mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
Allow the use of local-only stubtest allowlists (#11173)
This makes it nicer to work on a local system with known divergences from the CI environment
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -71,3 +71,6 @@ analyze.py
|
||||
|
||||
# pyenv local python version
|
||||
.python-version
|
||||
|
||||
# deliberately local test configuration files
|
||||
tests/stubtest_allowlists/*.local
|
||||
|
||||
0
scripts/runtests.py
Normal file → Executable file
0
scripts/runtests.py
Normal file → Executable file
@@ -133,6 +133,12 @@ test it automatically (or
|
||||
[running the test via Github Actions](https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow#running-a-workflow)
|
||||
on your typeshed fork).
|
||||
|
||||
As a convenience, stubtest\_stdlib.py will look for local-only allowlist files
|
||||
and use those if they are present. Only version-specific local allowlists are supported.
|
||||
An example local allowlist file is
|
||||
`tests/stubtest_allowlists/py312.txt.local`. Use caution when taking advantage of this feature;
|
||||
the CI run of stubtest remains canonical.
|
||||
|
||||
If you need a specific version of Python to repro a CI failure,
|
||||
[pyenv](https://github.com/pyenv/pyenv) can also help.
|
||||
|
||||
|
||||
@@ -66,4 +66,5 @@ def main() -> None:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
assert sys.version_info >= (3, 9), "Python 3.9+ is required to run this test"
|
||||
main()
|
||||
|
||||
@@ -18,6 +18,7 @@ def run_stubtest(typeshed_dir: Path) -> int:
|
||||
version_allowlist = f"py{sys.version_info.major}{sys.version_info.minor}.txt"
|
||||
platform_allowlist = f"{sys.platform}.txt"
|
||||
combined_allowlist = f"{sys.platform}-py{sys.version_info.major}{sys.version_info.minor}.txt"
|
||||
local_version_allowlist = version_allowlist + ".local"
|
||||
|
||||
# Note when stubtest imports distutils, it will likely actually import setuptools._distutils
|
||||
# This is fine because we don't care about distutils and allowlist all errors from it
|
||||
@@ -39,6 +40,8 @@ def run_stubtest(typeshed_dir: Path) -> int:
|
||||
cmd += ["--allowlist", str(allowlist_dir / platform_allowlist)]
|
||||
if (allowlist_dir / combined_allowlist).exists():
|
||||
cmd += ["--allowlist", str(allowlist_dir / combined_allowlist)]
|
||||
if (allowlist_dir / local_version_allowlist).exists():
|
||||
cmd += ["--allowlist", str(allowlist_dir / local_version_allowlist)]
|
||||
if sys.version_info < (3, 10):
|
||||
# As discussed in https://github.com/python/typeshed/issues/3693, we only aim for
|
||||
# positional-only arg accuracy for python 3.10 and above.
|
||||
|
||||
Reference in New Issue
Block a user