Skip to content
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 disabling mypy completely per module/package #3383

Closed
Daenyth opened this issue May 19, 2017 · 6 comments
Closed

Allow disabling mypy completely per module/package #3383

Daenyth opened this issue May 19, 2017 · 6 comments

Comments

@Daenyth
Copy link

Daenyth commented May 19, 2017

I'd like to exclude a package from mypy entirely. Due to some constraints right now, I need to commit some generated code to my repo, and it's breaking my mypy setup because it's untyped.

I can't just tune down the parameters because mypy treats certain ones as global - I tried flipping all the flags off that I could, but even setting follow_imports = silent in my mypy.ini under [mypy-pkg/foo], I still get errors about error: No library stub file for module 'blah' coming from inside the foo package

This would also help make it easier for new projects to start using mypy incrementally in their CI, by blacklisting sections that haven't been updated yet.

@Daenyth Daenyth changed the title Allow disabling mypy completely per module Allow disabling mypy completely per module/package May 19, 2017
@gvanrossum
Copy link
Member

In mypy.ini you can include a section like this:

[mypy-foo.bar.baz]
ignore_errors = True

(assuming the name of your generated module is foo.bar.baz, e.g. living in a file foo/bar/baz.py.)

See http://mypy.readthedocs.io/en/latest/config_file.html

@Daenyth
Copy link
Author

Daenyth commented May 19, 2017 via email

@miedzinski
Copy link
Contributor

You can use * wildcard. See https://mypy.readthedocs.io/en/latest/config_file.html.

@dimaqq
Copy link

dimaqq commented Oct 11, 2022

It seems that some errors are too terrible to ignore:

> mypy .
/.../lib/python3.10/site-packages/lmdbm/lmdbm.py:28: error: syntax error in type comment "(bool, ) -> None"
/.../lib/python3.10/site-packages/lmdbm/lmdbm.py:98: error: syntax error in type comment "(int, ) -> None"
/.../lib/python3.10/site-packages/lmdbm/lmdbm.py:103: error: syntax error in type comment "(object, ) -> bytes"
/.../lib/python3.10/site-packages/lmdbm/lmdbm.py:113: error: syntax error in type comment "(bytes, ) -> KT"
/.../lib/python3.10/site-packages/lmdbm/lmdbm.py:118: error: syntax error in type comment "(VT, ) -> bytes"
/.../lib/python3.10/site-packages/lmdbm/lmdbm.py:128: error: syntax error in type comment "(bytes, ) -> VT"
/.../lib/python3.10/site-packages/lmdbm/lmdbm.py:133: error: syntax error in type comment "(KT, ) -> VT"
/.../lib/python3.10/site-packages/lmdbm/lmdbm.py:161: error: syntax error in type comment "(KT, ) -> None"
/.../lib/python3.10/site-packages/lmdbm/lmdbm.py:188: error: syntax error in type comment "(object, ) -> bool"
/.../lib/python3.10/site-packages/lmdbm/lmdbm.py:288: error: syntax error in type comment "(VT, ) -> bytes"
/.../lib/python3.10/site-packages/lmdbm/lmdbm.py:294: error: syntax error in type comment "(bytes, ) -> VT"
Found 11 errors in 1 file (errors prevented further checking)

I've tried to silence this with:

# pyproject.toml
[[tool.mypy.overrides]]
module = "lmdbm.*"
ignore_errors = true

but, alas, this isn't working...
(it could be that I just don't understand the config syntax 😕

Encountered with mypy 0.982 (compiled: yes)

P.S. I'm sorry for resurrecting an old thread.

@hauntsaninja
Copy link
Collaborator

Yeah, "errors prevented further checking" is an indicator of a too terrible error :-)

The easiest thing for you is probably to add a per-module follow_imports=skip.

(Instead of analysing the module and trying to ignore errors, that will prevent analysis of the module in the first place and just preemptively replace everything from it with Any)

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Jan 12, 2024

Since people are linking to this: I fixed the blocking import part of this in #13506. There might still be some reporting issues though.

Also note: the per-module follow_imports option refers to the module you're using, not the module you use it from (which is what you want in this situation!). Be careful with follow_imports, in particular, if you set it globally you will make mypy kinda useless.

(Locking, since I think enough has changed that further discussion on this issue will just prove confusing)

@python python locked as resolved and limited conversation to collaborators Jan 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants