Skip to main content

Arg Check

A Python utility for checking that call args have the expected types and all required args are provided.

Works only with Python 3.7 (fixing that soon)

Installation

pip install arg-check

Usage

This library uses simple decorators.

Argument Type Checking

@enforce_arg_types
def foobar(a: int, b: str):
    ...
  • Type checking is performed via the annotations. If an argument does not have an annotation, type checking is skipped just for that argument.
  • If an argument is a collection, all items in the collection are checked.
  • Can handle Union and Optional

Required Arguments

@required_args("a", "b")
def foobar(a, b, c=None):
    ...
  • Tests the given arguments and raises a ValueError if the value is either None or an empty string
  • To make all arguments required, use @required_args without parenthesis

All checks in one decorator

@strict_args
def foobar(a: int, b: str):
    ...
  • All arguments are type checked
  • All arguments are required

Metadata

Release files for argument-checks 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for argument-checks 0.1.1
File Size Uploaded
argument-checks-0.1.1.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for argument-checks 0.1.1
File Interpreter ABI Platform
argument_checks-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.4 kB

Release files / argument-checks-0.1.1.tar.gz

Download URL argument-checks-0.1.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e4648a2de088464fdec091e45a07afe9af4039653806f2a03073edae59619a00
BLAKE2b-256 checksum
How to use checksums
12d2d6ee0df0cc522b24632e9f73a28f69f70c0397573a67a0c3692f30ee0f7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.7.12 Linux/4.4.0-19041-Microsoft

Release files / argument_checks-0.1.1-py3-none-any.whl

Download URL argument_checks-0.1.1-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bac4006f6f051f7bb39e566630f4a0f9c8f279ff9495bf47733232e4b8573538
BLAKE2b-256 checksum
How to use checksums
bd97624df0e983d0431fc3a071d26745ca759ab380425c565ffdc257610e0db1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.7.12 Linux/4.4.0-19041-Microsoft

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page