Skip to content

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

Merged
merged 1 commit into from
Jul 31, 2021

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Jul 31, 2021

Copy link
Member

@Fidget-Spinner Fidget-Spinner left a 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)
Copy link
Member

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')
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

@serhiy-storchaka serhiy-storchaka merged commit be4cb90 into python:main Jul 31, 2021
@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@serhiy-storchaka serhiy-storchaka deleted the test-typing-Callable branch July 31, 2021 17:05
@bedevere-bot
Copy link

GH-27514 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jul 31, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 31, 2021
miss-islington added a commit that referenced this pull request Jul 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants