Skip to main content

ArgGuard Tests Actions Status

ArgGuard is a simple abstract utility class to remove some boilerplate code when asserting class arguments.

Usage

The ArgGuard class provides the protected abstract _argGuard method. This is the method where all assertions, checks and validations of the class arguments should take place. Every class that extends the ArgGuard class needs to implement this method.

A second central method is _assert_args which stores the provided arguments and calls _argGuard. This method should be called as soon as possible in the constructor of the class to be guarded.

API

Method Args Description
_arg_guard self Abstract method where all assertions should take pace
_assert_args self, args Stores the provided arguments and calls _argGuard
_get_args self, *requested_args Retrieves all requested arguments
_get_required_args self, *requested_args Retrieves all requested arguments and fails if they are missing

Example

# Without ArgGuard
class A:
    def __init__(self, a, b, c=0):
        assert (
            'a' in self.__args
        ), 'Required argument "a" is missing'

        assert (
            'b' in self.__args
        ), 'Required argument "b" is missing'

        assert (
            a % b == 0
        ), 'a ({}) must be divisible by b ({})'.format(a, b)

        self.state = a // b + c

# With ArgGuard
class A(ArgGuard):
    def __init__(self, a, b, c=0):
        self._assert_args(locals())
        self.state = a // b + c

    def _arg_guard(self):
        # If a required argument is missing, an error is thrown
        a, b = self._get_required_args('a', 'b')

        assert (
            a % b == 0
        ), 'a ({}) must be divisible by b ({})'.format(a, b)

Metadata

Release files for argguard 0.0.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 argguard 0.0.1
File Size Uploaded Provenance Actions
argguard-0.0.1.tar.gz 3.3 kB Without provenance Details for argguard-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for argguard 0.0.1
File Interpreter ABI Platform Actions
argguard-0.0.1-py3-none-any.whl Python 3 none any Details for argguard-0.0.1-py3-none-any.whl

Total release size: 7.3 kB

Release files / argguard-0.0.1.tar.gz

Download URL argguard-0.0.1.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9056ed8a0af3284280706c73244577b3b5d15561c6d7d3ce1dfb35b029f42eee
BLAKE2b-256 checksum
How to use checksums
1112bcdc9da5e4513b918c1c00f9e7b8889c555cfd9ce4d22e2be3984efcb4a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

Release files / argguard-0.0.1-py3-none-any.whl

Download URL argguard-0.0.1-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b11b6cba136e920e8f3a7cee8ef03d32495ba2b87fb9b40041408077e16c228
BLAKE2b-256 checksum
How to use checksums
6d0cbee68ab76e625602dca44b5b488157468c0bc6eb1de0ace9c5aeb22d719d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

Security for argguard 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

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