| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
--ignore-missing-stubs MODULE-1 [MODULE-2 ...] will suppress missing typeshed information for the specified modules Fixes issue python#3905
|
Thanks! I have one issue with the UI design though. The way argparse parses flags with an arbitrary number of values unfortunately makes it hard to specify that flag followed by a filename (meant as a positional arg): mypy --ignore-missing-stubs foo bar x.py will complain that there's no target module, package or file. My suggested solution is to use a comma as a separator instead; you'll have to do a little parsing of the (single) argument to make that work, and it'll require some more work for mypy.ini. |
Sorry, something went wrong.
|
What about naming it --ignore-missing-modules instead and making it possible to ignore arbitrary modules? The third party module list in mypy is not at all complete. Besides, it could be used for ignoring user modules as well. It would be nice if there was an easy way to ignore an entire package. Maybe the target should act as a prefix, ignoring all submodules as well? Or we could support the * wildcard. The documentation should probably cover packages and submodules as well. |
Sorry, something went wrong.
|
Note that IIRC it's possible to ignore specific modules by putting either ignore_missing_imports = True or follow_imports = skip in a module-specific section in mypy for the module to be ignored. (Can someone please verify that this works?) |
Sorry, something went wrong.
The new syntax is --ignore-missing-stubs module-1[,module-2,...,module-n]
|
The above commit has the new syntax and additional tests to make sure behavior is consistent with the config files. |
Sorry, something went wrong.
|
Can anyone help merge this PR? This feature would be very useful to several projects I'm working on. |
Sorry, something went wrong.
|
@boompig To move forward with this, please respond to my comments above. |
Sorry, something went wrong.
I think this may be confused with --ignore-missing-imports. Using stubs makes it clear that you're not ignoring the module, you're just ignoring the lack of a stubs file. But if you feel strongly, I don't mind changing it.
It's missing numpy and pandas, for example.
This is a good idea, though in practice I wonder how often this comes up for a user who has chosen to use mypy...
I like the idea of a * wildcard. This is a very good idea. Not sure if I have the bandwidth to work on this though, since it's a non-trivial change.
Can you explain further? |
Sorry, something went wrong.
The current approach only works for certain third party modules that happen to be whitelisted in mypy. It doesn't allow ignoring missing stdlib stubs and non-whitelisted third party modules, which is too limiting (and also confusing). We could continue to use --ignore-missing-stubs as the name of the option but allow ignoring arbitrary modules, not just whitelisted third party ones. The new note could be generated for known modules only. It would be better to generate the note for both known third party and stdlib modules, however, instead of just third party modules.
You could mention that ignoring package x doesn't affect imports from submodules of x such as x.y. It's necessary to list each submodule that is being ignored separately, and this is not clear from the current documentation. |
Sorry, something went wrong.
|
I'm not so sure this is needed.
I did test this and it worked fine. |
Sorry, something went wrong.
If you're thinking of #3789, according to the OP it still parses those modules? |
Sorry, something went wrong.
Interesting. It seems if I have: mod | - __init__.py | - lib.py it will skip it with mypy -m mod but not mypy mod. |
Sorry, something went wrong.
Ah, I know why. The latter invocation searches the folder named mod for .py[i] files, and it parses those regardless of the other settings. Though I'm now curious how the code in #3789 avoids that. |
Sorry, something went wrong.
|
Agree that this isn't needed. [mypy-module.*] ignore_missing_imports = True To suppress use of a typeshed package this is present but that you want to suppress anyways, you can use: [mypy-module.*] follow_imports = skip follow_imports_for_stubs = True (the follow_imports_for_stubs option is recent and post-dates this PR, but was a smaller hammer) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
--ignore-missing-stubs MODULE-1 [MODULE-2 ...] will suppress missing typeshed information for the specified modules
Includes tests for both command-line and config file invocations
Fixes issue #3905