-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Exclude patterns don't work for the nested modules #10820
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
Comments
Exclude currently only affects mypy's recursive directory, not its import following. Similar issue to #10377. In addition to an exclude pattern, try adding:
to your config file. |
Hi, I've treid adding the suggested section into my
BTW setting Also, I think it is worth mentioning in the docs that |
Sorry, not too familiar with the TOML config file, maybe try the following:
Yeah, agreed on the point about documentation as a minimum thing to do here. |
This has worked, thank you |
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.
Unfortunately, though [[tool.mypy.overrides]]
module = "mypkg.*"
follow_imports = "skip"
ignore_errors = true will skip following imports and ignore errors, |
There is several similar issues, and I just encountered the same. I think reporting another concrete case could help, and I'm willing to contribute to the documentation if I can find the solution. If I should instead another issue, please let me know. I got the same problem/question, but not for a third party package, for a part of my codebase which is hard to refactor for now, while I still want to catch type errors elsewhere with the CI. Simplified tree of the project:
pyproject.toml (only relevant parts) [tool.mypy]
exclude = [
'^(docs|tasks|tests)|setup\.py'
]
[[tool.mypy.overrides]]
module = "thoth.*" # Trying to test the ignore_errors fonctionnality on the whole package before being more specific
follow_imports = "skip"
ignore_errors = true Unfortunately it does not seem to have any effect (= I get mypy errors for every code under The mentionned code is availabe at https://github.com/thoth-station/storages for context. |
Are you sure your module name is |
Indeed, you're right. I'm apparently still confused by the package concept in Python. Sorry for the noise then, and thanks for the tip 👍 |
It looks like there is no bug or feature request here. If so, this issue can be closed. |
The documentation was improved a while back. #10377 can be used to track the possibility of making exclude imply a per module follow imports skip. For anything else, open a new issue. |
My project directory structure is something like:
"waveshare_epd" is a third party module which is not published on PyPi, so I had to include it's files directly into the project folder. However, it generates a lot of errors which ruin my CI so I want to exclude those files from checking.
For that I use the "exclude" option in my configuration file (pyproject.toml).
The issue is that none of the regular expressions I've tried putting into the exclude option actually work.
I have tried:
"waveshare_epd", ".*/waveshare_epd/", "feecc_spoke/waveshare_epd/.*", ".*epd.*", "[epd2in13d\.py|epdconfig\.py]"
and many more patterns.I have tried putting in the patterns via: command line arguments, mypy.ini file, pyproject.toml file. None of the options had any effect - the files still get included into the report.
My current configuration (a section in the pyproject.toml file) looks like this:
At this point I have spent hours at this issue over the course of multiple days and still can't find any fix for the problem.
I am using MyPy v.0.910 inside of a Poetry generated venv with base interpreter being Python 3.9.6 on a Linux system.
The text was updated successfully, but these errors were encountered: