Skip to content

dmypy crashes every 2nd run when trying to update unlreated and unchanged numpy.compat #11009

Closed
@aberres

Description

@aberres

Crash Report

When dmypy is run the second time it crashes when trying to update its internal state. No code has been changed between runs.

Traceback

Traceback (most recent call last):
  File "/Users/berres/venv/xyx/lib/python3.9/site-packages/mypy/dmypy_server.py", line 229, in serve
    resp = self.run_command(command, data)
  File "/Users/berres/venv/xyx/lib/python3.9/site-packages/mypy/dmypy_server.py", line 272, in run_command
    return method(self, **data)
  File "/Users/berres/venv/xyx/lib/python3.9/site-packages/mypy/dmypy_server.py", line 331, in cmd_run
    return self.check(sources, is_tty, terminal_width)
  File "/Users/berres/venv/xyx/lib/python3.9/site-packages/mypy/dmypy_server.py", line 393, in check
    messages = self.fine_grained_increment_follow_imports(sources)
  File "/Users/berres/venv/xyx/lib/python3.9/site-packages/mypy/dmypy_server.py", line 637, in fine_grained_increment_follow_imports
    messages = fine_grained_manager.update([], to_delete)
  File "/Users/berres/venv/xyx/lib/python3.9/site-packages/mypy/server/update.py", line 272, in update
    messages = self.manager.errors.new_messages()
  File "/Users/berres/venv/xyx/lib/python3.9/site-packages/mypy/errors.py", line 587, in new_messages
    msgs.extend(self.file_messages(path))
  File "/Users/berres/venv/xyx/lib/python3.9/site-packages/mypy/errors.py", line 575, in file_messages
    return self.format_messages(self.error_info_map[path], source_lines)
  File "/Users/berres/venv/xyx/lib/python3.9/site-packages/mypy/errors.py", line 548, in format_messages
    source_line = source_lines[line - 1]
IndexError: list index out of range

To Reproduce

I do not yet have a stand alone repo, but collected some logs what happens.

The problematic call is simply

dmypy run -- --config-file mypy.ini -p flask_rest_json_api

In the config we set pretty=True which causes the error to show up.

When the crash happens, dmypy tries to update the error messages for the system wide installed numpy. The detected error is absolutely bogus. The file python3.9/site-packages/numpy/core/overrides.py has only 227 lines while multiple errors are detected between lines 2936 and 3363 (see log below). Hence the crash.

The thing is: We are not at all interested in these numpy errors. Numpy should not be a package errors are reported for. And the first run actually does not report any numpy errors.

The verbose logs from the second run. As we see numpy.compat is considered to be deleted. The integrity_problem log has beed added by myself.

LOG:  fine-grained increment: find_changed: 0.004s
changed []
new_files []
to_delete: [('email.mime', '/Users/berres/venv/xyz/lib/python3.9/site-packages/mypy/typeshed/stdlib/email/mime/__init__.pyi'), ('html', '/Users/berres/venv/xyz/lib/python3.9/site-packages/mypy/typeshed/stdlib/html/__init__.pyi'), ('numpy.compat', '/Users/berres/venv/xyz/lib/python3.9/site-packages/numpy/compat/__init__.py'), ('numpy.compat.py3k', '/Users/berres/venv/xyz/lib/python3.9/site-packages/numpy/compat/py3k.py')] <class 'list'>
LOG:  fine-grained: ==== update 'email.mime', 'html', 'numpy.compat', 'numpy.compat.py3k' ====
LOG:  fine-grained: previous targets with errors: ['flask_rest_json_api.resource.ResourceDetail.patch', 'flask_rest_json_api.resource.ResourceList.get']
LOG:  fine-grained: --- update single 'email.mime' ---
LOG:  fine-grained: delete module 'email.mime'
LOG:  fine-grained: triggered: ['<email.mime>', '<email.mime[wildcard]>']
LOG:  fine-grained: triggered: []
LOG:  fine-grained: update once: email.mime in 0.001s - 3 left
LOG:  fine-grained: --- update single 'html' ---
LOG:  fine-grained: delete module 'html'
LOG:  fine-grained: triggered: ['<html.AnyStr>', '<html.escape>', '<html.unescape>', '<html>', '<html[wildcard]>']
LOG:  fine-grained: triggered: []
LOG:  fine-grained: update once: html in 0.000s - 2 left
LOG:  fine-grained: --- update single 'numpy.compat' ---
LOG:  fine-grained: delete module 'numpy.compat'
LOG:  fine-grained: triggered: ['<numpy.compat.Path>', '<numpy.compat._inspect>', '<numpy.compat.asbytes>', '<numpy.compat.asbytes_nested>', '<numpy.compat.asstr>', '<numpy.compat.asunicode>', '<numpy.compat.asunicode_nested>', '<numpy.compat.basestring>', '<numpy.compat.bytes>', '<numpy.compat.contextlib_nullcontext>', '<numpy.compat.formatargspec>', '<numpy.compat.getargspec>', '<numpy.compat.getexception>', '<numpy.compat.integer_types>', '<numpy.compat.is_pathlib_path>', '<numpy.compat.isfileobj>', '<numpy.compat.long>', '<numpy.compat.npy_load_module>', '<numpy.compat.open_latin1>', '<numpy.compat.os_PathLike>', '<numpy.compat.os_fspath>', '<numpy.compat.pickle>', '<numpy.compat.py3k>', '<numpy.compat.sixu>', '<numpy.compat.strchar>', '<numpy.compat.unicode>', '<numpy.compat>', '<numpy.compat[wildcard]>']
LOG:  fine-grained: process: numpy.compat
LOG:  fine-grained: Can't find matching target for numpy.compat (stale dependency?)
LOG:  fine-grained: process: numpy.core.overrides
LOG:  fine-grained: triggered: []
LOG:  fine-grained: update once: numpy.compat in 2.971s - 1 left
LOG:  fine-grained: --- update single 'numpy.compat.py3k' ---
LOG:  fine-grained: delete module 'numpy.compat.py3k'
LOG:  fine-grained: triggered: ['<numpy.compat.py3k.Path>', '<numpy.compat.py3k.abc>', '<numpy.compat.py3k.abc_ABC>', '<numpy.compat.py3k.asbytes>', '<numpy.compat.py3k.asbytes_nested>', '<numpy.compat.py3k.asstr>', '<numpy.compat.py3k.asunicode>', '<numpy.compat.py3k.asunicode_nested>', '<numpy.compat.py3k.basestring>', '<numpy.compat.py3k.bytes>', '<numpy.compat.py3k.contextlib_nullcontext>', '<numpy.compat.py3k.getexception>', '<numpy.compat.py3k.integer_types>', '<numpy.compat.py3k.io>', '<numpy.compat.py3k.is_pathlib_path>', '<numpy.compat.py3k.isfileobj>', '<numpy.compat.py3k.long>', '<numpy.compat.py3k.npy_load_module>', '<numpy.compat.py3k.open_latin1>', '<numpy.compat.py3k.os>', '<numpy.compat.py3k.os_PathLike>', '<numpy.compat.py3k.os_fspath>', '<numpy.compat.py3k.pickle>', '<numpy.compat.py3k.sixu>', '<numpy.compat.py3k.strchar>', '<numpy.compat.py3k.sys>', '<numpy.compat.py3k.unicode>', '<numpy.compat.py3k>', '<numpy.compat.py3k[wildcard]>']
LOG:  fine-grained: process: numpy.compat.py3k.asbytes_nested
LOG:  fine-grained: Can't find matching target for numpy.compat.py3k.asbytes_nested (stale dependency?)
LOG:  fine-grained: process: numpy.compat.py3k.contextlib_nullcontext
LOG:  fine-grained: Can't find matching target for numpy.compat.py3k.contextlib_nullcontext (stale dependency?)
LOG:  fine-grained: process: numpy.compat
LOG:  fine-grained: Can't find matching target for numpy.compat (stale dependency?)
LOG:  fine-grained: process: numpy.compat.py3k
LOG:  fine-grained: Can't find matching target for numpy.compat.py3k (stale dependency?)
LOG:  fine-grained: process: numpy.compat.py3k.asunicode_nested
LOG:  fine-grained: Can't find matching target for numpy.compat.py3k.asunicode_nested (stale dependency?)
LOG:  fine-grained: triggered: []
LOG:  fine-grained: update once: numpy.compat.py3k in 2.855s - 0 left
LOG:  fine-grained: process target with error: flask_rest_json_api.resource.ResourceList.get
LOG:  fine-grained: process target with error: flask_rest_json_api.resource.ResourceDetail.patch
LOG:  fine-grained: triggered: []
prev errors {'flask_rest_json_api.resource.ResourceList.get', 'flask_rest_json_api.resource.ResourceDetail.patch'}
errors {'/Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py': [<mypy.errors.ErrorInfo object at 0x10b347820>, <mypy.errors.ErrorInfo object at 0x10b3477c0>, <mypy.errors.ErrorInfo object at 0x10b347910>, <mypy.errors.ErrorInfo object at 0x10b347940>, <mypy.errors.ErrorInfo object at 0x10b347970>, <mypy.errors.ErrorInfo object at 0x10b3478e0>, <mypy.errors.ErrorInfo object at 0x10b3479d0>, <mypy.errors.ErrorInfo object at 0x10b347a30>, <mypy.errors.ErrorInfo object at 0x10b347a00>, <mypy.errors.ErrorInfo object at 0x10b347a60>], '/Users/berres/Devel/mpptool/backend/flask-rest-json-api/flask_rest_json_api/resource.py': [<mypy.errors.ErrorInfo object at 0x109fe00a0>, <mypy.errors.ErrorInfo object at 0x108fcc820>]}
integrity_problem /Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py 227 2936 Class numpy.number has abstract attributes "__init__"
integrity_problem /Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py 227 2936 If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass
integrity_problem /Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py 227 3088 Class numpy.integer has abstract attributes "__init__"
integrity_problem /Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py 227 3088 If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass
integrity_problem /Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py 227 3244 Class numpy.inexact has abstract attributes "__init__"
integrity_problem /Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py 227 3244 If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass
integrity_problem /Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py 227 3344 Class numpy.flexible has abstract attributes "__init__"
integrity_problem /Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py 227 3344 If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass
integrity_problem /Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py 227 3363 Class numpy.character has abstract attributes "__init__"
integrity_problem /Users/berres/venv/xyx/lib/python3.9/site-packages/numpy/core/overrides.py 227 3363 If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass
LOG:  fine-grained increment: update: 5.955s

Your Environment

  • Mypy version used: 0.920+dev.7576f659d42ee271c78e69d7481b9d49517a49f6
  • 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
  • Python version used: 3.9
  • Operating system and version: MacOS

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions