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 trace logs for excluded dirs
  • Loading branch information
hauntsaninja committed Feb 2, 2021
commit da26d923110ce867dc8fbd9684b6b0992c83f9ca
6 changes: 5 additions & 1 deletion mypy/find_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import functools
import os
import re
import sys

from typing import List, Sequence, Set, Tuple, Optional
from typing_extensions import Final
Expand Down Expand Up @@ -93,6 +94,7 @@ def __init__(self, fscache: FileSystemCache, options: Options) -> None:
self.explicit_package_bases = get_explicit_package_bases(options)
self.namespace_packages = options.namespace_packages
self.exclude = options.exclude
self.verbose = options.verbosity >= 2

def is_explicit_package_base(self, path: str) -> bool:
assert self.explicit_package_bases
Expand All @@ -107,10 +109,12 @@ def find_sources_in_dir(self, path: str) -> List[BuildSource]:
subpath = os.path.join(path, name)

if self.exclude:
subpath_str = "/" + os.path.abspath(subpath).replace(os.sep, "/")
subpath_str = os.path.abspath(subpath).replace(os.sep, "/")
if self.fscache.isdir(subpath):
subpath_str += "/"
if re.search(self.exclude, subpath_str):
if self.verbose:
print("TRACE: Excluding {}".format(subpath_str), file=sys.stderr)
continue

if self.fscache.isdir(subpath):
Expand Down
4 changes: 3 additions & 1 deletion mypy/modulefinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,12 @@ def find_modules_recursive(self, module: str) -> List[BuildSource]:
subpath = os.path.join(package_path, name)

if self.options and self.options.exclude:
subpath_str = "/" + os.path.abspath(subpath).replace(os.sep, "/")
subpath_str = os.path.abspath(subpath).replace(os.sep, "/")
if self.fscache.isdir(subpath):
subpath_str += "/"
if re.search(self.options.exclude, subpath_str):
if self.options.verbosity >= 2:
print("TRACE: Excluding {}".format(subpath_str), file=sys.stderr)
continue

if self.fscache.isdir(subpath):
Expand Down
0