-
-
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
Add ability to ignore a file or directory without modifying it #4675
Comments
If you're just going to ignore the errors from specific paths, a more elegant solution is to use module-specific sections in your |
I think that will work and it is something that I was not aware of and I probably should have read the docs closer. Thank you, I will close this. |
The proposed solution doesn't work in case the mypy.ini is being controlled by a different entity (DevOps for example). |
I have a django codebase, where mypy is catching type errors in auto-generated migration files |
Wait, so you control neither
Yes, |
I have a Qt resource file compiled with pyrcc, which I want to ignore. I can't add I would like to add
or
to ignore all |
@Djedouas I think that.. [mypy-*.resources]
ignore_errors = True ...should work for you. Does it? |
@brandtbucher thanks, it works ! I was sure I had tested this pattern before, but apparently not... ;-) |
I am having same issue with a Another tool supporting A bit clunky in that their yaml doesn't support an excludes list, just a single regex. # ...
exclude: "(.idea/)|(src/my_project/__init__.py)|(src/my_project/_version.py)|(versioneer.py)" |
Pardon the comment on a closed issue, but this seems to be the most appropriate place. In pypa/twine#619, I'm ignoring the tests (primarily to avoid noise in my editor) by making
However, there's some concern about the side-effects of making More detail at https://github.com/pypa/twine/pull/619/files#r423015876. |
I want to ignore errors in unit test files. My unit tests are co-located with the code they test, under
|
@Hubro In order to ignore tests as you're attempting to do, I've resorted to making the Of course, that solution depends on your project structure. Also, if you're using setuptools to create a distribution, it could also result in your |
For Django migrations:
|
Another situation where the existing configuration options don't seem to work. Here, the src directory contains data files that are to be used by cookiecutter to render a new project. And unfortunately the project once rendered will be a python package, so mypy detects it. But it complains that the package name is not valid, which is true, but it should be ignored.
mypy.ini:
Running this:
Any workarounds? |
I think it's worth adding more support for something like this. We actually now have an example in mypy where |
Namely improvements to finding namespace modules (failing test pdoc.test.ApiTest.test_namespace): https://mypy-lang.blogspot.com/2021/01/mypy-0800-released.html python/mypy#4675 (comment)
It's not only helpful in combination with I don't have a minimal example atm. that I could share. |
Mymy has started linting all of node_modules as of 0.800 for me |
I have the same problem.
I would appreciate at least something like |
after the last version of mypy, I started to see all the typehinting for the I think a |
+1 |
+1
|
Resolves python#4675, resolves python#9981 Additionally, we always ignore site-packages and node_modules. Also note that this doesn't really affect import discovery; it only directly affects passing files or packages to mypy. The additional check before suggesting "are you missing an __init__.py" didn't make any sense to me, so I removed it, appended to the message and downgraded the severity to note.
Resolves python#4675, resolves python#9981 Additionally, we always ignore site-packages and node_modules. Also note that this doesn't really affect import discovery; it only directly affects passing files or packages to mypy. The additional check before suggesting "are you missing an __init__.py" didn't make any sense to me, so I removed it, appended to the message and downgraded the severity to note.
I opened a PR addressing this at #9992. I'd appreciate if some of you could test it and report back if it doesn't fix your issues. |
After upgrade to 0.800. When run 'mypy .' in my project root dir as before, I got error "...site-packages is in the PYTHONPATH. Please change directory so it is not". This error is raised in 'modulefinder.py'. I think it may be caused by take my "venv" virtual env dir as a package. May be add 'ignore_path' in config file could fix this? |
Awesome, for me this solved the issue by ignoring all bazel generated directories:
Mypy still throws many errors that were not there in v0.790... at least those I can start fixing myself 😄 |
I'm running into an issue where I have vendorized git submodules for a C++ extension (which I don't control) in a subfolder of my package, and these vendorized modules include python 2 files. As a result, mypy is stopping due to syntax errors even if I set |
Seeing a similar problem with a file in a build directory:
It doesn't make sense to me to ignore errors for build/lib but rather to completely exclude it from processing. |
Resolves #4675, resolves #9981. Additionally, we always ignore site-packages and node_modules, and directories starting with a dot. Also note that this doesn't really affect import discovery; it only directly affects passing files or packages to mypy. The additional check before suggesting "are you missing an __init__.py" didn't make any sense to me, so I removed it, appended to the message and downgraded the severity to note. Co-authored-by: hauntsaninja <>
Resolves #4675, resolves #9981. Additionally, we always ignore site-packages and node_modules, and directories starting with a dot. Also note that this doesn't really affect import discovery; it only directly affects passing files or packages to mypy. The additional check before suggesting "are you missing an __init__.py" didn't make any sense to me, so I removed it, appended to the message and downgraded the severity to note. Co-authored-by: hauntsaninja <>
Until python/mypy#4675 is resolved and PR merged
Hello, I wanted to ask something. I am using MyPy on a large existing codebase. I am maintaining a list of files that do not have types. How can I run the tests for all files except these files? Thanks! |
@hardikkat24 the documentation on the implemented functionality is here. You should provide the list of files to the |
Thanks a lot @micahjsmith |
Did you find a solution for this? |
@sonic-chase see my above comment linking to the mypy docs. The correct config option is |
Thanks! It was just a regex issue, ha. |
Namely improvements to finding namespace modules (failing test pdoc.test.ApiTest.test_namespace): https://mypy-lang.blogspot.com/2021/01/mypy-0800-released.html python/mypy#4675 (comment)
Namely improvements to finding namespace modules (failing test pdoc.test.ApiTest.test_namespace): https://mypy-lang.blogspot.com/2021/01/mypy-0800-released.html python/mypy#4675 (comment)
In a project I maintain, we vendor some third party Python code and the project includes generated files such as files created by python-versioneer.
What I'd like to do is type check all files, including any new files, apart from those that I have explicitly ignored.
Right now I have the following hack workaround:
Various tools have mechanisms for doing this, for example:
Thank you for the software.
The text was updated successfully, but these errors were encountered: