-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Allow stub files to be --exclude
d
#10842
Comments
--exclude
d
Does follow_imports = silent for the relevant module do what you want? https://mypy.readthedocs.io/en/stable/running_mypy.html#following-imports
|
It does not. I've set a minimal repo at https://github.com/jdferreira/mypy-test with to illustrate the issue. Even with the 'silent' setting, the errors are reported. |
Thanks for the repro, the following seemed to work for me:
https://mypy.readthedocs.io/en/stable/config_file.html#confval-follow_imports_for_stubs |
This did solve my issue! Thanks a bunch. For reference, and because my code base uses more than
Additionally, the documentation says that the |
Helps with python#10842, python#10820 and others There have been a number of issues recently where having this spelt out a little more explicitly would help users. The introduction of `--exclude` also (pretty understandably) confuses users who don't realise mypy's recursive file discovery is a little separate from its dogged import following. I think it could be reasonable to change mypy's behaviour so that exclude also implies follow_imports=skip (or maybe silent), but it might be a little finnicky (one is a regex on filenames, the other is patterns on fully qualified module names). I'm also just wary of attempting to change this - import following configuration is probably one of the more complicated and poorly understood parts of mypy's UX - so passing on that for now.
Helps with #10842, #10820 and others There have been a number of issues recently where having this spelt out a little more explicitly would help users. The introduction of --exclude also (pretty understandably) confuses users who don't realise mypy's recursive file discovery is a little separate from its dogged import following.
Feature
Disclaimer: I'm not sure this is a feature request or a bug report.
Allow the user to tell mypy where stubs are located but hide the errors found in there.
Pitch
I've generated thousands of stub files (with
stubgen
) to easily (if crudely) be able to type-check my code. But those files are not fully compliant withmypy
's type checks (things like using modules without type checks, redefining variables with values of different types, functions seemingly missing from the scope, etc.). I believe the modules are correct (to the point of usability, at least), and I'm not interested in tuning those files anyway. When more manual.pyi
files are created by those package owners, I'll use them instead, but for now I'm happy with the automatically generated stub.Given that, I get hundreds of errors in my output that are useless to me, and make it harder to spot my own type errors.
However, if I run
mypy --mypy-path .mypy_stubs --exclude .mypy_stubs
, these errors still appear in the output. I'd like them to be hidden.My guess is that
mypy
needs to check the stub files to be able to check my actual source (so they cannot be actually excluded), but the errors could be hidden from the output. Is this something that is reasonable? I could (in theory) try to look at the code and see if I can help with that, but I don't have a lot of experience contributing to open-source code.The text was updated successfully, but these errors were encountered: