Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 593: Allow Annotated as type annotation #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ldet
Copy link

@ldet ldet commented Feb 4, 2023

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant