rj-type-hint-checker

a rough equivilent of isinstance that works with type hints


Keywords
isinstance, type, hints, types
License
Other
Install
pip install rj-type-hint-checker==0.0.0

Documentation

Type Hint Checker

a replacement for isinstance that works with type hints

exports are_type_compatible which can be used as a drop in replacement for isinstance but works with type hints

are_type_compatible([0, 1, 2], list[int]) # true
are_type_compatible([0, 1, "2"], list[int]) # false

also takes two optional arguments the context which would be the function or class the type hint came from and the namespace which is the namespace to search for types