FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-91621: Fix typing.get_type_hints for collections.abc.Callable by hauntsaninja · Pull Request #91656 · python/cpython · GitHub

Repository navigation

gh-91621: Fix typing.get_type_hints for collections.abc.Callable - #91656

Merged
JelleZijlstra merged 5 commits into
python:mainfrom
hauntsaninja:calltyp
May 2, 2022
Merged

JelleZijlstra merged 5 commits into
python:mainfrom
hauntsaninja:calltyp

Conversation

hauntsaninja commented Apr 18, 2022 •
edited by JelleZijlstra
Loading

Copy link
Copy Markdown
Contributor

This mirrors logic in typing.get_args. The trickiness comes from how we
flatten args in collections.abc.Callable, see
https://bugs.python.org/issue42195

#91621

This mirrors logic in typing.get_args. The trickiness comes from how we
flatten args in collections.abc.Callable, see
https://bugs.python.org/issue42195

Copy link
Copy Markdown
Contributor Author

I think we can skip news since this is just a fix for the unreleased #30900

AlexWaygood added type-bug An unexpected behavior, bug, or error topic-typing stdlib Standard Library Python modules in the Lib/ directory labels Apr 18, 2022

Copy link
Copy Markdown
Member

I think we can skip news since this is just a fix for the unreleased #30900

Was #30900 not included in 3.11a7? If it was, then I think this probably does need a short NEWS entry :)

Comment thread Lib/test/test_typing.py

Fidget-Spinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

Comment thread Lib/typing.py Outdated
for arg in t.__args__
)
t = t.__origin__[args]
if (t.__origin__ is collections.abc.Callable

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I know this code pattern appears once in Generic code and once here now. Should we just convert this into one function? Maybe _should_flatten_callable_args()? Seems abit tiresome to repeat this (and it's also confusing for people who haven't dealt with Callable's args before).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

(sorry, missed this comment)
I added a helper function for this

JelleZijlstra self-assigned this May 2, 2022
JelleZijlstra merged commit ebb8b51 into python:main May 2, 2022
hauntsaninja deleted the calltyp branch May 2, 2022 23:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stdlib Standard Library Python modules in the Lib/ directory topic-typing type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL