python-dbus-next icon indicating copy to clipboard operation
python-dbus-next copied to clipboard

PEP 593: Allow Annotated as type annotation

Open ldet opened this issue 2 years ago • 0 comments

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:

@method()
def some_method(self, one: Annotated[str, 's'], two: Annotated[str, 's']) -> Annotated[str, 's']:
    return 'hello'

ldet avatar Feb 04 '23 02:02 ldet