Skip to content

empty directory among multiple targets aborts whole check #22173

Open

Description

@Zocker1999NET

When mypy is given more than one target and one of them expands to zero Python files, it exits with code 2 and emits no diagnostics for the other, valid targets.

I would expect only the empty target to be flagged with a warning and the remaining targets to still be checked. And only to be a fatal error when all given targets do neither contain a single Python file.

Context

mypy and dmypy show both the same issue here, which is why the issue is targeted to mypy alone. But the context of where this matters to me is in VS Code with the matangover.mypy extension which relies on dmypy. Where because of this preemptive exit, the extension cannot report anything about the files in the directories with Python files. And in that context, IMO it makes sense to insert multiple target dirs for future proofing (e.g. by configuring the search locations .github & . globally).

To Reproduce

# A directory containing only a Python file inside a dot-directory:
$ tree -a
.
── .github/
    └── hooks/
        └── enforce-tool-policy.py

$ mypy .github .

Expected Behavior

.github/hooks/enforce-tool-policy.py should still be type checked and its errors should be emitted.

Actual Behavior

$ mypy --config-file mypy.ini .github .
There are no .py[i] files in directory '.'
# exit code 2

Mypy not being helpful because it does not analyze the file which does exist.

Your Environment

  • Mypy version used: 1.20.1
  • Mypy command-line flags: mypy --config-file mypy.ini .github .
  • Mypy configuration options from mypy.ini: can be empty
  • Python version used: 3.13

Activity

  1. nightcityblade commented on Oct 11, 2026

    @nightcityblade

    Hi, I'd like to work on this. I'll submit a focused PR with a regression test shortly.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions