Skip to content

Internal error when enabling reports #9433

@quulah

Description

@quulah

🐛 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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy