| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Since mypy 0.990 type promotions was limited. This means that complex is not longer promoted to int/float, therefore we should adapt the types to list all possible types Closes python#9129
|
Mypy flake8 doesn't like it ./stdlib/_ast.pyi:332:12: Y041 Use "complex" instead of "float | complex" (see "The numeric tower" in PEP 484) |
Sorry, something went wrong.
|
Well I guess we can exclude Y041 (it is not very useful IMO), or if people still like it, you can put a # noqa: Y041 on those lines. |
Sorry, something went wrong.
|
@ilevkivskyi I added a noqa for now and opened an issue at flake8-pyi |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for the PR!
I'd like to discuss this a little more before we go ahead with this. We may want to do a complete revert of #7906 if we need to go down this route.
Sorry, something went wrong.
|
I don't think we need to do a full revert. It needs to be decided on case by case basis. For example, in function argument types using promotions is OK (unless function behaves differently for int and float). |
Sorry, something went wrong.
There was a problem hiding this comment.
Changes to stubs look good!
Sorry, something went wrong.
|
Hi, |
Sorry, something went wrong.
|
Hi @kasium! The discussion in the mypy issue means that it looks like the behaviour change in mypy is about to be (partially) reverted: python/mypy#14077. So I don't think there's a massive rush to get this merged :) Having said that, I'm happy for the changes to the ast and typed-ast stubs to go in. The typing specs don't precisely specify how type checkers should deal with implicit promotions with respect to attribute annotations. As such, we should err on the side of fully specified behaviour, and not rely on implicit promotions for these cases over at typeshed. So the changes to the ast and typed-ast stubs look good to me. I'd rather fix flake8-pyi first, however, so that it only emits Y041 for parameter annotations. Then we won't need to switch off Y041 in typeshed's .flake8 config file, and this PR can be focused solely on the changes to the ast and typed-ast stub. I should be able to create a flake8-pyi fix and release at some point in the next few days. |
Sorry, something went wrong.
|
I've asked if there's any chance of getting a mypy patch release with python/mypy#14077 included: python/mypy#13871 (comment). |
Sorry, something went wrong.
|
Update: mypy doesn't want to include python/mypy#14077 in a patch release. So let's merge this as a quick fix. |
Sorry, something went wrong.
|
Diff from mypy_primer, showing the effect of this PR on open source code: flake8-pyi (https://github.com/PyCQA/flake8-pyi)
- pyi.py:1126: error: Subclass of "complex" and "int" cannot exist: would have incompatible method signatures [unreachable]
- pyi.py:1275: error: Subclass of "complex" and "int" cannot exist: would have incompatible method signatures [unreachable]
- pyi.py:1275: error: Right operand of "and" is never evaluated [unreachable]
- pyi.py:1276: error: Statement is unreachable [unreachable]
- pyi.py:1287: error: Subclass of "complex" and "int" cannot exist: would have incompatible method signatures [unreachable]
- pyi.py:1288: error: Right operand of "and" is never evaluated [unreachable]
- pyi.py:1290: error: Statement is unreachable [unreachable]
- pyi.py:1313: error: Subclass of "complex" and "int" cannot exist: would have incompatible method signatures [unreachable]
|
Sorry, something went wrong.
|
Thanks for the fast work! |
Sorry, something went wrong.
improve ast types; revert several "redundant numeric union" changes from #7906 see python/typeshed#9130
|
@kasium — looks like the ast fixes will be included in the next mypy patch release, possibly coming out later today: python/mypy#13871 (comment) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Since mypy 0.990 type promotions was limited.
This means that complex is not longer promoted to int/float, therefore we should adapt the types to list all possible types
Closes #9129