8000 Use ‘exclude list’ instead of ‘blacklist’ by wbolster · Pull Request #4297 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Use ‘exclude list’ instead of ‘blacklist’ #4297

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 1 commit into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Run using:`(.venv3)$ python3 tests/mypy_test.py`

This test is shallow — it verifies that all stubs can be
imported but doesn't check whether stubs match their implementation
(in the Python standard library or a third-party package). It has a blacklist of
(in the Python standard library or a third-party package). It has an exclude list of
modules that are not tested at all, which also lives in the tests directory.

If you are in the typeshed repo that is submodule of the
Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions tests/mypy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def log(args, *varargs):
print(*varargs)


def match(fn, args, blacklist):
if blacklist.match(fn):
log(args, fn, 'exluded by blacklist')
def match(fn, args, exclude_list):
if exclude_list.match(fn):
log(args, fn, 'exluded by exclude list')
return False
if not args.filter and not args.exclude:
log(args, fn, 'accept by default')
Expand Down Expand Up @@ -80,8 +80,8 @@ def libpath(major, minor):
def main():
args = parser.parse_args()

with open(os.path.join(os.path.dirname(__file__), "mypy_blacklist.txt")) as f:
blacklist = re.compile("(%s)$" % "|".join(
with open(os.path.join(os.path.dirname(__file__), "mypy_exclude_list.txt")) as f:
exclude_list = re.compile("(%s)$" % "|".join(
re.findall(r"^\s*([^\s#]+)\s*(?:#.*)?$", f.read(), flags=re.M)))

try:
Expand Down Expand Up @@ -112,7 +112,7 @@ def main():
if mod in seen or mod.startswith('.'):
continue
if ext in ['.pyi', '.py']:
if match(full, args, blacklist):
if match(full, args, exclude_list):
seen.add(mod)
files.append(full)
elif (os.path.isfile(os.path.join(full, '__init__.pyi')) or
Expand All @@ -124,7 +124,7 @@ def main():
m, x = os.path.splitext(f)
if x in ['.pyi', '.py']:
fn = os.path.join(r, f)
if match(fn, args, blacklist):
if match(fn, args, exclude_list):
seen.add(mod)
files.append(fn)
if files:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Pytype blacklist. Files will not be tested with pytype.
# Pytype exclude list. Files will not be tested with pytype.

# pytype has its own version of these files, and thus doesn't mind if it
# can't parse the typeshed version:
Expand Down
10 changes: 5 additions & 5 deletions tests/pytype_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Depends on pytype being installed.

If pytype is installed:
1. For every pyi, do nothing if it is in pytype_blacklist.txt.
1. For every pyi, do nothing if it is in pytype_exclude_list.txt.
2. Otherwise, call 'pytype.io.parse_pyi'.
Option two will load the file and all the builtins, typeshed dependencies. This
will also discover incorrect usage of imported modules.
Expand Down Expand Up @@ -72,8 +72,8 @@ def search(self, path: str) -> Optional[Match[str]]:
return self.matcher.search(path)


def load_blacklist(typeshed_location: str) -> List[str]:
filename = os.path.join(typeshed_location, "tests", "pytype_blacklist.txt")
def load_exclude_list(typeshed_location: str) -> List[str]:
filename = os.path.join(typeshed_location, "tests", "pytype_exclude_list.txt")
skip_re = re.compile(r"^\s*([^\s#]+)\s*(?:#.*)?$")
skip = []

Expand Down Expand Up @@ -159,10 +159,10 @@ def check_python_exes_runnable(*, python27_exe_arg: str, python36_exe_arg: str)


def determine_files_to_test(*, typeshed_location: str, paths: Sequence[str]) -> List[Tuple[str, int]]:
"""Determine all files to test, checking if it's in the blacklist and which Python versions to use.
"""Determine all files to test, checking if it's in the exclude list and which Python versions to use.

Returns a list of pairs of the file path and Python version as an int."""
skipped = PathMatcher(load_blacklist(typeshed_location))
skipped = PathMatcher(load_exclude_list(typeshed_location))
filenames = find_stubs_in_paths(paths)
files = []
for f in sorted(filenames):
Expand Down
0