Skip to content

Commit cb0917d

Browse files
author
hauntsaninja
committed
add node_modules back to default exclusion
1 parent f5be793 commit cb0917d

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

docs/source/command_line.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ for full details, see :ref:`running-mypy`.
5757

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

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

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

7475

7576
Optional arguments

mypy/find_sources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def find_sources_in_dir(self, path: str) -> List[BuildSource]:
105105
names = sorted(self.fscache.listdir(path), key=keyfunc)
106106
for name in names:
107107
# Skip certain names altogether
108-
if name in ("__pycache__", "site-packages") or name.startswith("."):
108+
if name in ("__pycache__", "site-packages", "node_modules") or name.startswith("."):
109109
continue
110110
subpath = os.path.join(path, name)
111111

mypy/modulefinder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def find_modules_recursive(self, module: str) -> List[BuildSource]:
444444
names = sorted(self.fscache.listdir(package_path))
445445
for name in names:
446446
# Skip certain names altogether
447-
if name in ("__pycache__", "site-packages") or name.startswith("."):
447+
if name in ("__pycache__", "site-packages", "node_modules") or name.startswith("."):
448448
continue
449449
subpath = os.path.join(package_path, name)
450450

0 commit comments

Comments
 (0)