Repository navigation
Closed
Labels
crashpriority-0-hightopic-incrementaltopic-paramspecPEP 612, ParamSpec, ConcatenatePEP 612, ParamSpec, Concatenate
Description
Crash Report
Recently we (different team members) are now and then running into a mypy crash which can only be resolved by deleting .mypy_cache. We have no idea yet how to reproduce it - it likely is triggered after changing branches. But we could so far not figure out the problematic code path.
Traceback
Traceback (most recent call last):
File "/Users/abc/venv/weplan3.10/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/Users/abc/venv/weplan3.10/lib/python3.10/site-packages/mypy/__main__.py", line 12, in console_entry
main(None, sys.stdout, sys.stderr)
File "mypy/main.py", line 96, in main
File "mypy/main.py", line 173, in run_build
File "mypy/build.py", line 180, in build
File "mypy/build.py", line 256, in _build
File "mypy/build.py", line 2727, in dispatch
File "mypy/build.py", line 3071, in process_graph
File "mypy/build.py", line 3189, in process_stale_scc
File "mypy/build.py", line 2311, in write_cache
File "mypy/build.py", line 1488, in write_cache
File "mypy/nodes.py", line 344, in serialize
File "mypy/nodes.py", line 3364, in serialize
File "mypy/nodes.py", line 3301, in serialize
File "mypy/nodes.py", line 2827, in serialize
File "mypy/nodes.py", line 3364, in serialize
File "mypy/nodes.py", line 3301, in serialize
File "mypy/nodes.py", line 953, in serialize
File "mypy/types.py", line 1086, in serialize
File "mypy/types.py", line 1482, in serialize
File "mypy/types.py", line 611, in serialize
File "mypy/types.py", line 1079, in serialize
File "mypy/nodes.py", line 2676, in fullname
AttributeError: attribute '_fullname' of 'TypeInfo' undefined
To Reproduce
Well yeah, seems to be some constellation of stars and cache state.
Your Environment
- Mypy version used: mypy 0.941 (I think it happened with 0.931 as well)
- Mypy command-line flags: Just a bunch of packages passed with
-pand a config file. - Mypy configuration options from
mypy.ini(and other config files):
[mypy]
ignore_missing_imports = True
color_output = True
pretty = True
show_error_codes = True
check_untyped_defs = True
warn_unreachable = True
error_summary = True
# https://github.com/python/mypy/issues/9091
no_implicit_optional = True
# pip install sqlalchemy2-stubs
plugins = sqlalchemy.ext.mypy.plugin
- Python version used: 3.10
- Operating system and version: macOS Big Sur
Reacted by Felix Bargfeldt, Evin Callahan, Panagiotis Kanavos, Lukas Reineke, Cory Dolphin, ymorgenstern, Adam Johnson and Neil Girdhar
Metadata
Metadata
Assignees
Labels
crashpriority-0-hightopic-incrementaltopic-paramspecPEP 612, ParamSpec, ConcatenatePEP 612, ParamSpec, Concatenate
Activity
pkanavos commentedon Apr 6, 2022
I encountered the same problem just yesterday, after installing
mypy,pandas-stubsandsqlalchemy[mypy]. Deleting the cache workedronakts commentedon Apr 6, 2022
We also encountered this issue a few times, but not able to reproduce it. For us it always fails when writing a cache for
ddtrace/internal/atexit.pyand we also use mypy cache generated from other branches.Exception:
We saw this issue on 0.940, 0.941, and 0.942. If we run mypy without cache we don't face this issue.
Dreamsorcerer commentedon Apr 9, 2022
I encountered this after upgrading sqlalchemy and sqlalchemy2-stubs. So, maybe changes after upgrading a package can cause this crash.
AlexWaygood commentedon Apr 9, 2022
I'm raising the priority to "high" given that this appears to be causing problems for lots of users
ethanzh commentedon May 23, 2022
My team has also been experiencing this issue. We also noticed it has something to do with the cache + switching branches but I haven't been able to get a reproducible set of steps. We're also using sqlalchemy stubs as @Dreamsorcerer mentioned so that very well might be part of it.
AlexWaygood commentedon May 23, 2022
Unfortunately it is quite difficult to debug an issue without a reproducer (even a "maximal" reproducer is better than no reproducer at all). If anybody who's experienced this issue is able to put in time trying to get a reproducer, that would be very helpful.
Dreamsorcerer commentedon May 23, 2022
I've not experienced the problem for many releases, so this is basically resolved to me. Maybe it might be caused by a specific change in sqlachemy2-stubs and upgrading from a specific version (after running mypy on your code) might trigger it..
ethanzh commentedon May 23, 2022
I've bumped our Mypy version from 0.942 to 0.950 and I've also replaced types-sqlalchemy for sqlalchemy-stubs. After trying various situations to trigger this crash I haven't been able to. I'll loop back to this thread after a few days of use to report if the issue's been solved for us.
pranavrajpal commentedon May 23, 2022
Is everyone here using the sqlalchemy mypy plugin? If so, there's a decent chance that's what is causing the crash, so it might be worth disabling it for a few days and seeing if that stops the crashes.
Looking at the error message in the traceback, the thing that seems weird is that I can't find any code paths where
_fullnamewouldn't be defined on aTypeInfo. We define it in both the constructor and when deserializing, and there isn't any place we delete_fullnamein mypy.Some other things I've noticed that may or may not be related:
_fullnamemakes me suspicious that it's related, but it's changing the_fullnameof aVar, not aTypeInfo, so it might be unrelated.There's a chance that the
TypeInfothat we're trying to get the fullname of (at the bottom of the traceback) is the sameTypeInfothat we're serializing earlier (near the top of that traceback), which would probably cause problems if that were possible. TheVarbeing serialized in that traceback also might mean that this is related to the sqlalchemy PR I mentioned, but I don't really have an explanation for why either of those things would cause the_fullnameattribute to disappear during deserialization.One other strange thing I noticed is that the line we're crashing on in the
ParamSpecTypeserialization is this:mypy/mypy/types.py
Line 611 in 4e18c78
The docstring says the upper bound is always just
object, which seems to imply_fullnameis missing on theTypeInfoforobject, and I don't really understand how that would happen.mavidser commentedon May 23, 2022
Posting some of my research here - I'm reproduced this with and without the
sqlalchemy.ext.mypy.plugin. In my case, the issue if because I haveflask-limiterinstalled, which depends on the packagelimits.I was getting the same error as OP initially, before installing mypy with
pip -e.Digging deeper, lines like these seem to be the problem, with the
PParamSpec is causing mypy to crash. No idea what the exact issue is.Steps to reproduce (at least for me):
mypy --install-types .which was installing types-Deprecated and types-setuptools due to thelimitspackage.types-Deprecatedandtypes-setuptools, and removing.mypy_cachefolder made the crash reproducible every time.Might be related to #8645?
aberres commentedon May 24, 2022
@pranavrajpal As the crash persists until the cache is cleaned - is there anything we could debug while being in the broken state?
aberres commentedon May 24, 2022
Hmm, now that I read about
ParamSpecabove - I started to add ParamSpecs to our code base some time ago. Cannot tell for sure, but I think the crashes might have started at the same time.NeilGirdhar commentedon Jun 15, 2022
I'm running into the same problem after adding
ParamSpecto my codebase https://github.com/NeilGirdhar/tjax/.emmatyping commentedon Jul 10, 2022
Over in #13099 @copperfield42 was able to reduce things to a minimal reproducer:
ilevkivskyi commentedon Aug 23, 2022
Note this may be fixed by #13381 (you can check when the PR is merged)
A5rocks commentedon Oct 5, 2022
I tried reproducing and it does seem to work now on mypy 0.982. Are people still able to reproduce this?