Skip to content

fix(type-checking): raise when the type checker fails to run - #669

Open
agustin18 wants to merge 1 commit into
boxed:mainfrom
agustin18:fix/type-check-exit-status
Open

agustin18 wants to merge 1 commit into
boxed:mainfrom
agustin18:fix/type-check-exit-status

Conversation

@agustin18

Copy link
Copy Markdown
Contributor

run_type_checker() ignored the exit status of the type check command. A mypy
run that fails before printing a report, for example with an unknown flag or a
plugin import error, exits with status 2 and an empty stdout. That was parsed as
an empty report, so mutmut continued as if there were no type errors.

Raise when the command exits with a status other than 0 or 1, and when it exits
with 1 but prints no report. Status 1 with a note-only report still returns an
empty list, because mypy uses that for notes such as annotation-unchecked.

Fixes #667.

Testing:

  • Added four unit tests and updated the existing fatal-output test.
  • uv run pytest: 666 passed, 6 skipped.
  • uv run pre-commit run --files src/mutmut/type_checking.py tests/test_type_checking.py: passes.
  • E2E: mutmut run with an invalid mypy flag now exits 1 and shows the mypy stderr; a valid run still reports caught by type check.

Note: main currently fails the pre-commit mypy hook on
scripts/benchmark_type_check_filter.py (upstream runs 46880503657 and
46881125492). This PR does not touch that file.

The type check command exit status was ignored. A fatal mypy run, for example with an unknown flag, exits with status 2 and prints nothing to stdout, so mutmut treated it as an empty report and ran without a type check.

Raise on any status other than 0 or 1, and on status 1 with no report. Keep status 1 with a note-only report as an empty result, since mypy uses that for notes.

Fixes boxed#667.
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's exit status is ignored: a mypy run that fails without a report is read as "no type errors"

1 participant