Skip to content

Python package for runtime function arguments type and constraint validation

Notifications You must be signed in to change notification settings

lubie0kasztanki/pythonrules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

Simply decorate your function with @ruled() and put rules as type hints. Any time one of them gets violated a RuleViolationException will be thrown.

Examples

# basic pep484 type checking
@ruled()
def f(x : int):
    pass

# type check, length check and combination
@ruled()
def g(x : str, y : LenRule(3, "=="), z : (str, LenRule(3, "=="))):
    pass

About

Python package for runtime function arguments type and constraint validation

Topics

Resources

Stars

Watchers

Forks

Languages