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

python3 runtests.py fails if python version == 3.11 #14487

Closed
aless10 opened this issue Jan 21, 2023 · 3 comments · Fixed by #14492
Closed

python3 runtests.py fails if python version == 3.11 #14487

aless10 opened this issue Jan 21, 2023 · 3 comments · Fixed by #14492
Labels
bug mypy got something wrong good-first-issue topic-developer Issues relevant to mypy developers topic-tests

Comments

@aless10
Copy link
Contributor

aless10 commented Jan 21, 2023

Bug Report

Following the contributor guide I run the command python3 runtests.py and I got an error, based on the python version that I use in my virtualenv vs the one listed in the ini file (3.7).

To Reproduce

python3 runtests.py

Expected Behavior

No errors

Actual Behavior

run self: ['/Users/alessioizzo/alessio/mypy/venv/bin/python3', '-m', 'mypy', '--config-file', 'mypy_self_check.ini', '-p', 'mypy']
mypy/config_parser.py:16: error: Cannot find implementation or library stub for module named "tomli"  [import]
        import tomli as tomllib
    ^
mypy/config_parser.py:16: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
mypy/modulefinder.py:22: error: Cannot find implementation or library stub for module named "tomli"  [import]
        import tomli as tomllib
    ^
Found 2 errors in 2 files (checked 169 source files)

FAILED: self

Your Environment

  • Mypy version used: latest from git clone
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files): mypy_self_check.ini
  • Python version used: 3.11
  • OS: macos Apple M1 Pro, Ventura 13.1

I guess that the solution can be to remove the python version from the ini file. I'm going to open a pull request for this one if this happens to be a bug.

@aless10 aless10 added the bug mypy got something wrong label Jan 21, 2023
@aless10
Copy link
Contributor Author

aless10 commented Jan 21, 2023

I add that, removing the python version from the mypy_self_check.ini file, I got these errors

run self: ['/Users/alessioizzo/alessio/mypy/venv/bin/python3', '-m', 'mypy', '--config-file', 'mypy_self_check.ini', '-p', 'mypy']
mypy/fastparse.py:844: error: Unused "type: ignore" comment
                parsed = parse_type_ignore_tag(ti.tag)  # type: ignore[attr-defined]
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mypy/fastparse.py:1569: error: Left operand of "or" is always false  [redundant-expr]
            conv_str = "" if n.conversion is None or n.conversion < 0 else "!" + chr(n.conversion)
                             ^~~~~~~~~~~~~~~~~~~~
mypy/fastparse.py:2013: error: Unused "type: ignore" comment
                            s.col_offset = s.value.col_offset  # type: ignore[attr-defined]
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mypy/fastparse.py:2016: error: Unused "type: ignore" comment
                            s.col_offset = s.lower.col_offset  # type: ignore[attr-defined]
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 4 errors in 1 file (checked 169 source files)

FAILED: self

@AlexWaygood AlexWaygood added topic-developer Issues relevant to mypy developers topic-tests labels Jan 21, 2023
@JukkaL
Copy link
Collaborator

JukkaL commented Jan 21, 2023

I've seen this as well. As a workaround, you can run pip install tomli.

We want to always type check in 3.7 mode to make sure we don't use any features from more recent Python versions.

The fix would be to install tomli in test-requirements.txt, I guess.

@aless10 Would you like to contribute a fix? It should be easy.

@aless10
Copy link
Contributor Author

aless10 commented Jan 21, 2023

Ok, but while running the runtests.py command, I got this error

run self: ['/Users/alessioizzo/alessio/mypy/venv/bin/python3', '-m', 'mypy', '--config-file', 'mypy_self_check.ini', '-p', 'mypy']
mypy/fastparse.py:844: error: "TypeIgnore" has no attribute "tag"  [attr-defined]
                parsed = parse_type_ignore_tag(ti.tag)
                                               ^~~~~~
mypy/fastparse.py:1569: error: Unused "type: ignore" comment
            conv_str = "" if n.conversion is None or n.conversion < 0 else "!" + chr(n.conversion)  # type: ignore[redundant-expr]
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mypy/fastparse.py:2013: error: "Index" has no attribute "col_offset"  [attr-defined]
                            s.col_offset = s.value.col_offset
                            ^~~~~~~~~~~~
mypy/fastparse.py:2016: error: "Slice" has no attribute "col_offset"  [attr-defined]
                            s.col_offset = s.lower.col_offset
                            ^~~~~~~~~~~~
Found 4 errors in 1 file (checked 169 source files)

FAILED: self

I'd like also to fix this and update the README in order to explicit the fact that we want to use the 3.7 version. Is that ok?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong good-first-issue topic-developer Issues relevant to mypy developers topic-tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants