Skip to content
Merged
Changes from all commits
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
28 changes: 22 additions & 6 deletions mypy/modulefinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,12 +684,27 @@ def matches_exclude(
if fscache.isdir(subpath):
subpath_str += "/"
for exclude in excludes:
if re.search(exclude, subpath_str):
if verbose:
print(
f"TRACE: Excluding {subpath_str} (matches pattern {exclude})", file=sys.stderr
try:
if re.search(exclude, subpath_str):
if verbose:
print(
f"TRACE: Excluding {subpath_str} (matches pattern {exclude})",
file=sys.stderr,
)
return True
except re.error as e:
print(
f"error: The exclude {exclude} is an invalid regular expression, because: {e}"
+ (
"\n(Hint: use / as a path separator, even if you're on Windows!)"
if "\\" in exclude
else ""
)
return True
+ "\nFor more information on Python's flavor of regex, see:"
+ " https://docs.python.org/3/library/re.html",
file=sys.stderr,
)
sys.exit(2)
return False


Expand Down Expand Up @@ -786,7 +801,8 @@ def default_lib_path(
print(
"error: --custom-typeshed-dir does not point to a valid typeshed ({})".format(
custom_typeshed_dir
)
),
file=sys.stderr,
)
sys.exit(2)
else:
Expand Down