python/mypy

More "syntax error in type comment"s

Closed this issue · 6 comments

Bug Report

Related to #8627

To Reproduce

# cat <<DOG > some.py
import subprocess
DOG
# mypy some.py | head
/Users/Knoble/Library/Python/3.9/lib/python/site-packages/mypy/typeshed/stdlib/3/subprocess.pyi:50: error: syntax error in type comment
/Users/Knoble/Library/Python/3.9/lib/python/site-packages/mypy/typeshed/stdlib/3/subprocess.pyi:63: error: syntax error in type comment
/Users/Knoble/Library/Python/3.9/lib/python/site-packages/mypy/typeshed/stdlib/3/subprocess.pyi:66: error: syntax error in type comment
/Users/Knoble/Library/Python/3.9/lib/python/site-packages/mypy/typeshed/stdlib/3/subprocess.pyi:67: error: syntax error in type comment
/Users/Knoble/Library/Python/3.9/lib/python/site-packages/mypy/typeshed/stdlib/3/subprocess.pyi:77: error: syntax error in type comment
/Users/Knoble/Library/Python/3.9/lib/python/site-packages/mypy/typeshed/stdlib/3/subprocess.pyi:78: error: syntax error in type comment
/Users/Knoble/Library/Python/3.9/lib/python/site-packages/mypy/typeshed/stdlib/3/subprocess.pyi:79: error: syntax error in type comment
/Users/Knoble/Library/Python/3.9/lib/python/site-packages/mypy/typeshed/stdlib/3/subprocess.pyi:80: error: syntax error in type comment
/Users/Knoble/Library/Python/3.9/lib/python/site-packages/mypy/typeshed/stdlib/3/subprocess.pyi:81: error: syntax error in type comment
/Users/Knoble/Library/Python/3.9/lib/python/site-packages/mypy/typeshed/stdlib/3/subprocess.pyi:82: error: syntax error in type comment
# trimmed …

Expected Behavior

No issues

Actual Behavior

Unable to effectively sort through messages because of the ~360 from this module alone

Your Environment

  • Mypy version used: 740 and 790
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.9.1
  • Operating system and version: macOS Mojave 10.14.6 18G5033 x86_64

Expected on 0.740, but was fixed well before 0.790 (and I can't repro). Feel free to re-open if you can't get it to work, but closing since I'm quite sure you're still using an old mypy (maybe try hash -r).

Hm, yes, in spite of installing a fresh copy in a venv, it seems there was an issue with which mypy was used. Thank you.

I'm trying to use mypy 0.812 with python 3.9.4 on Arch but am seeing these:

/home/user/.cache/pre-commit/repobrxmsytl/py_env-python3/lib/python3.9/site-packages/mypy/typeshed/stdlib/2and3/builtins.pyi:1679: error:
syntax error in type comment  [syntax]
            def truncate(self, pos: Optional[int] = ...) -> int: ...

I'm also using venv if that makes a difference?

EDIT:

My fault - fixed by updating the version of mypy being called via pre-commit.

For those who have gotten this after an upgrade to Python 3.9, I was able to get things fixed with mypy==0.782.

I generally would recommend running the latest mypy unless something is holding you back.

In an ideal world yup, but unfortunately because of the breaking changes that get introduced in new versions of mypy, the amount of effort required to upgrade something is O(nm), n being the size of the codebase and m being the difference in versions.