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

[Python APIView] Fix type parsing regression in Python 3.10 #2479

Merged
merged 9 commits into from
Jan 12, 2022

Conversation

tjprescott
Copy link
Member

@tjprescott tjprescott commented Dec 30, 2021

Fixes #2478.

Fixes #752.
https://apiviewstaging.azurewebsites.net/Assemblies/Review/170d3e834f4d48f28bc3d98e7c20d3d0?diffRevisionId=941daaf7bb3743c087fd6cb7a069b7e1&doc=False&diffOnly=True

Note that for Python 2 code, APIView does NOT read the typehints (except for return types). The type information comes from the docstring. Since we have dropped Python 2 support, there's no motivation to fix this.

Finally, this also updates the syntax for kwargs to match those obtained from type hints:
old: str = ...
new: Optional[str] = ...

Comment on lines 30 to 31
assert arg.argtype == "typing.Optional[str]"
assert arg.default == "None"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this test, we'll at least know when a version change breaks this behavior.

@tjprescott tjprescott marked this pull request as draft January 3, 2022 20:47
@tjprescott tjprescott force-pushed the tjprescott/Fix310ParseIssue branch 2 times, most recently from 5811094 to 8bf0bb7 Compare January 3, 2022 21:01
@tjprescott tjprescott marked this pull request as ready for review January 3, 2022 21:49
…string_parser.py

Co-authored-by: Johan Stenberg (MSFT) <johan.stenberg@microsoft.com>
Co-authored-by: Charles Lowell <10964656+chlowell@users.noreply.github.com>
@tjprescott
Copy link
Member Author

We'll merge this next week after the bulk of releases have gone out.

@tjprescott tjprescott merged commit 5e9f60d into main Jan 12, 2022
@tjprescott tjprescott deleted the tjprescott/Fix310ParseIssue branch January 12, 2022 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants