Skip to content

bpo-42195: Disallow isinstance/issubclass for subclasses of genericaliases in Union #24059

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
Jan 2, 2021

Conversation

Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented Jan 2, 2021

Previously this didn't raise an error. Now it will:

from collections.abc import Callable
isinstance(int, list | Callable[..., str])

Also added tests in Union since there were previously none for stuff like isinstance(list, list | list[int]) either.

Backport to 3.9 not required.

https://bugs.python.org/issue42195

Automerge-Triggered-By: GH:gvanrossum

@Fidget-Spinner
Copy link
Member Author

I think we can skip news, the code was valid up till before PR-23060 so it can share the same news as that one.

@miss-islington miss-islington merged commit 49cd68f into python:master Jan 2, 2021
@Fidget-Spinner Fidget-Spinner deleted the union-block-callable branch January 2, 2021 16:26
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
…iases in Union (pythonGH-24059)

Previously this didn't raise an error. Now it will:
```python
from collections.abc import Callable
isinstance(int, list | Callable[..., str])
```
Also added tests in Union since there were previously none for stuff like ``isinstance(list, list | list[int])`` either.

Backport to 3.9 not required.

Automerge-Triggered-By: GH:gvanrossum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants