Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mypy - erroring when there are no Python files

Tags:

python

mypy

Is there a way to stop mypy erroring when it doesn't find any .py files? In essence, this isn't an error. What Im looking to do is hide or silence this one error.

$ poetry run mypy .
There are no .py[i] files in directory '.'
Error: Process completed with exit code 2.

Thanks,

like image 789
felix001 Avatar asked Jun 23 '26 09:06

felix001


1 Answers

From mypy's source it doesn't look like there is any way to do this from mypy directly. The function that reports the error does provide an argument for ignoring this error, but the argument is only passed from within tests https://github.com/python/mypy/blob/99f4d5af147d364eda1d4b99e79770c171896f13/mypy/find_sources.py#L20-L47.

Without ignoring other errors, as far as I can tell you'd have to submit each path to mypy individually (if you're passing it multiple) and ignore the 2 error code if it reports the error you want to ignore.

Patching mypy would be an another option, but mypy is precompiled through mypyc so you'd have to get rid of the binaries and lose out on a bunch of performance with monkey-patching, or build it yourself with the function changed and install the patched module.

like image 195
Numerlor Avatar answered Jun 24 '26 21:06

Numerlor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!