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

Mypy crashes when trying to ignore errors #11225

Closed
robbrit opened this issue Sep 29, 2021 · 2 comments
Closed

Mypy crashes when trying to ignore errors #11225

robbrit opened this issue Sep 29, 2021 · 2 comments
Labels
bug mypy got something wrong

Comments

@robbrit
Copy link

robbrit commented Sep 29, 2021

Bug Report

When attempting to set ignore_errors in mypy.ini, mypy blows up with a stack trace:

Traceback (most recent call last):
  File "/usr/local/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
  File "/usr/local/lib/python3.9/site-packages/mypy/__main__.py", line 11, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "mypy/main.py", line 87, in main
  File "mypy/main.py", line 165, in run_build
  File "mypy/build.py", line 179, in build
  File "mypy/build.py", line 254, in _build
  File "mypy/build.py", line 2697, in dispatch
  File "mypy/build.py", line 3021, in process_graph
  File "mypy/build.py", line 3138, in process_stale_scc
  File "mypy/build.py", line 2288, in write_cache
  File "mypy/build.py", line 1476, in write_cache
  File "mypy/build.py", line 1428, in json_dumps
  File "/usr/local/lib/python3.9/json/__init__.py", line 234, in dumps
    return cls(
  File "/usr/local/lib/python3.9/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python3.9/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/lib/python3.9/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type AnyType is not JSON serializable

This is with the latest mypy==0.910.

To Reproduce

Our original mypy.ini file looked like this:

[mypy]
plugins =
    mypy_django_plugin.main
mypy_path = ../shared/etc/mypy_stubs

[mypy-*.migrations.*]
ignore_errors = True

[mypy.plugins.django-stubs]
django_settings_module = community.settings

That worked great, but adding a new section caused the crash:

[mypy]
plugins =
    mypy_django_plugin.main
mypy_path = ../shared/etc/mypy_stubs

[mypy-*.migrations.*]
ignore_errors = True

; Disable mypy for protobuf services due to breaking changes in mypy-protobuf.
[mypy-shared.services.*]
ignore_errors = True

[mypy.plugins.django-stubs]
django_settings_module = community.settings

The shared.services module contains a number of autogenerated protobuf files.

Expected Behavior

It would not crash, or it would at least tell me what I could fix to make it not blow up.

Your Environment

  • Mypy version used: 0.910
  • Mypy command-line flags: --ignore-missing-imports
  • Mypy configuration options from mypy.ini (and other config files): written above
  • Python version used: 3.9.7
  • Operating system and version: Docker hub's python:3.9.7 image.
@robbrit robbrit added the bug mypy got something wrong label Sep 29, 2021
@sobolevn
Copy link
Member

@robbrit Thanks for the report! I've seen several other issues like this from our users in typeddjango/django-stubs#700

I think, that this needs to be fixed on our side, not here.

@robbrit
Copy link
Author

robbrit commented Oct 12, 2021

Cool, closing this one out as a duplicate.

@robbrit robbrit closed this as completed Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants