To better support static type checkers PEP 593 introduced a new method for custom type annotations in Python 3.9 via typing.Annotated. The addition has been backported to older Python versions via typing-extensions.
The feature is entirely optional and does not require any additional dependencies when not being used and simple string annotations are still allowed.
All the decorators are still marked @no_type_check_decorator, but not all type checkers respect that (e.g. pyright).
To better support static type checkers PEP 593 introduced a new method for custom type annotations in Python 3.9 via typing.Annotated. The addition has been backported to older Python versions via
typing-extensions
.The feature is entirely optional and does not require any additional dependencies when not being used and simple string annotations are still allowed.
All the decorators are still marked
@no_type_check_decorator
, but not all type checkers respect that (e.g. pyright).Example: