Open VictorSizov opened 1 month ago
I'm struggling to reproduce this on mypy-playground or locally. Do you have any configuration files lying around, e.g. pyproject.toml
or mypy.ini
?
I can reproduce it with Python 3.8.10, but not with a more recent version, like Python 3.11.0.
Thanks, I can reproduce this too on 3.8:
% .venv/bin/python3.8 -m mypy -c 'from typing import List; x: List[:str]' --show-traceback
error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.11.1
Traceback (most recent call last):
File "/Users/jelle/Library/Application Support/uv/python/cpython-3.8.19-macos-aarch64-none/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Users/jelle/Library/Application Support/uv/python/cpython-3.8.19-macos-aarch64-none/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/jelle/py/tmp/.venv/lib/python3.8/site-packages/mypy/__main__.py", line 37, in <module>
console_entry()
File "mypy/build.py", line 2069, in wrap_context
File "mypy/build.py", line 2176, in parse_file
File "mypy/build.py", line 841, in parse_file
File "mypy/parse.py", line 27, in parse
File "mypy/fastparse.py", line 234, in parse
File "mypy/fastparse.py", line 401, in visit
File "mypy/fastparse.py", line 860, in visit_Module
File "mypy/fastparse.py", line 475, in translate_stmt_list
File "mypy/fastparse.py", line 401, in visit
File "mypy/fastparse.py", line 1241, in visit_AnnAssign
File "mypy/fastparse.py", line 1877, in visit
File "mypy/fastparse.py", line 2065, in visit_Subscript
AttributeError: 'NoneType' object has no attribute 'col_offset'
: note: use --pdb to drop into pdb
@VictorSizov the bug in your code is that you have List[:str]
instead of List[str]
. Fixing that should make the crash go away.
However, of course this is still a bug in mypy; mypy should report an error here instead of crashing.
Crash Report
Validating of my python module causes "INTERNAL ERROR"
Traceback
version: 1.11.1 Traceback (most recent call last): File "/home/sizov/Documents/root/venv/bin/mypy", line 8, in
sys.exit(console_entry())
File "mypy/build.py", line 2069, in wrap_context
File "mypy/build.py", line 2176, in parse_file
File "mypy/build.py", line 841, in parse_file
File "mypy/parse.py", line 27, in parse
File "mypy/fastparse.py", line 234, in parse
File "mypy/fastparse.py", line 401, in visit
File "mypy/fastparse.py", line 860, in visit_Module
File "mypy/fastparse.py", line 475, in translate_stmt_list
File "mypy/fastparse.py", line 401, in visit
File "mypy/fastparse.py", line 873, in visit_FunctionDef
File "mypy/fastparse.py", line 890, in do_func_def
File "mypy/fastparse.py", line 1072, in transform_args
File "mypy/fastparse.py", line 1115, in make_argument
File "mypy/fastparse.py", line 1877, in visit
File "mypy/fastparse.py", line 2086, in visit_Subscript
File "mypy/fastparse.py", line 1877, in visit
File "mypy/fastparse.py", line 2065, in visit_Subscript
AttributeError: 'NoneType' object has no attribute 'col_offset'
parser.py: : note: use --pdb to drop into pdb
To Reproduce
write stand-alone example to disk as python file:
and call "mypy \<stand-alone example>"
My Environment