8000 Add --exclude by hauntsaninja · Pull Request #9992 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Add --exclude #9992

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

Merged
merged 22 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add node_modules back to default exclusion
  • Loading branch information
hauntsaninja committed Feb 3, 2021
commit cb0917d28042891f72c80b987425b8f88d51573e
11 changes: 6 additions & 5 deletions docs/source/command_line.rst
8000
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ for full details, see :ref:`running-mypy`.

For instance, to avoid discovering any files named `setup.py` you could
pass ``--exclude '/setup.py$'``. Similarly, you can ignore discovering
directories with a given name by e.g. ``--exclude /node_modules/`` or
directories with a given name by e.g. ``--exclude /build/`` or
those matching a subpath with ``--exclude /project/vendor/``.

Note that this flag only affects recursive discovery, that is, when mypy is
Expand All @@ -66,10 +66,11 @@ for full details, see :ref:`running-mypy`.
instance, ``mypy --exclude '/setup.py$' but_still_check/setup.py``.

Note that mypy will never recursively discover files and directories named
"site-packages" or "__pycache__" or those whose name starts with a period,
exactly as ``--exclude '/(site-packages|__pycache__|\..*)$'`` would.
Mypy will also never recursively discover files with extensions other than
``.py`` or ``.pyi``.
"site-packages", "node_modules" or "__pycache__", or those whose name starts
with a period, exactly as ``--exclude
'/(site-packages|node_modules|__pycache__|\..*)$'`` would. Mypy will also
never recursively discover files with extensions other than ``.py`` or
``.pyi``.


Optional arguments
Expand Down
2 changes: 1 addition & 1 deletion mypy/find_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def find_sources_in_dir(self, path: str) -> List[BuildSource]:
names = sorted(self.fscache.listdir(path), key=keyfunc)
for name in names:
# Skip certain names altogether
if name in ("__pycache__", "site-packages") or name.startswith("."):
if name in ("__pycache__", "site-packages", "node_modules") or name.startswith("."):
continue
subpath = os.path.join(path, name)

Expand Down
2 changes: 1 addition & 1 deletion mypy/modulefinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def find_modules_recursive(self, module: str) -> List[BuildSource]:
names = sorted(self.fscache.listdir(package_path))
for name in names:
# Skip certain names altogether
if name in ("__pycache__", "site-packages") or name.startswith("."):
if name in ("__pycache__", "site-packages", "node_modules") or name.startswith("."):
continue
subpath = os.path.join(package_path, name)

Expand Down
0