typesentry
typesentry copied to clipboard
is_type method does not support modern Union syntax
Hello ! It appears the is_type method does not support the pipe separated Union from Python 3.10+.
# Legacy syntax
User: TypeAlias = Union[Administrator, Standard, Guest]
std_u = Standard()
is_type = tc1.Config().is_type
is_type(std_u, User) # Working as expected
# Modern syntax
User: TypeAlias = Administrator | Standard | Guest
std_u = Standard()
is_type = tc1.Config().is_type
is_type(std_u, User) # Raise Unknown type XXX | XXX | XXX for type-checker