Skip to content

potfur/strict-hint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Strict hint

Strict hint provides a way to do runtime type checks based based on type hint annotations introduced by PEP-484.

Usage is quite simple, just add type annotations to a function or method and decorate it with `@strict`:

from strict_hint import strict

@strict
def add(a: int: b: int) -> int:
    return a+b

If non int will be passed, a TypeError will be raised. Same will happen if function would return different type than expected.

Type checks support (for arguments and returned values):
  • all primitive type hints: int, float, list, tuple, set, dict, etc.,
  • standard interpreter types eg.: FunctionType and other,
  • tuples of types, eg: (int, float) will allow for both types to be accepted,
  • default values, also of different type than annotation: eg. a: int = None
  • used defined classes and class inheritance

About

Strict type runtime checks for arguments and return types

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages