-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-46611: add coverage to instance and class checks in typing.py
#31078
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
Conversation
Lib/test/test_types.py
Outdated
self.assertIsInstance({}, x) | ||
self.assertTrue(issubclass(dict, x)) | ||
def test_instancecheck_and_subclasscheck(self): | ||
for x in [int | str, typing.Union[int, str]]: |
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.
Minor style thing;
for x in [int | str, typing.Union[int, str]]: | |
for x in (int | str, typing.Union[int, str]): |
Tuple parentheses are interpreted as grouping things, compared to a specific list object (+ avoid runs of brackets)
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.
Good point! ()
and []
surely have a different meaning here. Thanks, I will change them tomorrow.
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.
FWIW, I disagree with @merwok -- anything you iterate over surely is more like a list than like a tuple.
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.
(But I also don't want to hold up the PR, so I'll merge regardless.)
@gvanrossum I think this one can be merged. |
Lib/test/test_types.py
Outdated
self.assertIsInstance({}, x) | ||
self.assertTrue(issubclass(dict, x)) | ||
def test_instancecheck_and_subclasscheck(self): | ||
for x in [int | str, typing.Union[int, str]]: |
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.
(But I also don't want to hold up the PR, so I'll merge regardless.)
Thanks @sobolevn for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10. |
Sorry @sobolevn and @gvanrossum, I had trouble checking out the |
…g.py` (pythonGH-31078) (cherry picked from commit 067c03b) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
GH-31182 is a backport of this pull request to the 3.10 branch. |
Some proofs that these lines were not covered:


Now, they are! 👍
https://bugs.python.org/issue46611