Add partial_stub metadata field (#10157)

This commit is contained in:
Avasam
2023-05-10 11:04:18 -04:00
committed by GitHub
parent ff700e1b95
commit db0149859c
51 changed files with 68 additions and 1 deletions

View File

@@ -193,6 +193,10 @@ supported:
* `upload` (optional): This field is set to `false` to prevent automatic
uploads to PyPI. This should only used in special cases, e.g. when the stubs
break the upload.
* `partial_stub` (optional): This field marks the type stub package as
[partial](https://peps.python.org/pep-0561/#partial-stub-packages). This is for
3rd-party stubs that don't cover the entirety of the package's public API.
In most cases, this field is identical to `ignore_missing_stub`.
In addition, we specify configuration for stubtest in the `tool.stubtest` table.
This has the following keys:

View File

@@ -1,6 +1,7 @@
version = "3.0.*"
# Requires a version of flask with a `py.typed` file
requires = ["Flask>=2.0.0"]
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,6 +1,7 @@
version = "4.0.*"
# Requires a version of flask with a `py.typed` file
requires = ["Flask>=2.0.0", "types-Flask-SQLAlchemy"]
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,6 +1,7 @@
version = "2.5.*"
requires = ["types-SQLAlchemy"]
obsolete_since = "3.0.1" # Released on 2022-10-11
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "3.4.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "9.5.*"
partial_stub = true
[tool.stubtest]
stubtest_requirements = ["olefile"]

View File

@@ -1,4 +1,5 @@
version = "1.0.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,5 +1,6 @@
version = "2.15.*"
requires = ["types-docutils", "types-setuptools"]
partial_stub = true
[tool.stubtest]
stubtest_requirements = ["sphinx"]

View File

@@ -1,4 +1,5 @@
version = "1.8.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "2.12.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,6 +1,7 @@
version = "2.11.*"
requires = ["types-pytz"]
obsolete_since = "2.12.1" # Released on 2023-02-28
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,5 +1,6 @@
version = "4.12.*"
requires = ["types-html5lib"]
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "6.0.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,5 +1,6 @@
version = "2.49.*"
requires = []
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "4.19.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,6 +1,7 @@
version = "1.2.*"
# also types-lxml and types-icalendar when those stubs are added
requires = ["types-requests", "types-vobject"]
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,5 +1,6 @@
version = "5.0.*"
obsolete_since = "5.1.0" # Released on 2022-12-01
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "0.9.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "0.20.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "23.5.9"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "2.1.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "1.7.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "1.3.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "0.3.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "0.20.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "1.14.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "2.1.*"
partial_stub = true
[tool.stubtest]
stubtest_requirements = ["protobuf==3.20.2"]

View File

@@ -1,4 +1,5 @@
version = "1.1.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "2.0.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "4.17.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,5 +1,6 @@
version = "2.9.*"
requires = ["types-pyasn1"]
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "3.2.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "3.1.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "2.4.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,6 +1,7 @@
version = "3.0.*"
# Requires a version of cryptography where cryptography.hazmat.primitives.ciphers.Cipher is generic
requires = ["cryptography>=37.0.0"]
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "0.13.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,5 +1,6 @@
version = "4.23.*"
extra_description = "Generated with aid from mypy-protobuf v3.4.0"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "2.9.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,6 +1,7 @@
version = "23.1.*"
# Requires a version of cryptography with a `py.typed` file
requires = ["cryptography>=35.0.0"]
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "3.0.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,6 +1,7 @@
version = "1.5.*"
# Requires a version of arrow with a `py.typed` file
requires = ["arrow>=1.0.1"]
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "2.8.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,5 +1,6 @@
version = "8.0.0.*"
obsolete_since = "8.0.1.0" # Released on 2023-05-05
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,6 +1,7 @@
version = "4.5.5"
# Requires a version of cryptography with a `py.typed` file
requires = ["cryptography>=35.0.0", "types-pyOpenSSL"]
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "67.7.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "3.19.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,4 +1,5 @@
version = "3.5.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,6 +1,7 @@
version = "2.12.*"
# requires a version of numpy with a `py.typed` file
requires = ["numpy>=1.20", "types-protobuf"]
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,5 +1,6 @@
version = "1.26.*"
obsolete_since = "2.0.0" # Released on 2023-04-26
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -1,5 +1,6 @@
version = "2.1.*"
requires = []
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true

View File

@@ -123,11 +123,22 @@ class StubMetadata:
obsolete_since: Annotated[str, "A string representing a specific version"] | None
no_longer_updated: bool
uploaded_to_pypi: Annotated[bool, "Whether or not a distribution is uploaded to PyPI"]
partial_stub: Annotated[bool, "Whether this is a partial type stub package as per PEP 561."]
stubtest_settings: StubtestSettings
_KNOWN_METADATA_FIELDS: Final = frozenset(
{"version", "requires", "extra_description", "stub_distribution", "obsolete_since", "no_longer_updated", "upload", "tool"}
{
"version",
"requires",
"extra_description",
"stub_distribution",
"obsolete_since",
"no_longer_updated",
"upload",
"tool",
"partial_stub",
}
)
_KNOWN_METADATA_TOOL_FIELDS: Final = {
"stubtest": {
@@ -190,6 +201,8 @@ def read_metadata(distribution: str) -> StubMetadata:
assert type(no_longer_updated) is bool
uploaded_to_pypi: object = data.get("upload", True)
assert type(uploaded_to_pypi) is bool
partial_stub: object = data.get("partial_stub", True)
assert type(partial_stub) is bool
empty_tools: dict[object, object] = {}
tools_settings: object = data.get("tool", empty_tools)
@@ -209,6 +222,7 @@ def read_metadata(distribution: str) -> StubMetadata:
obsolete_since=obsolete_since,
no_longer_updated=no_longer_updated,
uploaded_to_pypi=uploaded_to_pypi,
partial_stub=partial_stub,
stubtest_settings=read_stubtest_settings(distribution),
)