You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mypy crashes when inheriting from a locally defined namedtuple, when all of the following is true:
Its fields are not a literal
Another file generates an attr-defined error
Cache is enabled (without --no-incremental)
Seems to be related to #10913, but produces a traceback similar to the closed #7281.
Traceback
Traceback (most recent call last):
File "/home/.../env/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/home/.../env/lib/python3.7/site-packages/mypy/__main__.py", line 11, in console_entry
main(None, sys.stdout, sys.stderr)
File "mypy/main.py", line 87, in main
File "mypy/main.py", line 165, in run_build
File "mypy/build.py", line 179, in build
File "mypy/build.py", line 254, in _build
File "mypy/build.py", line 2697, in dispatch
File "mypy/build.py", line 3014, in process_graph
File "mypy/build.py", line 3092, in process_fresh_modules
File "mypy/build.py", line 1991, in fix_cross_refs
File "mypy/fixup.py", line 26, in fixup_module
File "mypy/fixup.py", line 90, in visit_symbol_table
File "mypy/fixup.py", line 49, in visit_type_info
File "mypy/types.py", line 846, in accept
File "mypy/fixup.py", line 154, in visit_instance
File "mypy/fixup.py", line 269, in lookup_qualified_typeinfo
File "mypy/fixup.py", line 297, in lookup_qualified
File "mypy/fixup.py", line 306, in lookup_qualified_stnode
File "mypy/lookup.py", line 47, in lookup_fully_qualified
AssertionError: Cannot find component 'TupleType@4' for 'a.TupleType@4'
To Reproduce
Use this script to reproduce:
#!/bin/sh
mkdir -p mypy_crash
cat >mypy_crash/a.py <<EOFfrom collections import namedtupledef crash(fields): TupleType = namedtuple("TupleType", fields) class InheritFromTuple(TupleType): passEOF
cat >mypy_crash/b.py <<EOFfrom a import AEOF
rm -rf .mypy_cache
echo"First run, should be ok"
mypy mypy_crash/
echoecho"Second run, with cache disabled, should be ok"
mypy --no-incremental mypy_crash/
echoecho"Third run, with cache enabled, this should crash"
mypy mypy_crash/
mypy does not crash if any of the following are removed:
File b.py
Import error in file b.py, e.g. by replacing from a import A by from a import crash (or any other valid name)
Definition of class InheritFromTuple in a.py
Argument fields in definition of namedtuple, e.g. by TupleType = namedtuple("TupleType", 'a b c')
Your Environment
Mypy version used: 0.910
Mypy command-line flags: (none, see script)
Mypy configuration options from mypy.ini (and other config files): (none, can reproduce without mypy.ini)
Python version used: 3.7.9
Operating system and version: Ubuntu 18.04.6 LTS (bionic)
The text was updated successfully, but these errors were encountered:
Crash Report
mypy crashes when inheriting from a locally defined namedtuple, when all of the following is true:
attr-defined
error--no-incremental
)Seems to be related to #10913, but produces a traceback similar to the closed #7281.
Traceback
To Reproduce
Use this script to reproduce:
mypy does not crash if any of the following are removed:
b.py
b.py
, e.g. by replacingfrom a import A
byfrom a import crash
(or any other valid name)class InheritFromTuple
ina.py
fields
in definition of namedtuple, e.g. byTupleType = namedtuple("TupleType", 'a b c')
Your Environment
mypy.ini
(and other config files): (none, can reproduce without mypy.ini)The text was updated successfully, but these errors were encountered: