Skip to content

[3.9] bpo-42195: Ensure consistency of Callable's __args__ in collections.abc and typing (GH-23060) #23765

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

Merged
merged 2 commits into from
Dec 14, 2020

Conversation

Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented Dec 14, 2020

This patch fixes bpo-42195 via changing the GenericAlias builtin and subclassing for collections.abc.Callable's __class_getitem__. The changes are:

  1. Made GenericAlias subclassable.
  2. Subclassed it in collections.abc.Callable's __class_getitem__ to allow for consistentency with typing.Callable's __args__. This includes flattening the __args__.
>>> import collections.abc
>>> alias = collections.abc.Callable[[int, str], dict]

>>> alias
collections.abc.Callable[[int, str], dict]

>>> alias.__args__
(int, str, dict)
  1. Added tests for the above.
  2. Loosened type checks for Callable's argtypes in Callable[[argtypes], resulttype] to prepare for PEP 612.

https://bugs.python.org/issue42195

(cherry picked from commit 463c7d3)

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Thanks! Just what I had in mind.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@gvanrossum
Copy link
Member

I don't understand why you get test failures for test_ttk_guionly, but I don't think it's your fault. Possibly it'll pass now the tests are bein rerun.

@gvanrossum gvanrossum merged commit 33b3fed into python:3.9 Dec 14, 2020
@Fidget-Spinner Fidget-Spinner deleted the 3.9-abc-callable-ga branch December 18, 2020 14:12
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.

4 participants