paramak
paramak copied to clipboard
Adding precontions to type hints
When checking for types passed into functions it can be useful to ensure only positive ints or positive floats
Here is an example
https://stackoverflow.com/questions/61546201/python-typehint-int-as-positive
Perhaps a new class called PositiveInt is the way to go
Perhaps pydantic can help here https://pydantic-docs.helpmanual.io/usage/types/#constrained-types