pantsbuild / pants

The Pants Build System
https://www.pantsbuild.org
Apache License 2.0
3.29k stars 631 forks source link

Internal error in `mypy` during `pants check` #18512

Open kaos opened 1 year ago

kaos commented 1 year ago

Describe the bug Once every third blue moon I observe mypy crashing with "internal error" for perfectly valid sources.

Pants version 2.16.0a0 (but have observed this since ~2.14 or before)

OS Mac

Additional info

# from mypy sandbox
./__run.sh
src/.../x.py:205: 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: 0.961
Traceback (most recent call last):
  File "mypy/checker.py", line 431, in accept
  File "mypy/nodes.py", line 747, in accept
  File "mypy/checker.py", line 782, in visit_func_def
  File "mypy/checker.py", line 793, in _visit_func_def
  File "mypy/checker.py", line 1500, in check_method_override
  File "mypy/checker.py", line 1528, in check_method_or_accessor_override_for_base
  File "mypy/checker.py", line 1614, in check_method_override_for_base_with_name
  File "mypy/checker.py", line 1776, in check_override
  File "mypy/messages.py", line 845, in signature_incompatible_with_supertype
  File "mypy/messages.py", line 867, in pretty_callable_or_overload
  File "mypy/messages.py", line 1979, in pretty_callable
AttributeError: attribute 'arguments' of 'FuncDef' undefined
src/.../x.py:205: : note: use --pdb to drop into pdb

Reading the comment in __mypyrunner.sh my suspicion falls on a corrupt mypy cache, as this issue goes away every time I wipe the pants caches and there are some trickery going on with it.

The cache.db sqlite file seems to not be corrupt though. (as in it is usable, not sure about the state of the contents in the DB itself)

Minimal work-around To preserve as much cache as possible, this wipes the mypy caches only:

rm -rf ~/.cache/pants/named_caches/mypy_cache/
thejcannon commented 1 year ago

Mypy seemingly is a consistent source of headaches...

kaos commented 1 year ago

Related issue (same root cause?)

Partition #1 - resolve-a, ['CPython==3.8.*']:
Traceback (most recent call last):
  File "/tmp/pants-sandbox-7SLpYn/.cache/pex_root/venvs/a02fcb9ba528002810305b[79](https://github.com/.../actions/runs/x/jobs/x?pr=x#step:5:80)x/ddab[80](https://github.com/.../actions/runs/x/jobs/x?pr=x#step:5:81)x/pex", line 284, in <module>
    sys.exit(func())
  File "/github/home/.cache/pants/named_caches/pex_root/venvs/s/1224b575/venv/lib/python3.8/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 154, in build
  File "mypy/build.py", line 213, in _build
  File "mypy/build.py", line 608, in __init__
  File "mypy/build.py", line 1142, in create_metastore
  File "mypy/metastore.py", line 175, in __init__
  File "mypy/metastore.py", line 156, in connect_db
sqlite3.DatabaseError: database disk image is malformed

Partition #2 - resolve-b, ['CPython==3.8.*']:
Success: no issues found in 7[95](https://github.com/.../actions/runs/x/jobs/x?pr=x#step:5:96) source files
thejcannon commented 1 year ago

No, thats different. I split the issue, and will attempt to tackle it