Skip to content

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

Closed

Description

@aless10

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.

Activity

  1. aless10 commented on Jan 21, 2023

    @aless10
    ContributorAuthor

    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
    
    
  2. JukkaL commented on Jan 21, 2023

    @JukkaL
    Collaborator

    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.

  3. aless10 commented on Jan 21, 2023

    @aless10
    ContributorAuthor

    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

  4. added a commit that references this issue on Jan 23, 2023
    77f8725
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions