Skip to main content

codecov GitHub Workflow Status License MIT PyPI - Python Version PyPI - Wheel Github

kwargshelper

A python package for working with kwargs.

Allows for validation of args passed in via **kwargs in various ways. Such as type checking, rules checking, error handeling.

Many built in rules that make validation of input simple and effective. Easily create and add new rules.

Various callbacks to hook each kwarg with rich set of options for fine control.

Docs

Read the docs here

Installation

You can install the Version Class from PyPI

pip install kwargshelper

KwargsHelper Class

Helper class for working with python **kwargs in a class constructor

Assigns values of **kwargs to an exising class with type checking and rules

Parse kwargs with suport for rules that can be extended that validate any arg of kwargs. Type checking of any type.

Callback function for before update that includes a Cancel Option.

Many other options avaliable for more complex usage.

KwArg Class

Helper class for working with python **kwargs in a method/function Wrapper for KwargsHelper Class.

Assigns values of **kwargs to itself with validation

Parse kwargs with suport for rules that can be extended that validate any arg of kwargs. Type checking of any type.

Callback function for before update that includes a Cancel Option.

Many other options avaliable for more complex usage.

Decorator Classes

Decorators that can applied to function that validate arguments.

Decorators for Type checking and Rule testing is built in.

The following example ensures all function args are a positive int or a positive float.

from kwhelp.decorator import RuleCheckAny
import kwhelp.rules as rules

@RuleCheckAny(rules.RuleIntPositive, rules.RuleFloatPositive)
def speed_msg(speed, limit, **kwargs) -> str:
    if limit > speed:
        msg = f"Current speed is '{speed}'. You may go faster as the limit is '{limit}'."
    elif speed == limit:
        msg = f"Current speed is '{speed}'. You are at the limit."
    else:
        msg = f"Please slow down limit is '{limit}' and you are currenlty going '{speed}'."
    if 'hours' in kwargs:
        msg = msg + f" Current driving hours is '{kwargs['hours']}'"
    return msg

Metadata

Release files for kwargshelper 2.7.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 kwargshelper 2.7.1
File Size Uploaded
kwargshelper-2.7.1.tar.gz 35.8 kB Details

Built distribution (wheel)

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

Total release size: 74.5 kB

Release files / kwargshelper-2.7.1.tar.gz

Download URL kwargshelper-2.7.1.tar.gz
Size 35.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b063bd547efdc5b2edff601fe3c3c664dd2359f9fd86681b95d67ed34557d9ca
BLAKE2b-256 checksum
How to use checksums
500f9adde4b91aac07fc98876723b49deeffcb12e0da970e5cf3dc93366fd412
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/0.0.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / kwargshelper-2.7.1-py3-none-any.whl

Download URL kwargshelper-2.7.1-py3-none-any.whl
Size 38.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78b28f1dc2caf49d1a87c2f906112c58948049223276824fd612928d0ed1f731
BLAKE2b-256 checksum
How to use checksums
18a8fca7346ef5483097b66d46c9947ea9cf155347cdf98f40e175e78987c5a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/0.0.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

2.7.1 This release

2 release files

2.7.0

2 release files

2.6.0

2 release files

2.5.0

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.4

2 release files

2.1.3

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.0.4

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