-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[mypyc] Use PyList_Check for isinstance(obj, list) #19416
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -537,3 +537,33 @@ def test_sorted() -> None: | |
| assert sorted((2, 1, 3)) == res | ||
| assert sorted({2, 1, 3}) == res | ||
| assert sorted({2: "", 1: "", 3: ""}) == res | ||
|
|
||
| [case testIsInstance] | ||
| from copysubclass import subc | ||
| def test() -> None: | ||
| assert isinstance([], list) | ||
p-sawicki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert isinstance([1,2,3], list) | ||
| assert isinstance(['a','b'], list) | ||
| assert isinstance(subc(), list) | ||
| assert isinstance(subc([1,2,3]), list) | ||
| assert isinstance(subc(['a','b']), list) | ||
|
|
||
| assert not isinstance({}, list) | ||
p-sawicki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert not isinstance((), list) | ||
| assert not isinstance((1,2,3), list) | ||
| assert not isinstance(('a','b'), list) | ||
| assert not isinstance(1, list) | ||
| assert not isinstance('a', list) | ||
|
|
||
| [file copysubclass.py] | ||
| from typing import Any | ||
| class subc(list[Any]): | ||
| pass | ||
|
|
||
| [case testUserDefinedList] | ||
| class list: | ||
| pass | ||
|
|
||
| def test() -> None: | ||
|
||
| assert isinstance(list(), list) | ||
| assert not isinstance([list()], list) | ||
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.
Similar to my other comment about
test_prefix.