-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Exclude multiple directories on mypy commandline: improve documentation #10250
Comments
This works... Closing.
|
If the correct solution isn't obvious, the documentation should be improved. We could add an example excluding multiple directories. |
I also found that the correct syntax wasn't obvious :( would really appreciate an example excluding multiple directories and an example excluding from a config file |
Reopening as a docs issue |
The docs (that you linked to) do technically have an example excluding multiple things: |
That example has If I want to land |
It could be good to have a few more examples in the docs, each of which only does a fairly specific thing, and clearly explain what each example does exactly. Regular expressions are not very familiar to everybody, and they can be used in subtly incorrect ways that result in false negatives or other unexpected results. |
I consider myself to be pretty decent with regex and even I cannot figure out how to simultaneously exclude
Being forced to write one massive regex for this is pretty horrible. The command line syntax should be more similar to |
In the pull request above I added an example on how to combine expressions to exclude multiple file names an directory names. Similar to @cclauss I also tried passing the |
I wonder if we should just make passing multiple |
I suppose in the config file |
That makes sense to me / let's use #10310 to track that. Note the initial non regex implementation of exclude did this, but Jukka requested a single value for the exclude option in #9992 (comment) when we decided to use regexes. |
Please consider including an example on how to unambiguously identify a single entry at any level without sweeping in others. The current example(s) do not work for that. As of 0.910, As an aside, the ergonomics of that are pretty brutal. I don't know of any other command that requires this much domain knowledge to correctly exclude precisely the desired files from processing. |
Here is the syntax I use: exclude = """
(?x)(
file.py$|
anotherone.py
)
""" |
Thanks, @trallnag. What does |
@posita, the parenthesis and the question mark are used to set modifier flags and in this case I set the x modifier to enable extended mode. This allows breaking up the regex string with whitespace and newlines. I copied this from an example in the context of pre-commit some time ago |
Oh! Duh. It's the inline version of the verbose flag.
|
Some further documentation on configuring complex examples of exclusions with pyproject.toml would be helpful. There's some idiosyncrasies between the mypy.ini, the console and pyproject.toml which make it very confusing on how to exclude:
|
@posita |
@trallnag Would you mind to give an example of how to use pyproject.toml to exclude multiple directories and files? |
Here's one example I used. [tool.mypy]
python_version = 3.8
ignore_missing_imports = true
exclude = "(setup.py|tasks.py)/$" Would appreciate more. |
Thanks @asears for the example. After a bit more searching, I was also able to find other examples. |
Here's one example I used.
|
Thanks to everyone who's contributed here. The docs on latest master (and the upcoming 0.931) are substantially different than when this was converted to a docs issue, so I'm closing this issue. If there are specific improvements still to be made, feel free to open a PR |
FWIW, I think @cclauss's issue remains (even with the doc updates), but perhaps it's better to open a new issue after 0.931 is released? (I'm willing to take a stab at an update once I get some free time. Feel free to @-mention me if a new issue is filed.) |
Questions and Help
Please note that this issue tracker is not a help form and this issue will be closed.
Please check here instead:
This question is about the mypy commandline, not about mypy configuration files.
The
--exclude
documentation does not explain how to exclude multiple directories on mypy commandline.Should there be a single
--exclude
option with comma-separated terms orshould there be multiple
--exclude
options whose terms would be additive?mypy --ignore-missing-imports --exclude @mypy_failing_files.txt
# does not work as expected.Given https://github.com/TheAlgorithms/Python we would like to exclude directories until they can be made mypy compatible. We currently have an include list that works but as our mypy compatibility increases, we would like to switch to a shorter
exclude list
like:The text was updated successfully, but these errors were encountered: