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

Positional-only parameters with python 3.10.7 (and numpy) (fixed in 0.981) #13627

Closed
sodul opened this issue Sep 8, 2022 · 8 comments · Fixed by ImperialCollegeLondon/virtual_ecosystem#110 or pawngrubber/template#29
Labels
bug mypy got something wrong

Comments

@sodul
Copy link

sodul commented Sep 8, 2022

Bug Report

After upgrading to python 3.10.7 from 3.10.6 mypy is reporting errors on numpy .pyi files when positional only parameters syntax is present. This error should only get triggered when using versions of python older than 3.8. After rolling back to python 3.10.6 no errors are being reported.

To Reproduce

(Write your steps here:)

  1. mypy something_using_numpy.py

Expected Behavior

It should pass without any problem

Actual Behavior

/Users/stephane/.pyenv/versions/3.10.7/lib/python3.10/site-packages/numpy/__init__.pyi:636:48: error: Positional-only parameters are only supported in Python 3.8 and greater  [syntax]
Found 1 error in 1 file (errors prevented further checking)

Your Environment

  • mypy==0.971
  • Mypy command-line flags: none
  • Mypy configuration options:
python_version=3.10
sqlite_cache=True
namespace_packages=True
ignore_missing_imports=True
follow_imports=silent
show_column_numbers=True
check_untyped_defs=True
show_error_codes=True
  • Python 3.10.7 (3.10.6 is working fine).
  • macOS 12.5.1, Apple CPU
  • numpy==1.23.2
@sodul sodul added the bug mypy got something wrong label Sep 8, 2022
@michael-k
Copy link
Contributor

michael-k commented Sep 8, 2022

This might be related to

[:func:`ast.parse`](https://github.com/python/cpython/blob/v3.10.7/Misc/NEWS.d/3.10.7.rst#id13)
will no longer parse function definitions with positional-only params when passed feature_version
less than (3, 8). Patch by Shantanu Jain.

Source: https://github.com/python/cpython/blob/v3.10.7/Misc/NEWS.d/3.10.7.rst

Related pull requests/issues:

@michael-k
Copy link
Contributor

Looks like this was already fixed in #13500 (unreleased)

@AlexWaygood
Copy link
Member

AlexWaygood commented Sep 8, 2022

Yup, a mypy release with the fix will be out soon (might be included in mypy 0.980, if not it will be in mypy 0.990).

Edit: fix was included in 0.981 and newer

@atugushev
Copy link
Contributor

Any known workaround for this?

@AlexWaygood
Copy link
Member

Any known workaround for this?

Pin Python to 3.10.6 (not 3.10.7).

nsmith- added a commit to cms-nanoAOD/correctionlib that referenced this issue Sep 13, 2022
* Try alternative xxhash implementation

Hopefully it can compile on non-x86 arch

* Pin formatting CI python version

To work around python/mypy#13627

* Revert adding pypy to builds

* Add includes in makefile as well
dalcinl added a commit to mpi4py/mpi4py that referenced this issue Sep 15, 2022
DoctorDalek1963 added a commit to DoctorDalek1963/lintrans that referenced this issue Sep 28, 2022
jeremieb-pass added a commit to pass-culture/pass-culture-main that referenced this issue Sep 29, 2022
It seems that there is a bug with mypy and python 3.10.7:

"After upgrading to python 3.10.7 from 3.10.6 mypy is reporting errors
on numpy .pyi files when positional only parameters syntax is present.
This error should only get triggered when using versions of python older
than 3.8. After rolling back to python 3.10.6 no errors are being
reported."

python/mypy#13627
whitphx added a commit to whitphx/stlite that referenced this issue Oct 1, 2022
whitphx added a commit to whitphx/stlite that referenced this issue Oct 1, 2022
whitphx added a commit to whitphx/stlite that referenced this issue Oct 2, 2022
whitphx added a commit to whitphx/stlite that referenced this issue Oct 2, 2022
* Remove tornado submodule

* Rename packages/stlite-kernel to packages/kernel

* Add submodule packages/kernel/py/tornado

* Replace @stlite/stlite-kernel usage with @stlite/kernel

* Replace stlite-kernel with kernel in the CI workflows

* Update mypy due to python/mypy#13627
Arista-Jenkins pushed a commit to aristanetworks/cloudvision-python that referenced this issue Oct 5, 2022
Running the linting with the latest image fails as it raises issues with mypy
See: python/mypy#13627

Change-Id: I98bb6e713f3e32d7dae0ca0398a3e7632e0e886d
astropenguin added a commit to astropenguin/pandas-dataclasses that referenced this issue Oct 5, 2022
Iain-S added a commit to Iain-S/sentry-bot that referenced this issue Oct 7, 2022
The older MyPy version had a bug.
See python/mypy#13627
Iain-S added a commit to Iain-S/sentry-bot that referenced this issue Oct 7, 2022
The older MyPy version had a bug.
See python/mypy#13627
calpaterson added a commit to calpaterson/csvbase that referenced this issue Oct 8, 2022
python/mypy#13627 now causes spurious errors
involving numpy but another type issue is solved.
dalcinl added a commit to mpi4py/mpi4py that referenced this issue Oct 10, 2022
dalcinl added a commit to mpi4py/mpi4py that referenced this issue Oct 10, 2022
@hauntsaninja
Copy link
Collaborator

If you're running into this, use mypy 0.981 or newer or downgrade to Python 3.10.6

@python python locked as resolved and limited conversation to collaborators Oct 13, 2022
@hauntsaninja hauntsaninja unpinned this issue Oct 30, 2022
bengsparks added a commit to multidim-typeinf4py/dynamic-pytypes that referenced this issue Nov 6, 2022
frankh added a commit to PostHog/posthog that referenced this issue Feb 22, 2023
Needed this bug to be fixed: python/mypy#13627

This also incidentally fixed the mypy bug in csv_exporter.py
hazzadous pushed a commit to PostHog/posthog that referenced this issue Feb 24, 2023
* Python 3.10

Performance gains go brrr

* Add missing SAML deps

* Add missing dep to dockerfile

* Update mypy to 0.981 for 3.10.7 compatibility

Needed this bug to be fixed: python/mypy#13627

This also incidentally fixed the mypy bug in csv_exporter.py

* bump to 3.10.10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants