-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-44794: Merge tests for typing.Callable and collection.abc.Callable #27507
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
bpo-44794: Merge tests for typing.Callable and collection.abc.Callable #27507
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I just have a few questions below.
Phew, this refactored a lot of other tests in typing too. Thanks.
self.assertEqual(c1.__args__, c2.__args__) | ||
self.assertEqual(hash(c1.__args__), hash(c2.__args__)) | ||
|
||
test_errors = skip("known bug #44793")(BaseCallableTests.test_errors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 off topic: I find this really elegant.
@@ -478,8 +478,7 @@ def __getitem__(self, item): | |||
# then X[int, str] == X[[int, str]]. | |||
param_len = len(self.__parameters__) | |||
if param_len == 0: | |||
raise TypeError(f'There are no type or parameter specification' | |||
f'variables left in {self}') | |||
raise TypeError(f'{self} is not a generic class') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for consistency with the typing version right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a minor bug in the old error message: missed space between "specification" and "variables".
Also, there is no reason to have different error messages for two implementations, so I changed one of them. I hope I left the better one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I didn't notice the space. Good eye!
The message is copied from Py_GenericAlias for consistency with the rest of the collections.abc https://github.com/python/cpython/blob/main/Objects/genericaliasobject.c#L303
However, keeping it same with the old typing.Callable
should be fine too.
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10. |
GH-27514 is a backport of this pull request to the 3.10 branch. |
pythonGH-27507) (cherry picked from commit be4cb90) Co-authored-by: Serhiy Storchaka <[email protected]>
GH-27507) (cherry picked from commit be4cb90) Co-authored-by: Serhiy Storchaka <[email protected]>
https://bugs.python.org/issue44794