bpo-46611: add coverage to instance and class checks in typing.py#31078
Conversation
| 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.
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.
Good point! () and [] surely have a different meaning here. Thanks, I will change them tomorrow.
There was a problem hiding this comment.
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.
(But I also don't want to hold up the PR, so I'll merge regardless.)
|
@gvanrossum I think this one can be merged. |
| 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.
(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