Skip to content

feat: Support extras in stubtest_third_party.py #8467

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 8 commits into from
Aug 18, 2022
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: 0 additions & 2 deletions stubs/beautifulsoup4/@tests/requirements-stubtest.txt

This file was deleted.

3 changes: 3 additions & 0 deletions stubs/beautifulsoup4/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
version = "4.11.*"

[tool.stubtest]
extras = ["lxml", "html5lib"]
2 changes: 0 additions & 2 deletions stubs/html5lib/@tests/requirements-stubtest.txt

This file was deleted.

3 changes: 3 additions & 0 deletions stubs/html5lib/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
version = "1.1.*"

[tool.stubtest]
extras = ["all"]
1 change: 0 additions & 1 deletion stubs/requests/@tests/requirements-stubtest.txt

This file was deleted.

3 changes: 3 additions & 0 deletions stubs/requests/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
version = "2.28.*"
requires = ["types-urllib3<1.27"] # keep in sync with requests's setup.py

[tool.stubtest]
extras = ["socks"]
2 changes: 0 additions & 2 deletions stubs/tqdm/@tests/requirements-stubtest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ tensorflow
pandas
dask
rich
requests
slack-sdk
3 changes: 3 additions & 0 deletions stubs/tqdm/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
version = "4.64.*"

[tool.stubtest]
extras = ["slack", "telegram"]
1 change: 0 additions & 1 deletion stubs/urllib3/@tests/requirements-stubtest.txt

This file was deleted.

3 changes: 3 additions & 0 deletions stubs/urllib3/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
version = "1.26.*"

[tool.stubtest]
extras = ["socks"]
2 changes: 1 addition & 1 deletion tests/check_consistent.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from packaging.version import Version

metadata_keys = {"version", "requires", "extra_description", "obsolete_since", "no_longer_updated", "tool"}
tool_keys = {"stubtest": {"skip", "apt_dependencies", "ignore_missing_stub"}}
tool_keys = {"stubtest": {"skip", "apt_dependencies", "extras", "ignore_missing_stub"}}
allowed_files = {"README.md"}


Expand Down
5 changes: 4 additions & 1 deletion tests/stubtest_third_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool:
python_exe = str(venv_dir / "bin" / "python")

dist_version = metadata["version"]
extras = stubtest_meta.get("extras", [])
assert isinstance(dist_version, str)
dist_req = f"{dist.name}=={dist_version}"
assert isinstance(extras, list)
dist_extras = ", ".join(extras)
dist_req = f"{dist.name}[{dist_extras}]=={dist_version}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, didn't realise this, but pip install pkg[] does work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, as long as you conform to the structure, the behavior will work. It's only if you break the calling structure that it fails to execute :)


# If @tests/requirements-stubtest.txt exists, run "pip install" on it.
req_path = dist / "@tests" / "requirements-stubtest.txt"
Expand Down