Skip to content
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

Y041 is not compatible with mypy 0.990 #299

Closed
kasium opened this issue Nov 8, 2022 · 3 comments · Fixed by #305
Closed

Y041 is not compatible with mypy 0.990 #299

kasium opened this issue Nov 8, 2022 · 3 comments · Fixed by #305
Assignees
Labels

Comments

@kasium
Copy link

kasium commented Nov 8, 2022

With mypy 0.990 type promotions was changed.

Before

class Foo:
  a: complex

isinstance(Foo().a, int)  # fine

After

class Foo:
  a: complex

isinstance(Foo().a, int)  # fails

class Foo:
  a: complex | float | int  # raises Y041 

isinstance(Foo().a, int)  # fine

Not sure what to do with this check, but just raining attention.
See python/mypy#14030 and python/typeshed#9130

@ilevkivskyi
Copy link

Actually mypy allows type promotions in subtyping so add(1,2) is OK. There are just specific legitimate use cases for a union (related to e.g. isinstance() checks).

@kasium
Copy link
Author

kasium commented Nov 8, 2022

@ilevkivskyi thanks. I adjusted the code

@AlexWaygood
Copy link
Collaborator

AlexWaygood commented Nov 8, 2022

Thanks for opening the issue!

Let's use python/mypy#14030 for discussing this problem for now until we've reached an agreement on what to do; not sure it's helpful to have discussion split across 3 repos.

@AlexWaygood AlexWaygood self-assigned this Nov 14, 2022
charliermarsh pushed a commit to astral-sh/ruff that referenced this issue Jul 13, 2023
## Summary

Implements PYI041 from flake8-pyi. See [original
code](https://github.com/PyCQA/flake8-pyi/blob/2a86db8271dc500247a8a69419536240334731cf/pyi.py#L1283).

This check only applies to function parameters in order to avoid issues
with mypy. See PyCQA/flake8-pyi#299.

ref: #848

## Test Plan

Snapshots, manual runs of flake8.
evanrittenhouse pushed a commit to evanrittenhouse/ruff that referenced this issue Jul 19, 2023
## Summary

Implements PYI041 from flake8-pyi. See [original
code](https://github.com/PyCQA/flake8-pyi/blob/2a86db8271dc500247a8a69419536240334731cf/pyi.py#L1283).

This check only applies to function parameters in order to avoid issues
with mypy. See PyCQA/flake8-pyi#299.

ref: astral-sh#848

## Test Plan

Snapshots, manual runs of flake8.
konstin pushed a commit to astral-sh/ruff that referenced this issue Jul 19, 2023
## Summary

Implements PYI041 from flake8-pyi. See [original
code](https://github.com/PyCQA/flake8-pyi/blob/2a86db8271dc500247a8a69419536240334731cf/pyi.py#L1283).

This check only applies to function parameters in order to avoid issues
with mypy. See PyCQA/flake8-pyi#299.

ref: #848

## Test Plan

Snapshots, manual runs of flake8.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants