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: master
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 force-pushed the fix-types-with-pep563 branch from aa0dbf1 to 50506cb Compare March 3, 2023 11:13
@terencehonles terencehonles force-pushed the fix-types-with-pep563 branch from 50506cb to d5d0ec6 Compare July 6, 2023 18:11
@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

@JoelLefkowitz JoelLefkowitz deleted the branch axnsan12:master October 17, 2024 11:55
@JoelLefkowitz JoelLefkowitz reopened this Oct 17, 2024
@JoelLefkowitz JoelLefkowitz changed the base branch from 1.21.x to master October 17, 2024 12:02
@JoelLefkowitz JoelLefkowitz added 1.23.x Release target in 1.23.x bug Bug report/fix labels Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.23.x Release target in 1.23.x bug Bug report/fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optional type hint schema generation support broken
2 participants