mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 22:11:54 +08:00
Rename whitelist to allowlist (#5614)
Resolves #4436 I want to add stubtest for third party stubs, and figured it'd be easier to make this change now. Co-authored-by: hauntsaninja <>
This commit is contained in:
@@ -81,8 +81,8 @@ If you need a specific version of Python to repro a CI failure,
|
||||
[pyenv](https://github.com/pyenv/pyenv) can help.
|
||||
|
||||
Due to its dynamic nature, you may run into false positives. In this case, you
|
||||
can add to the whitelists for each affected Python version in
|
||||
`tests/stubtest_whitelists`. Please file issues for stubtest false positives
|
||||
can add to the allowlists for each affected Python version in
|
||||
`tests/stubtest_allowlists`. Please file issues for stubtest false positives
|
||||
at [mypy](https://github.com/python/mypy/issues).
|
||||
|
||||
To run stubtest against third party stubs, it's easiest to use stubtest
|
||||
|
||||
@@ -21,7 +21,7 @@ select.kqueue.__init__ # default C signature is wrong
|
||||
select.POLLMSG # system dependent
|
||||
|
||||
# ==========
|
||||
# Whitelist entries that cannot or should not be fixed
|
||||
# Allowlist entries that cannot or should not be fixed
|
||||
# ==========
|
||||
|
||||
# Modules that do not exist on macos systems
|
||||
@@ -26,7 +26,7 @@ spwd.struct_spwd._make # PyStructSequence
|
||||
spwd.struct_spwd._replace # PyStructSequence
|
||||
|
||||
# ==========
|
||||
# Whitelist entries that cannot or should not be fixed
|
||||
# Allowlist entries that cannot or should not be fixed
|
||||
# ==========
|
||||
|
||||
# Modules that do not exist on Linux systems
|
||||
@@ -219,7 +219,7 @@ webbrowser.UnixBrowser.remote_action_newwin # always overridden in inheriting c
|
||||
wsgiref.types # Doesn't exist, see comments in file
|
||||
|
||||
# ==========
|
||||
# Whitelist entries that cannot or should not be fixed
|
||||
# Allowlist entries that cannot or should not be fixed
|
||||
# ==========
|
||||
_pydecimal.* # See comments in file
|
||||
ast.NodeVisitor.visit_\w+ # Methods are discovered dynamically, see #3796
|
||||
@@ -6,7 +6,7 @@ locale.[A-Z0-9_]+ # Constants that should be moved to _locale and re-exported c
|
||||
locale.nl_langinfo # Function that should be moved to _locale and re-exported conditionally
|
||||
|
||||
# ==========
|
||||
# Whitelist entries that cannot or should not be fixed
|
||||
# Allowlist entries that cannot or should not be fixed
|
||||
# ==========
|
||||
|
||||
# Modules that do not exist on Windows systems
|
||||
@@ -16,40 +16,40 @@ from pathlib import Path
|
||||
|
||||
|
||||
def run_stubtest(typeshed_dir: Path) -> int:
|
||||
whitelist_dir = typeshed_dir / "tests" / "stubtest_whitelists"
|
||||
version_whitelist = "py{}{}.txt".format(sys.version_info.major, sys.version_info.minor)
|
||||
platform_whitelist = "{}.txt".format(sys.platform)
|
||||
combined_whitelist = "{}-py{}{}.txt".format(sys.platform, sys.version_info.major, sys.version_info.minor)
|
||||
allowlist_dir = typeshed_dir / "tests" / "stubtest_allowlists"
|
||||
version_allowlist = "py{}{}.txt".format(sys.version_info.major, sys.version_info.minor)
|
||||
platform_allowlist = "{}.txt".format(sys.platform)
|
||||
combined_allowlist = "{}-py{}{}.txt".format(sys.platform, sys.version_info.major, sys.version_info.minor)
|
||||
|
||||
ignore_unused_whitelist = "--ignore-unused-whitelist" in sys.argv[1:]
|
||||
ignore_unused_allowlist = "--ignore-unused-allowlist" in sys.argv[1:]
|
||||
|
||||
cmd = [
|
||||
sys.executable,
|
||||
"-m",
|
||||
"mypy.stubtest",
|
||||
# Use --ignore-missing-stub, because if someone makes a correct addition, they'll need to
|
||||
# also make a whitelist change and if someone makes an incorrect addition, they'll run into
|
||||
# also make a allowlist change and if someone makes an incorrect addition, they'll run into
|
||||
# false negatives.
|
||||
"--ignore-missing-stub",
|
||||
"--check-typeshed",
|
||||
"--custom-typeshed-dir",
|
||||
str(typeshed_dir),
|
||||
"--whitelist",
|
||||
str(whitelist_dir / "py3_common.txt"),
|
||||
"--whitelist",
|
||||
str(whitelist_dir / version_whitelist),
|
||||
"--allowlist",
|
||||
str(allowlist_dir / "py3_common.txt"),
|
||||
"--allowlist",
|
||||
str(allowlist_dir / version_allowlist),
|
||||
]
|
||||
if ignore_unused_whitelist:
|
||||
cmd += ["--ignore-unused-whitelist"]
|
||||
if (whitelist_dir / platform_whitelist).exists():
|
||||
if ignore_unused_allowlist:
|
||||
cmd += ["--ignore-unused-allowlist"]
|
||||
if (allowlist_dir / platform_allowlist).exists():
|
||||
cmd += [
|
||||
"--whitelist",
|
||||
str(whitelist_dir / platform_whitelist),
|
||||
"--allowlist",
|
||||
str(allowlist_dir / platform_allowlist),
|
||||
]
|
||||
if (whitelist_dir / combined_whitelist).exists():
|
||||
if (allowlist_dir / combined_allowlist).exists():
|
||||
cmd += [
|
||||
"--whitelist",
|
||||
str(whitelist_dir / combined_whitelist),
|
||||
"--allowlist",
|
||||
str(allowlist_dir / combined_allowlist),
|
||||
]
|
||||
if sys.version_info < (3, 10):
|
||||
# As discussed in https://github.com/python/typeshed/issues/3693, we only aim for
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Runs stubtest and prints each unused whitelist entry with filename.
|
||||
# Runs stubtest and prints each unused allowlist entry with filename.
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import List, Tuple
|
||||
|
||||
_UNUSED_NOTE = "note: unused allowlist entry "
|
||||
_WHITELIST_PATH = Path("tests") / "stubtest_whitelists"
|
||||
_ALLOWLIST_PATH = Path("tests") / "stubtest_allowlists"
|
||||
|
||||
|
||||
def main() -> None:
|
||||
@@ -30,11 +30,11 @@ def unused_files(unused: str) -> List[Tuple[str, str]]:
|
||||
files = ["py3_common.txt", version + ".txt", sys.platform + ".txt", sys.platform + "-" + version + ".txt"]
|
||||
found = []
|
||||
for file in files:
|
||||
path = _WHITELIST_PATH / file
|
||||
path = _ALLOWLIST_PATH / file
|
||||
if find_unused_in_file(unused, path):
|
||||
found.append((path.as_posix(), unused))
|
||||
if not found:
|
||||
raise ValueError("unused item {} not found in any whitelist file".format(unused))
|
||||
raise ValueError("unused item {} not found in any allowlist file".format(unused))
|
||||
return found
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user