Closed helderco closed 2 years ago
Thanks for reminding me of this feature @helderco, we should definitely do that. Though it's only available since Python 3.10, it also can be used in earlier Python versions via typing-extensions.
Commited to the main branch, will be available in the next (alpha) release of version 3.3.
As an example I specifically need them in
type/definition.py
to correctly narrow down the types in a codegen tool. In the meantime I've reimplemented these functions:I thought the
isinstance
would be enough for the type checker to infer in these cases but if the return type isbool
in these functions they're not narrowed.