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

[MERGE AFTER #868] fix type hints when using postponed evaluation of annotations (PEP-563) #840

Open
wants to merge 2 commits into
base: 1.21.x
Choose a base branch
from

Conversation

terencehonles
Copy link
Contributor

@terencehonles terencehonles commented Mar 3, 2023

This change uses typing.get_type_hints instead of inspect.signature since the former will try to eval string type hints (PEP-563) and will return an object rather than a string if it was successful which will allow the remaining code to work. inspect.signature on the other hand does not have the ability to resolve string type hints until Python 3.10 and has to be called with eval_str=True

This also partially reverts #428, but fixes #426 correctly by not failing on the isclass(hint_class) check due to annotations not "really" being classes.

This latter change is done because list[str] is unconditionally and improperly unwrapped and will result in a type of str since list's annotations will also have a first argument of str.

@terencehonles terencehonles changed the title fix type hints when using postponed evaluation of annotations (PEP-563) [MERGE AFTER #868] fix type hints when using postponed evaluation of annotations (PEP-563) Sep 7, 2023
@terencehonles
Copy link
Contributor Author

Marking this to be merged after #868, but combining both PRs to confirm this fixes the lint check

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.

None yet

1 participant