Skip to content

Commit fc7a544

Browse files
authored
Rename requires to dependencies in METADATA files (#15594)
1 parent 8b31f26 commit fc7a544

File tree

70 files changed

+97
-97
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+97
-97
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ supported:
163163
When the stubs are updated to a newer version
164164
of the library, the version of the stub should be bumped (note that
165165
previous versions are still available on PyPI).
166-
* `requires` (optional): A list of other stub packages or packages with type
166+
* `dependencies` (optional): A list of other stub packages or packages with type
167167
information that are imported by the stubs in this package. Only packages
168168
generated by typeshed or required by the upstream package are allowed to
169169
be listed here, for security reasons. See
@@ -202,9 +202,9 @@ This has the following keys:
202202
`--ignore_missing_stub` option to the stubtest call. See
203203
[tests/README.md](./tests/README.md) for more information. In most cases,
204204
this field should be identical to `partial_stub`.
205-
* `stubtest_requirements` (default: `[]`): A list of Python packages that need
205+
* `stubtest_dependencies` (default: `[]`): A list of Python packages that need
206206
to be installed for stubtest to run successfully. These packages are installed
207-
in addition to the requirements in the `requires` field.
207+
in addition to the dependencies in the `dependencies` field.
208208
* `apt_dependencies` (default: `[]`): A list of Ubuntu APT packages
209209
that need to be installed for stubtest to run successfully.
210210
* `brew_dependencies` (default: `[]`): A list of MacOS Homebrew packages

lib/ts_utils/metadata.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class StubtestSettings:
8484
ignore_missing_stub: bool
8585
supported_platforms: list[str] | None # None means all platforms
8686
ci_platforms: list[str]
87-
stubtest_requirements: list[str]
87+
stubtest_dependencies: list[str]
8888
mypy_plugins: list[str]
8989
mypy_plugins_config: dict[str, dict[str, Any]]
9090

@@ -109,7 +109,7 @@ def read_stubtest_settings(distribution: str) -> StubtestSettings:
109109
ignore_missing_stub: object = data.get("ignore_missing_stub", False)
110110
supported_platforms: object = data.get("supported_platforms")
111111
ci_platforms: object = data.get("ci_platforms", DEFAULT_STUBTEST_PLATFORMS)
112-
stubtest_requirements: object = data.get("stubtest_requirements", [])
112+
stubtest_dependencies: object = data.get("stubtest_dependencies", [])
113113
mypy_plugins: object = data.get("mypy_plugins", [])
114114
mypy_plugins_config: object = data.get("mypy_plugins_config", {})
115115

@@ -123,7 +123,7 @@ def read_stubtest_settings(distribution: str) -> StubtestSettings:
123123
assert _is_list_of_strings(brew_dependencies)
124124
assert _is_list_of_strings(choco_dependencies)
125125
assert _is_list_of_strings(extras)
126-
assert _is_list_of_strings(stubtest_requirements)
126+
assert _is_list_of_strings(stubtest_dependencies)
127127
assert _is_list_of_strings(mypy_plugins)
128128
assert _is_nested_dict(mypy_plugins_config)
129129

@@ -151,7 +151,7 @@ def read_stubtest_settings(distribution: str) -> StubtestSettings:
151151
ignore_missing_stub=ignore_missing_stub,
152152
supported_platforms=supported_platforms,
153153
ci_platforms=ci_platforms,
154-
stubtest_requirements=stubtest_requirements,
154+
stubtest_dependencies=stubtest_dependencies,
155155
mypy_plugins=mypy_plugins,
156156
mypy_plugins_config=mypy_plugins_config,
157157
)
@@ -174,7 +174,7 @@ class StubMetadata:
174174

175175
distribution: Annotated[str, "The name of the distribution on PyPI"]
176176
version_spec: Annotated[Specifier, "Upstream versions that the stubs are compatible with"]
177-
requires: Annotated[list[Requirement], "The parsed requirements as listed in METADATA.toml"]
177+
dependencies: Annotated[list[Requirement], "The parsed dependencies as listed in METADATA.toml"]
178178
extra_description: str | None
179179
stub_distribution: Annotated[str, "The name under which the distribution is uploaded to PyPI"]
180180
upstream_repository: Annotated[str, "The URL of the upstream repository"] | None
@@ -193,7 +193,7 @@ def is_obsolete(self) -> bool:
193193
_KNOWN_METADATA_FIELDS: Final = frozenset(
194194
{
195195
"version",
196-
"requires",
196+
"dependencies",
197197
"extra_description",
198198
"stub_distribution",
199199
"upstream_repository",
@@ -216,7 +216,7 @@ def is_obsolete(self) -> bool:
216216
"ignore_missing_stub",
217217
"supported_platforms",
218218
"ci_platforms",
219-
"stubtest_requirements",
219+
"stubtest_dependencies",
220220
"mypy_plugins",
221221
"mypy_plugins_config",
222222
}
@@ -235,7 +235,7 @@ def read_metadata(distribution: str) -> StubMetadata:
235235
This function does some basic validation,
236236
but does no parsing, transforming or normalization of the metadata.
237237
Use `read_dependencies` if you need to parse the dependencies
238-
given in the `requires` field, for example.
238+
given in the `dependencies` field, for example.
239239
"""
240240
try:
241241
with metadata_path(distribution).open("rb") as f:
@@ -255,9 +255,9 @@ def read_metadata(distribution: str) -> StubMetadata:
255255
version_spec = Specifier(version)
256256
assert version_spec.operator in {"==", "~="}, f"Invalid 'version' field in METADATA.toml for {distribution!r}"
257257

258-
requires_s: object = data.get("requires", []) # pyright: ignore[reportUnknownMemberType]
259-
assert isinstance(requires_s, list)
260-
requires = [parse_requires(distribution, req) for req in requires_s]
258+
dependencies_s: object = data.get("dependencies", []) # pyright: ignore[reportUnknownMemberType]
259+
assert isinstance(dependencies_s, list)
260+
dependencies = [parse_dependencies(distribution, dep) for dep in dependencies_s]
261261

262262
extra_description: object = data.get("extra_description") # pyright: ignore[reportUnknownMemberType]
263263
assert isinstance(extra_description, (str, type(None)))
@@ -336,7 +336,7 @@ def read_metadata(distribution: str) -> StubMetadata:
336336
return StubMetadata(
337337
distribution=distribution,
338338
version_spec=version_spec,
339-
requires=requires,
339+
dependencies=dependencies,
340340
extra_description=extra_description,
341341
stub_distribution=stub_distribution,
342342
upstream_repository=upstream_repository,
@@ -366,7 +366,7 @@ def update_metadata(distribution: str, **new_values: object) -> tomlkit.TOMLDocu
366366
return data
367367

368368

369-
def parse_requires(distribution: str, req: object) -> Requirement:
369+
def parse_dependencies(distribution: str, req: object) -> Requirement:
370370
assert isinstance(req, str), f"Invalid requirement {req!r} for {distribution!r}"
371371
return Requirement(req)
372372

@@ -398,7 +398,7 @@ def read_dependencies(distribution: str) -> PackageDependencies:
398398
pypi_name_to_typeshed_name_mapping = get_pypi_name_to_typeshed_name_mapping()
399399
typeshed: list[Requirement] = []
400400
external: list[Requirement] = []
401-
for dependency in read_metadata(distribution).requires:
401+
for dependency in read_metadata(distribution).dependencies:
402402
if dependency.name in pypi_name_to_typeshed_name_mapping:
403403
req = Requirement(str(dependency)) # copy the requirement
404404
req.name = pypi_name_to_typeshed_name_mapping[dependency.name]

stubs/Authlib/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version = "1.6.9"
22
upstream_repository = "https://github.com/authlib/authlib"
3-
requires = ["cryptography"]
3+
dependencies = ["cryptography"]

stubs/Deprecated/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version = "~=1.3.1"
22
upstream_repository = "https://github.com/laurent-laporte-pro/deprecated"
3-
requires = []
3+
dependencies = []

stubs/Flask-Cors/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
version = "6.0.*"
22
upstream_repository = "https://github.com/corydolphin/flask-cors"
33
# Requires a version of flask with a `py.typed` file
4-
requires = ["Flask>=2.0.0"]
4+
dependencies = ["Flask>=2.0.0"]

stubs/Flask-Migrate/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
version = "4.1.*"
22
upstream_repository = "https://github.com/miguelgrinberg/Flask-Migrate"
33
# Requires versions of flask and Flask-SQLAlchemy with `py.typed` files
4-
requires = ["Flask-SQLAlchemy>=3.0.1", "Flask>=2.0.0"]
4+
dependencies = ["Flask-SQLAlchemy>=3.0.1", "Flask>=2.0.0"]

stubs/Flask-SocketIO/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version = "5.6.*"
2-
requires = ["Flask>=0.9"]
2+
dependencies = ["Flask>=0.9"]
33
upstream_repository = "https://github.com/miguelgrinberg/flask-socketio"

stubs/JACK-Client/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version = "0.5.*"
22
upstream_repository = "https://github.com/spatialaudio/jackclient-python"
33
# Requires a version of numpy with a `py.typed` file
4-
requires = ["numpy>=1.20", "types-cffi"]
4+
dependencies = ["numpy>=1.20", "types-cffi"]
55

66
[tool.stubtest]
77
# darwin and win32 are equivalent

stubs/PyAutoGUI/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version = "0.9.*"
22
upstream_repository = "https://github.com/asweigart/pyautogui"
3-
requires = ["types-PyScreeze"]
3+
dependencies = ["types-PyScreeze"]

stubs/PyScreeze/METADATA.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
version = "1.0.1"
22
upstream_repository = "https://github.com/asweigart/pyscreeze"
3-
requires = ["Pillow>=10.3.0"]
3+
dependencies = ["Pillow>=10.3.0"]
44

55
[tool.stubtest]
66
# Linux has extra constants, win32 has different definitions
77
ci_platforms = ["linux", "win32"]
88
# PyScreeze has an odd setup.py file
99
# that doesn't list Pillow as a dependency for py312+ yet:
1010
# https://github.com/asweigart/pyscreeze/blob/eeca245a135cf171c163b3691300138518efa64e/setup.py#L38-L46
11-
stubtest_requirements = ["Pillow"]
11+
stubtest_dependencies = ["Pillow"]

0 commit comments

Comments
 (0)