Skip to content

dmypy: INTERNAL ERROR: AssertionError in _add_error_info() #15486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
asqui opened this issue Jun 21, 2023 · 5 comments · Fixed by #18906
Closed

dmypy: INTERNAL ERROR: AssertionError in _add_error_info() #15486

asqui opened this issue Jun 21, 2023 · 5 comments · Fixed by #18906

Comments

@asqui
Copy link

asqui commented Jun 21, 2023

Crash Report

Just trying out dmypy for the first time and I encountered the below issue when trying to check an individual file after starting the daemon and checking the entire source repository.

Repro / Traceback

$ time dmypy run -- src/ ; time dmypy run -- src/scratch.py ; time dmypy run -- src/scratch.py
Daemon started
src/scratch.py:16: error: "C" has no attribute "foo"  [attr-defined]
Found 1 error in 1 file (checked 2952 source files)

real    2m1.636s
user    0m0.264s
sys     0m0.140s
src/scratch.py:16: error: "C" has no attribute "foo"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)

real    0m54.281s
user    0m0.174s
sys     0m0.098s
-------------------------------------------------------------------------------
stderr:
src/scratch.py:16: 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.3.0
src/scratch.py:16: 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.3.0
Daemon crashed!
Traceback (most recent call last):
  File "mypy/dmypy_server.py", line 230, in serve
  File "mypy/dmypy_server.py", line 277, in run_command
  File "mypy/dmypy_server.py", line 345, in cmd_run
  File "mypy/dmypy_server.py", line 414, in check
  File "mypy/dmypy_server.py", line 663, in fine_grained_increment_follow_imports
  File "mypy/server/update.py", line 288, in update
  File "mypy/server/update.py", line 881, in propagate_changes_using_dependencies
  File "mypy/server/update.py", line 1024, in reprocess_nodes
  File "mypy/checker.py", line 526, in check_second_pass
  File "mypy/checker.py", line 531, in check_partial
  File "mypy/checker.py", line 545, in check_top_level
  File "mypy/nodes.py", line 1228, in accept
  File "mypy/checker.py", line 4130, in visit_expression_stmt
  File "mypy/checkexpr.py", line 4892, in accept
  File "mypy/errors.py", line 1177, in report_internal_error
  File "mypy/checkexpr.py", line 4882, in accept
  File "mypy/checkexpr.py", line 429, in visit_call_expr
  File "mypy/checkexpr.py", line 515, in visit_call_expr_inner
  File "mypy/checkexpr.py", line 4892, in accept
  File "mypy/errors.py", line 1177, in report_internal_error
  File "mypy/checkexpr.py", line 4890, in accept
  File "mypy/nodes.py", line 1813, in accept
  File "mypy/checkexpr.py", line 2771, in visit_member_expr
  File "mypy/checkexpr.py", line 2792, in analyze_ordinary_member_access
  File "mypy/checkmember.py", line 201, in analyze_member_access
  File "mypy/checkmember.py", line 220, in _analyze_member_access
  File "mypy/checkmember.py", line 343, in analyze_instance_member_access
  File "mypy/checkmember.py", line 601, in analyze_member_var_access
  File "mypy/checkmember.py", line 274, in report_missing_attribute
  File "mypy/messages.py", line 485, in has_no_attr
  File "mypy/messages.py", line 272, in fail
  File "mypy/messages.py", line 247, in report
  File "mypy/errors.py", line 440, in report
  File "mypy/errors.py", line 502, in add_error_info
  File "mypy/errors.py", line 443, in _add_error_info
AssertionError


real    0m0.863s
user    0m0.158s
sys     0m0.107s

Observations

  1. Checking our entire source repo of 2,952 files takes ~2 minutes, and then re-checking a single file (which has not been modified, was already checked, and had its errors reported in the first run) takes nearly a minute. This seems very surprising. (I'd expect this to be near instant, given the file has not been modified since the initial check?)
  2. This crash only seems to happen if scratch.py has an error it it. If I 'fix' the error in that file, the crash does not occur, though the curiosity of re-checking the individual file taking nearly a minute remains.

Environment

  • Mypy version used: 1.3.0
  • Mypy configuration options from mypy.ini (and other config files): Can repro with empty mypy.ini
  • Python version used: 3.11.3
  • Operating system and version: Red Hat Enterprise Linux release 8.3 (Ootpa)
@asqui asqui added the crash label Jun 21, 2023
@ikonst
Copy link
Contributor

ikonst commented Jun 22, 2023

Did you mean to also provide the contents of src/scratch.py here?

@asqui
Copy link
Author

asqui commented Jul 10, 2023

src/scratch.py looks something like this:

from foo import bar  # Import from our internal codebase


class A:
    pass


A().foo()

(Unfortunately I can't share the codebase that this is interacting with.)

@gerner
Copy link

gerner commented Jan 14, 2025

I'm seeing a very similar stacktrace after upgrading to the latest mypy 1.14.1:

src/stellarpunk/orders/core.py:686: 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.14.1
Daemon crashed!
Traceback (most recent call last):
  File "mypy/dmypy_server.py", line 236, in serve
  File "mypy/dmypy_server.py", line 285, in run_command
  File "mypy/dmypy_server.py", line 353, in cmd_run
  File "mypy/dmypy_server.py", line 432, in check
  File "mypy/dmypy_server.py", line 700, in fine_grained_increment_follow_imports
  File "mypy/server/update.py", line 285, in update
  File "mypy/server/update.py", line 881, in propagate_changes_using_dependencies
  File "mypy/server/update.py", line 1025, in reprocess_nodes
  File "mypy/checker.py", line 535, in check_second_pass
  File "mypy/checker.py", line 547, in check_partial
  File "mypy/checker.py", line 594, in accept
  File "mypy/errors.py", line 1288, in report_internal_error
  File "mypy/checker.py", line 592, in accept
  File "mypy/nodes.py", line 827, in accept
  File "mypy/checker.py", line 1046, in visit_func_def
  File "mypy/checker.py", line 1050, in _visit_func_def
  File "mypy/checker.py", line 1084, in check_func_item
  File "mypy/checker.py", line 1360, in check_func_def
  File "mypy/checker.py", line 594, in accept
  File "mypy/errors.py", line 1288, in report_internal_error
  File "mypy/checker.py", line 592, in accept
  File "mypy/nodes.py", line 1277, in accept
  File "mypy/checker.py", line 2952, in visit_block
  File "mypy/checker.py", line 594, in accept
  File "mypy/errors.py", line 1288, in report_internal_error
  File "mypy/checker.py", line 592, in accept
  File "mypy/nodes.py", line 1473, in accept
  File "mypy/checker.py", line 4613, in visit_return_stmt
  File "mypy/checker.py", line 4649, in check_return_stmt
  File "mypy/checkexpr.py", line 5892, in accept
  File "mypy/errors.py", line 1288, in report_internal_error
  File "mypy/checkexpr.py", line 5890, in accept
  File "mypy/nodes.py", line 1908, in accept
  File "mypy/checkexpr.py", line 3283, in visit_member_expr
  File "mypy/checkexpr.py", line 3308, in analyze_ordinary_member_access
  File "mypy/checkmember.py", line 206, in analyze_member_access
  File "mypy/checkmember.py", line 225, in _analyze_member_access
  File "mypy/checkmember.py", line 356, in analyze_instance_member_access
  File "mypy/checkmember.py", line 618, in analyze_member_var_access
  File "mypy/checkmember.py", line 279, in report_missing_attribute
  File "mypy/messages.py", line 512, in has_no_attr
  File "mypy/messages.py", line 289, in fail
  File "mypy/messages.py", line 264, in report
  File "mypy/errors.py", line 463, in report
  File "mypy/errors.py", line 529, in add_error_info
  File "mypy/errors.py", line 466, in _add_error_info
AssertionError

I'm running dmypy run, so it's running on the whole code base. It seems like it happens after I've run dmypy twice. If I run it a third time, it crashes. I can restart dmypy (via dmypy run), it works fine once, it works fine if I run dmypy run a second time (very quickly as I would expect it's cached a ton of stuff), but then crashes on the third run.

Here's the code base: https://github.com/gerner/stellarpunk/tree/668ea4996ea17bb1da64ea80192c825074f74435
although, I made some edits in my workspace on top of that. I believe if you make any errors mypy will catch you can repro the problem.

Sorry I don't have a minimal repro case, but I'm happy to help out. I'm just not familiar with MyPy internals enough to quickly whip up a minimal repro.

@hauntsaninja
Copy link
Collaborator

Looks like this is same crash as in #18396
If you happen to have time, and if you're only seeing this since 1.14.1, would be interesting to bisect!

@gerner
Copy link

gerner commented Jan 14, 2025

1.0.0 is incredibly slow (like a minute or more to run from a fresh start on this code base). now I remember why I started using dmypy in the first place. no crash, but a ton of syntax errors that aren't picked up by 1.14.1 (must be newer python features I'm using). so this must be older than the version I was using before my most recent upgrade

1.10.0 is faster (about as fast as 1.14.1). I see PEP 695 generics not supportd warning which is probably the feature I'm using. No crash.

1.12.0 All those spurious syntax errors are gone. No crash.

1.13.0 no crash

1.14.0 crash on 3rd run of dmypy run

According to pypi it seems there's no versions between 1.13.0 and 1.14.0

I'll post this to #18396 too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants