Repository: python/typeshed

Issue:
Drop all use of the name whitelist in the codebase
https://github.com/python/typeshed/pull/4297 changed `blacklist` to `exclude_list` in the typeshed codebase. 👍 

But `whitelist` remains.  Please rename all `whitelist` references to `allow_list` or similar.


Discussion:
in particular `scripts/update-stubtest-whitelist.py` and `tests/stubtest_whitelist` (I didn't grep, just poked around the tree)
Does this still require improvements? If yes then I'm in else why don't you mark it closed
@gpshead 
It's blocked on changes^ to mypy, which have been made but need to be released before it makes sense to change typeshed

Resolving patch:
diff --git a/scripts/update-stubtest-whitelist.py b/scripts/update-stubtest-allowlist.py
similarity index 82%
rename from scripts/update-stubtest-whitelist.py
rename to scripts/update-stubtest-allowlist.py
--- a/scripts/update-stubtest-whitelist.py
+++ b/scripts/update-stubtest-allowlist.py
@@ -1,11 +1,11 @@
 #!/usr/bin/env python3
 
-# This script removes lines from stubtest whitelists, according to
+# This script removes lines from stubtest allowlists, according to
 # an input file. The input file has one entry to remove per line.
-# Each line consists of a whitelist filename and an entry, separated
+# Each line consists of a allowlist filename and an entry, separated
 # by a colon.
 
-# This script is used by the workflow to remove unused whitelist entries.
+# This script is used by the workflow to remove unused allowlist entries.
 
 import sys
 from collections import defaultdict
@@ -19,7 +19,7 @@ def main() -> None:
 
     to_remove = parse_input_file(sys.argv[1])
     for filename, entries in to_remove.items():
-        remove_entries_from_whitelist(filename, entries)
+        remove_entries_from_allowlist(filename, entries)
 
 
 def parse_input_file(input_file: str) -> Dict[str, Set[str]]:
@@ -37,7 +37,7 @@ def parse_input_line(line: str) -> Tuple[str, str]:
     return filename, entry
 
 
-def remove_entries_from_whitelist(filename: str, entries: Set[str]) -> None:
+def remove_entries_from_allowlist(filename: str, entries: Set[str]) -> None:
     new_lines: List[str] = []
     with open(filename) as f:
         for line in f:


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -112,4 +112,4 @@ jobs:
       - name: Install dependencies
         run: pip install $(grep mypy== requirements-tests-py3.txt)
       - name: Run stubtest
-        run: python tests/stubtest_test.py --ignore-unused-whitelist
+        run: python tests/stubtest_test.py --ignore-unused-allowlist
diff --git a/tests/README.md b/tests/README.md
--- a/tests/README.md
+++ b/tests/README.md
@@ -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
diff --git a/tests/stubtest_whitelists/darwin-py310.txt b/tests/stubtest_allowlists/darwin-py310.txt
similarity index 100%
rename from tests/stubtest_whitelists/darwin-py310.txt
rename to tests/stubtest_allowlists/darwin-py310.txt
diff --git a/tests/stubtest_whitelists/darwin-py36.txt b/tests/stubtest_allowlists/darwin-py36.txt
similarity index 100%
rename from tests/stubtest_whitelists/darwin-py36.txt
rename to tests/stubtest_allowlists/darwin-py36.txt
diff --git a/tests/stubtest_whitelists/darwin-py37.txt b/tests/stubtest_allowlists/darwin-py37.txt
similarity index 100%
rename from tests/stubtest_whitelists/darwin-py37.txt
rename to tests/stubtest_allowlists/darwin-py37.txt
diff --git a/tests/stubtest_whitelists/darwin-py38.txt b/tests/stubtest_allowlists/darwin-py38.txt
similarity index 100%
rename from tests/stubtest_whitelists/darwin-py38.txt
rename to tests/stubtest_allowlists/darwin-py38.txt
diff --git a/tests/stubtest_whitelists/darwin-py39.txt b/tests/stubtest_allowlists/darwin-py39.txt
similarity index 100%
rename from tests/stubtest_whitelists/darwin-py39.txt
rename to tests/stubtest_allowlists/darwin-py39.txt
diff --git a/tests/stubtest_whitelists/darwin.txt b/tests/stubtest_allowlists/darwin.txt
similarity index 96%
rename from tests/stubtest_whitelists/darwin.txt
rename to tests/stubtest_allowlists/darwin.txt
--- a/tests/stubtest_whitelists/darwin.txt
+++ b/tests/stubtest_allowlists/darwin.txt
@@ -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
diff --git a/tests/stubtest_whitelists/linux-py310.txt b/tests/stubtest_allowlists/linux-py310.txt
similarity index 100%
rename from tests/stubtest_whitelists/linux-py310.txt
rename to tests/stubtest_allowlists/linux-py310.txt
diff --git a/tests/stubtest_whitelists/linux-py36.txt b/tests/stubtest_allowlists/linux-py36.txt
similarity index 100%
rename from tests/stubtest_whitelists/linux-py36.txt
rename to tests/stubtest_allowlists/linux-py36.txt
diff --git a/tests/stubtest_whitelists/linux-py37.txt b/tests/stubtest_allowlists/linux-py37.txt
similarity index 100%
rename from tests/stubtest_whitelists/linux-py37.txt
rename to tests/stubtest_allowlists/linux-py37.txt
diff --git a/tests/stubtest_whitelists/linux-py38.txt b/tests/stubtest_allowlists/linux-py38.txt
similarity index 100%
rename from tests/stubtest_whitelists/linux-py38.txt
rename to tests/stubtest_allowlists/linux-py38.txt
diff --git a/tests/stubtest_whitelists/linux-py39.txt b/tests/stubtest_allowlists/linux-py39.txt
similarity index 100%
rename from tests/stubtest_whitelists/linux-py39.txt
rename to tests/stubtest_allowlists/linux-py39.txt
diff --git a/tests/stubtest_whitelists/linux.txt b/tests/stubtest_allowlists/linux.txt
similarity index 96%
rename from tests/stubtest_whitelists/linux.txt
rename to tests/stubtest_allowlists/linux.txt
--- a/tests/stubtest_whitelists/linux.txt
+++ b/tests/stubtest_allowlists/linux.txt
@@ -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
diff --git a/tests/stubtest_whitelists/py310.txt b/tests/stubtest_allowlists/py310.txt
similarity index 100%
rename from tests/stubtest_whitelists/py310.txt
rename to tests/stubtest_allowlists/py310.txt
diff --git a/tests/stubtest_whitelists/py36.txt b/tests/stubtest_allowlists/py36.txt
similarity index 100%
rename from tests/stubtest_whitelists/py36.txt
rename to tests/stubtest_allowlists/py36.txt
diff --git a/tests/stubtest_whitelists/py37.txt b/tests/stubtest_allowlists/py37.txt
similarity index 100%
rename from tests/stubtest_whitelists/py37.txt
rename to tests/stubtest_allowlists/py37.txt
diff --git a/tests/stubtest_whitelists/py38.txt b/tests/stubtest_allowlists/py38.txt
similarity index 100%
rename from tests/stubtest_whitelists/py38.txt
rename to tests/stubtest_allowlists/py38.txt
diff --git a/tests/stubtest_whitelists/py39.txt b/tests/stubtest_allowlists/py39.txt
similarity index 100%
rename from tests/stubtest_whitelists/py39.txt
rename to tests/stubtest_allowlists/py39.txt
diff --git a/tests/stubtest_whitelists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt
similarity index 99%
rename from tests/stubtest_whitelists/py3_common.txt
rename to tests/stubtest_allowlists/py3_common.txt
--- a/tests/stubtest_whitelists/py3_common.txt
+++ b/tests/stubtest_allowlists/py3_common.txt
@@ -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
diff --git a/tests/stubtest_whitelists/win32-py310.txt b/tests/stubtest_allowlists/win32-py310.txt
similarity index 100%
rename from tests/stubtest_whitelists/win32-py310.txt
rename to tests/stubtest_allowlists/win32-py310.txt
diff --git a/tests/stubtest_whitelists/win32-py36.txt b/tests/stubtest_allowlists/win32-py36.txt
similarity index 100%
rename from tests/stubtest_whitelists/win32-py36.txt
rename to tests/stubtest_allowlists/win32-py36.txt
diff --git a/tests/stubtest_whitelists/win32-py37.txt b/tests/stubtest_allowlists/win32-py37.txt
similarity index 100%
rename from tests/stubtest_whitelists/win32-py37.txt
rename to tests/stubtest_allowlists/win32-py37.txt
diff --git a/tests/stubtest_whitelists/win32-py38.txt b/tests/stubtest_allowlists/win32-py38.txt
similarity index 100%
rename from tests/stubtest_whitelists/win32-py38.txt
rename to tests/stubtest_allowlists/win32-py38.txt
diff --git a/tests/stubtest_whitelists/win32.txt b/tests/stubtest_allowlists/win32.txt
similarity index 91%
rename from tests/stubtest_whitelists/win32.txt
rename to tests/stubtest_allowlists/win32.txt
--- a/tests/stubtest_whitelists/win32.txt
+++ b/tests/stubtest_allowlists/win32.txt
@@ -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
diff --git a/tests/stubtest_test.py b/tests/stubtest_test.py
--- a/tests/stubtest_test.py
+++ b/tests/stubtest_test.py
@@ -16,40 +16,40 @@
 
 
 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
diff --git a/tests/stubtest_unused.py b/tests/stubtest_unused.py
--- a/tests/stubtest_unused.py
+++ b/tests/stubtest_unused.py
@@ -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