bpo-44794: Merge tests for typing.Callable and collection.abc.Callable#27507
Conversation
| 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.
👍 off topic: I find this really elegant.
| 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.
This is for consistency with the typing version right?
There was a problem hiding this comment.
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.
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