Skip to content

Fix crash when mypy reports no errors - #599

Open
Ishaan400 wants to merge 1 commit into
boxed:mainfrom
Ishaan400:fix-mypy-clean-run-json
Open

Ishaan400 wants to merge 1 commit into
boxed:mainfrom
Ishaan400:fix-mypy-clean-run-json

Conversation

@Ishaan400

Copy link
Copy Markdown

Fixes #598

mypy prints a lone newline on a clean run. run_type_checker passed the resulting empty line to json.loads, which raised "type check command did not return JSON". Blank lines are now skipped for mypy output.

Tests added in tests/test_type_checking.py (mypy invocation faked via subprocess.run):

  • clean run ("\n", exit 0) returns no errors (fails without the fix)
  • error output (two JSON lines, exit 1) is still parsed
  • fatal output (non-JSON, exit 2) still raises "did not return JSON"

Verified: pytest tests --ignore=tests/e2e 446 passed, 3 skipped; ruff check and ruff format --check clean; mypy src/mutmut/type_checking.py clean; a real mutmut run with the mypy type_check_command above now completes. tests/e2e was not run.

mypy prints a lone newline on a clean run. Parsing it line by line
passed an empty string to json.loads and raised "type check command
did not return JSON". Skip blank lines instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

type_check_command with mypy crashes with "type check command did not return JSON" when mypy finds no errors

1 participant