Skip to content
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

Internal error when enabling reports #9433

Closed
quulah opened this issue Sep 10, 2020 · 1 comment
Closed

Internal error when enabling reports #9433

quulah opened this issue Sep 10, 2020 · 1 comment
Labels

Comments

@quulah
Copy link

quulah commented Sep 10, 2020

🐛 Bug Report

Mypy throws an internal error when running with a specific file, options and generating a coverage report.

I tried a few versions and the master, but all throw the same error.

It does however generate the report.

To Reproduce

These come from an actual project, but I managed to figure out the smallest possible reproducible example:

.
├── common
│   ├── __init__.py
│   └── encoder.py
└── empty.py

1 directory, 3 files

__init__.py:

from common import encoder

encoder.py:

import simplejson as json

class MyJSONEncoder(json.JSONEncoder):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)  # type: ignore

empty.py is empty.

Then run mypy with either --txt-report or --cobertura-xml-report and the --disallow-untyped-calls and --check-untyped-defs flags.

Expected Behavior

Report should be generated without an error.

Actual Behavior

./common/encoder.py: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.782
Traceback (most recent call last):
  File "<snip>/python/3.8.0/bin/mypy", line 10, in <module>
    sys.exit(console_entry())
  File "mypy/build.py", line 1919, in wrap_context
  File "mypy/build.py", line 2147, in finish_passes
  File "mypy/build.py", line 801, in report_file
  File "mypy/report.py", line 83, in file
  File "mypy/report.py", line 476, in on_file
  File "mypy/nodes.py", line 294, in accept
  File "mypy/stats.py", line 89, in visit_mypy_file
  File "mypy/traverser.py", line 35, in visit_mypy_file
  File "mypy/nodes.py", line 939, in accept
  File "mypy/stats.py", line 158, in visit_class_def
  File "mypy/nodes.py", line 1004, in accept
  File "mypy/traverser.py", line 39, in visit_block
  File "mypy/nodes.py", line 676, in accept
  File "mypy/stats.py", line 139, in visit_func_def
  File "mypy/traverser.py", line 54, in visit_func_def
  File "mypy/traverser.py", line 51, in visit_func
  File "mypy/nodes.py", line 1004, in accept
  File "mypy/traverser.py", line 39, in visit_block
  File "mypy/nodes.py", line 1019, in accept
  File "mypy/stats.py", line 192, in visit_expression_stmt
  File "mypy/traverser.py", line 82, in visit_expression_stmt
  File "mypy/nodes.py", line 1544, in accept
  File "mypy/stats.py", line 225, in visit_call_expr
  File "mypy/stats.py", line 234, in record_call_target_precision
  File "mypy/stats.py", line 248, in record_callable_target_precision
  File "mypy/argmap.py", line 101, in map_formals_to_actuals
  File "mypy/argmap.py", line 39, in map_actuals_to_formals
  File "mypy/stats.py", line 253, in <lambda>
KeyError: <mypy.nodes.NameExpr object at 0x11286f430>
./common/encoder.py: : note: use --pdb to drop into pdb
Generated TXT report (via XSLT): <snip>/report/index.txt

Your Environment

  • Mypy version used: 0.770, 0.782 and master
  • Mypy command-line flags: --txt-report report --show-traceback --disallow-untyped-calls --check-untyped-defs
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.8.0
  • Operating system and version:
@quulah quulah added the bug mypy got something wrong label Sep 10, 2020
@AlexWaygood AlexWaygood added crash and removed bug mypy got something wrong labels Mar 26, 2022
@Michael0x2a
Copy link
Collaborator

This no longer reproduces on master. According to git-bisect, this bug was fixed by #9510.

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

No branches or pull requests

3 participants