Skip to content

JSONDecodeError when running MyPy #6156

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
salimfadhley opened this issue Jan 7, 2019 · 3 comments
Closed

JSONDecodeError when running MyPy #6156

salimfadhley opened this issue Jan 7, 2019 · 3 comments

Comments

@salimfadhley
Copy link

When I run the following command:

mypy ./src/main ./src/tests --junit-xml mypy.xml

I get the following error.

Traceback (most recent call last):
  File "/usr/local/bin/mypy", line 11, in <module>
    sys.exit(console_entry())
  File "/usr/local/lib/python3.7/site-packages/mypy/__main__.py", line 7, in console_entry
    main(None)
  File "/usr/local/lib/python3.7/site-packages/mypy/main.py", line 92, in main
    res = build.build(sources, options, None, flush_errors, fscache)
  File "/usr/local/lib/python3.7/site-packages/mypy/build.py", line 156, in build
    result = _build(sources, options, alt_lib_path, flush_errors, fscache)
  File "/usr/local/lib/python3.7/site-packages/mypy/build.py", line 206, in _build
    graph = dispatch(sources, manager)
  File "/usr/local/lib/python3.7/site-packages/mypy/build.py", line 2178, in dispatch
    graph = load_graph(sources, manager)
  File "/usr/local/lib/python3.7/site-packages/mypy/build.py", line 2336, in load_graph
    root_source=True)
  File "/usr/local/lib/python3.7/site-packages/mypy/build.py", line 1476, in __init__
    self.meta = find_cache_meta(self.id, path, manager)
  File "/usr/local/lib/python3.7/site-packages/mypy/build.py", line 862, in find_cache_meta
    log_error='Could not load cache for {}: '.format(id))
  File "/usr/local/lib/python3.7/site-packages/mypy/build.py", line 790, in _load_json_file
    result = json.loads(data)  # TODO: Errors
  File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 105 column 5 (char 5143)
@salimfadhley salimfadhley changed the title JSONDecoder Error when running MyPy JSONDecodeError when running MyPy Jan 7, 2019
@ilevkivskyi
Copy link
Member

I looks like you have broken cache. Have you tried rm -rf .mypy_cache?

Anyway, mypy shouldn't crash in this case, but show/log a reasonable error message. (There is even a TODO about this in the traceback.)

@salimfadhley
Copy link
Author

Is the .mypy_cache file always at the root of the project?

@ilevkivskyi
Copy link
Member

IIRC by default mypy stores it in current working directory from where mypy is run (but can be overridden by --cache-dir).

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

No branches or pull requests

2 participants