mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
Integrate requirements-stubtest.txt into METADATA.toml (#9778)
This commit is contained in:
3
.github/workflows/daily.yml
vendored
3
.github/workflows/daily.yml
vendored
@@ -36,7 +36,7 @@ jobs:
|
||||
matrix:
|
||||
# tkinter doesn't import on macOS-12
|
||||
os: ["ubuntu-latest", "windows-latest", "macos-11"]
|
||||
python-version: ["3.7", "3.8", "3.9", "3.10.10", "3.11.2"] # TODO: unpin micro versions
|
||||
python-version: ["3.7", "3.8", "3.9", "3.10.10", "3.11.2"] # TODO: unpin micro versions
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
@@ -69,7 +69,6 @@ jobs:
|
||||
cache: pip
|
||||
cache-dependency-path: |
|
||||
requirements-tests.txt
|
||||
stubs/**/@tests/requirements-stubtest.txt
|
||||
stubs/**/METADATA.toml
|
||||
- name: Install dependencies
|
||||
run: pip install -r requirements-tests.txt
|
||||
|
||||
1
.github/workflows/stubtest_third_party.yml
vendored
1
.github/workflows/stubtest_third_party.yml
vendored
@@ -45,7 +45,6 @@ jobs:
|
||||
cache: pip
|
||||
cache-dependency-path: |
|
||||
requirements-tests.txt
|
||||
stubs/**/@tests/requirements-stubtest.txt
|
||||
stubs/**/METADATA.toml
|
||||
- name: Install dependencies
|
||||
run: pip install -r requirements-tests.txt
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
olefile
|
||||
@@ -1,4 +1,4 @@
|
||||
# Requires Pyside or PyQt to be installed.
|
||||
# Not worth adding to requirements-stubtest.txt
|
||||
# Not worth adding to tool.stubtest.stubtest_requirements
|
||||
# because it's only used as a base type and it's a long install.
|
||||
PIL.ImageQt.ImageQt
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
version = "9.4.*"
|
||||
|
||||
[tool.stubtest]
|
||||
stubtest_requirements = ["olefile"]
|
||||
ignore_missing_stub = true
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
sphinx
|
||||
@@ -2,4 +2,5 @@ version = "2.14.*"
|
||||
requires = ["types-docutils", "types-setuptools"]
|
||||
|
||||
[tool.stubtest]
|
||||
stubtest_requirements = ["sphinx"]
|
||||
ignore_missing_stub = true
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
pytest
|
||||
@@ -6,4 +6,5 @@ extra_description = """\
|
||||
obsolete_since = "2.0.0" # Released on 2023-01-26
|
||||
|
||||
[tool.stubtest]
|
||||
stubtest_requirements = ["pytest"]
|
||||
ignore_missing_stub = true
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
cryptography
|
||||
@@ -1,2 +1,5 @@
|
||||
version = "2.6.1"
|
||||
requires = ["types-Pillow>=9.2.0"]
|
||||
|
||||
[tool.stubtest]
|
||||
stubtest_requirements = ["cryptography"]
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
protobuf==3.20.2
|
||||
@@ -1,4 +1,5 @@
|
||||
version = "2.1.*"
|
||||
|
||||
[tool.stubtest]
|
||||
stubtest_requirements = ["protobuf==3.20.2"]
|
||||
ignore_missing_stub = true
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
docutils
|
||||
mock
|
||||
@@ -1 +1,4 @@
|
||||
version = "10.0.*"
|
||||
|
||||
[tool.stubtest]
|
||||
stubtest_requirements = ["docutils", "mock"]
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
aiohttp
|
||||
@@ -3,3 +3,4 @@ requires = ["types-urllib3"]
|
||||
|
||||
[tool.stubtest]
|
||||
extras = ["extra"]
|
||||
stubtest_requirements = ["aiohttp"]
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
gssapi
|
||||
@@ -7,3 +7,4 @@ apt_dependencies = ["libkrb5-dev"]
|
||||
# No need to install on the CI. Leaving here as information for MacOs/Windows contributors.
|
||||
# brew_dependencies = ["krb5"]
|
||||
# choco_dependencies = ["mitkerberos"]
|
||||
stubtest_requirements = ["gssapi"]
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
dask
|
||||
pandas
|
||||
rich
|
||||
tensorflow
|
||||
@@ -2,3 +2,4 @@ version = "4.64.*"
|
||||
|
||||
[tool.stubtest]
|
||||
extras = ["slack", "telegram"]
|
||||
stubtest_requirements = ["dask", "pandas", "rich", "tensorflow"]
|
||||
|
||||
@@ -162,7 +162,7 @@ directly, with
|
||||
|
||||
For each distribution, stubtest ignores definitions listed in a `@tests/stubtest_allowlist.txt` file,
|
||||
relative to the distribution. Additional packages that are needed to run stubtest for a
|
||||
distribution can be added to `@tests/requirements-stubtest.txt`.
|
||||
distribution can be added to `tool.stubtest.stubtest_requirements` in `METADATA.toml`.
|
||||
|
||||
### Using stubtest to find objects missing from the stubs
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ class StubtestSettings:
|
||||
extras: list[str]
|
||||
ignore_missing_stub: bool
|
||||
platforms: list[str]
|
||||
stubtest_requirements: list[str]
|
||||
|
||||
def system_requirements_for_platform(self, platform: str) -> list[str]:
|
||||
assert platform in _STUBTEST_PLATFORM_MAPPING, f"Unrecognised platform {platform!r}"
|
||||
@@ -69,6 +70,7 @@ def read_stubtest_settings(distribution: str) -> StubtestSettings:
|
||||
extras = data.get("extras", [])
|
||||
ignore_missing_stub = data.get("ignore_missing_stub", False)
|
||||
specified_platforms = data.get("platforms", ["linux"])
|
||||
stubtest_requirements = data.get("stubtest_requirements", [])
|
||||
|
||||
assert type(skipped) is bool
|
||||
assert type(ignore_missing_stub) is bool
|
||||
@@ -79,6 +81,7 @@ def read_stubtest_settings(distribution: str) -> StubtestSettings:
|
||||
assert _is_list_of_strings(brew_dependencies)
|
||||
assert _is_list_of_strings(choco_dependencies)
|
||||
assert _is_list_of_strings(extras)
|
||||
assert _is_list_of_strings(stubtest_requirements)
|
||||
|
||||
unrecognised_platforms = set(specified_platforms) - _STUBTEST_PLATFORM_MAPPING.keys()
|
||||
assert not unrecognised_platforms, f"Unrecognised platforms specified for {distribution!r}: {unrecognised_platforms}"
|
||||
@@ -98,6 +101,7 @@ def read_stubtest_settings(distribution: str) -> StubtestSettings:
|
||||
extras=extras,
|
||||
ignore_missing_stub=ignore_missing_stub,
|
||||
platforms=specified_platforms,
|
||||
stubtest_requirements=stubtest_requirements,
|
||||
)
|
||||
|
||||
|
||||
@@ -131,6 +135,7 @@ _KNOWN_METADATA_TOOL_FIELDS: Final = {
|
||||
"extras",
|
||||
"ignore_missing_stub",
|
||||
"platforms",
|
||||
"stubtest_requirements",
|
||||
}
|
||||
}
|
||||
_DIST_NAME_RE: Final = re.compile(r"^[a-z0-9]([a-z0-9._-]*[a-z0-9])?$", re.IGNORECASE)
|
||||
|
||||
@@ -41,10 +41,9 @@ def run_stubtest(dist: Path, *, verbose: bool = False, specified_stubs_only: boo
|
||||
dist_extras = ", ".join(stubtest_settings.extras)
|
||||
dist_req = f"{dist_name}[{dist_extras}]=={metadata.version}"
|
||||
|
||||
# If @tests/requirements-stubtest.txt exists, run "pip install" on it.
|
||||
req_path = dist / "@tests" / "requirements-stubtest.txt"
|
||||
if req_path.exists():
|
||||
pip_cmd = [pip_exe, "install", "-r", str(req_path)]
|
||||
# If tool.stubtest.stubtest_requirements exists, run "pip install" on it.
|
||||
if stubtest_settings.stubtest_requirements:
|
||||
pip_cmd = [pip_exe, "install"] + stubtest_settings.stubtest_requirements
|
||||
try:
|
||||
subprocess.run(pip_cmd, check=True, capture_output=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
|
||||
Reference in New Issue
Block a user