paramak icon indicating copy to clipboard operation
paramak copied to clipboard

Adding precontions to type hints

Open shimwell opened this issue 3 years ago • 0 comments

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

shimwell avatar Nov 19 '21 11:11 shimwell