Skip to content

Commit ede5ac8

Browse files
author
hauntsaninja
committed
fix logic
1 parent 75f09c2 commit ede5ac8

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

mypy/config_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def check_follow_imports(choice: str) -> str:
8383
'custom_typing_module': str,
8484
'custom_typeshed_dir': expand_path,
8585
'mypy_path': lambda s: [expand_path(p.strip()) for p in re.split('[,:]', s)],
86-
'ignore_path': lambda s: [expand_path(p.strip()) for p in s.split(',')],
86+
'ignore_path': lambda s: [expand_path(p.strip()).replace("/", os.sep) for p in s.split(",")],
8787
'files': split_and_match_files,
8888
'quickstart_file': expand_path,
8989
'junit_xml': expand_path,

mypy/find_sources.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import List, Sequence, Set, Tuple, Optional
77
from typing_extensions import Final
88

9-
from mypy.modulefinder import BuildSource, PYTHON_EXTENSIONS, mypy_path
9+
from mypy.modulefinder import BuildSource, PYTHON_EXTENSIONS, mypy_path, matches_ignore_pattern
1010
from mypy.fscache import FileSystemCache
1111
from mypy.options import Options
1212

@@ -111,7 +111,7 @@ def find_sources_in_dir(self, path: str) -> List[BuildSource]:
111111
):
112112
continue
113113
subpath = os.path.join(path, name)
114-
if any(subpath.endswith(pattern.rstrip("/")) for pattern in self.ignore_path):
114+
if any(matches_ignore_pattern(subpath, pattern) for pattern in self.ignore_path):
115115
continue
116116

117117
if self.fscache.isdir(subpath):

mypy/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,8 @@ def set_strict_flags() -> None:
954954
if options.logical_deps:
955955
options.cache_fine_grained = True
956956

957+
options.ignore_path = [p.replace("/", os.sep) for p in options.ignore_path]
958+
957959
# Set target.
958960
if special_opts.modules + special_opts.packages:
959961
options.build_type = BuildType.MODULE

mypy/modulefinder.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def find_modules_recursive(self, module: str) -> List[BuildSource]:
451451
continue
452452
subpath = os.path.join(package_path, name)
453453
if self.options and any(
454-
subpath.endswith(pattern.rstrip("/")) for pattern in self.options.ignore_path
454+
matches_ignore_pattern(subpath, pattern) for pattern in self.options.ignore_path
455455
):
456456
continue
457457

@@ -475,6 +475,15 @@ def find_modules_recursive(self, module: str) -> List[BuildSource]:
475475
return sources
476476

477477

478+
def matches_ignore_pattern(path: str, pattern: str) -> bool:
479+
path_components = path.split(os.sep)
480+
pattern_components = pattern.split(os.sep)
481+
return all(
482+
path == pattern
483+
for path, pattern in zip(reversed(path_components), reversed(pattern_components))
484+
)
485+
486+
478487
def verify_module(fscache: FileSystemCache, id: str, path: str, prefix: str) -> bool:
479488
"""Check that all packages containing id have a __init__ file."""
480489
if path.endswith(('__init__.py', '__init__.pyi')):

0 commit comments

Comments
 (0)