MCPcopy Index your code
hub / github.com/python/mypy / matches_exclude

Function matches_exclude

mypy/modulefinder.py:677–707  ·  view source on GitHub ↗
(
    subpath: str, excludes: list[str], fscache: FileSystemCache, verbose: bool
)

Source from the content-addressed store, hash-verified

675
676
677def matches_exclude(
678 subpath: str, excludes: list[str], fscache: FileSystemCache, verbose: bool
679) -> bool:
680 if not excludes:
681 return False
682 subpath_str = os.path.relpath(subpath).replace(os.sep, "/")
683 if fscache.isdir(subpath):
684 subpath_str += "/"
685 for exclude in excludes:
686 try:
687 if re.search(exclude, subpath_str):
688 if verbose:
689 print(
690 f"TRACE: Excluding {subpath_str} (matches pattern {exclude})",
691 file=sys.stderr,
692 )
693 return True
694 except re.error as e:
695 print(
696 f"error: The exclude {exclude} is an invalid regular expression, because: {e}"
697 + (
698 "\n(Hint: use / as a path separator, even if you're on Windows!)"
699 if "\\" in exclude
700 else ""
701 )
702 + "\nFor more information on Python's flavor of regex, see:"
703 + " https://docs.python.org/3/library/re.html",
704 file=sys.stderr,
705 )
706 sys.exit(2)
707 return False
708
709
710def matches_gitignore(subpath: str, fscache: FileSystemCache, verbose: bool) -> bool:

Callers 2

find_sources_in_dirMethod · 0.90

Calls 4

printFunction · 0.85
replaceMethod · 0.80
exitMethod · 0.80
isdirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…