Skip to content

Commit 7b032f4

Browse files
committed
🎨 use 88 as max line length for scipts/*.py
1 parent 73db95c commit 7b032f4

File tree

3 files changed

+60
-21
lines changed

3 files changed

+60
-21
lines changed

‎scripts/.ruff.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
extend = "../pyproject.toml"
2+
line-length = 88

‎scripts/generate_matrix.py

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
(Version("3.11"), Version("1.25")),
2020
(Version("3.12"), Version("1.26")),
2121
(Version("3.13"), Version("2.1")),
22-
) # fmt: skip
22+
)
2323

2424

2525
class UVPythonVersionParts(TypedDict):
@@ -81,7 +81,9 @@ def get_package_minimum_python_version(package: str) -> Version:
8181
"""
8282
raw_version = importlib.metadata.metadata(package)["Requires-Python"]
8383
if "<" in raw_version:
84-
raise NotImplementedError("Version specifier with upper bound not yet supported!")
84+
raise NotImplementedError(
85+
"Version specifier with upper bound not yet supported!"
86+
)
8587

8688
return parse(raw_version.replace(">=", "").replace("~=", ""))
8789

@@ -98,7 +100,8 @@ def get_dependency_minimum_version(package: str, dependency: str) -> Version:
98100
Version: The minimum required version of the dependency.
99101
100102
Raises:
101-
ValueError: If the package does not list any requirements or the dependency is not found.
103+
ValueError:
104+
The package does not list any requirements or the dependency is not found.
102105
103106
"""
104107
requirements = importlib.metadata.requires(package)
@@ -107,33 +110,49 @@ def get_dependency_minimum_version(package: str, dependency: str) -> Version:
107110

108111
try:
109112
# Find the first requirement that matches the dependency and is not an extra
110-
dependency_req = next(req for req in requirements if req.startswith(dependency) and " extra " not in req)
113+
dependency_req = next(
114+
req
115+
for req in requirements
116+
if req.startswith(dependency) and " extra " not in req
117+
)
111118
except StopIteration as e:
112-
raise ValueError(f"Dependency {dependency} not found in requirements for {package}") from e
119+
raise ValueError(
120+
f"Dependency {dependency} not found in requirements for {package}"
121+
) from e
113122

114123
# Extract the version specifier (e.g., ">=1.21.0")
115-
version_specifier = next((ver for ver in dependency_req.split(",") if ">" in ver), None)
124+
version_specifier = next(
125+
(ver for ver in dependency_req.split(",") if ">" in ver), None
126+
)
116127
if version_specifier is None:
117-
raise ValueError(f"No version specifier found for dependency {dependency} in {package}")
128+
raise ValueError(
129+
f"No version specifier found for dependency {dependency} in {package}"
130+
)
118131

119132
# Remove dependency name and comparison operator to get the version
120-
version_str = version_specifier.replace(dependency, "").replace(">=", "").replace(">", "")
133+
version_str = (
134+
version_specifier.replace(dependency, "").replace(">=", "").replace(">", "")
135+
)
121136
return parse(version_str)
122137

123138

124139
def get_available_python_versions(
125-
min_version: Version | None = None, max_version: Version | None = None, pre_releases: bool = False
140+
min_version: Version | None = None,
141+
max_version: Version | None = None,
142+
pre_releases: bool = False,
126143
) -> list[Version]:
127144
"""
128-
Get a list of available Python versions from GitHub Actions' Python Versions Manifest.
145+
Get a list of available Python versions from GitHub Actions' Python Versions
146+
Manifest.
129147
130148
Args:
131149
min_version (Version | None): The minimum Python version to include in the list.
132150
max_version (Version | None): The maximum Python version to include in the list.
133151
pre_releases (bool): Whether to include pre-release versions.
134152
135153
Returns:
136-
list[Version]: A list of available Python versions satisfying the specified criteria.
154+
list[Version]:
155+
A list of available Python versions satisfying the specified criteria.
137156
138157
Raises:
139158
urllib.error.URLError: If fetching data fails.
@@ -189,19 +208,22 @@ def fetch_json(url: str) -> Any:
189208
sys.exit(1)
190209

191210

192-
def get_available_package_versions(package_name: str, min_version: Version, pre_releases: bool = False) -> dict[Version, str]:
211+
def get_available_package_versions(
212+
package_name: str, min_version: Version, pre_releases: bool = False
213+
) -> dict[Version, str]:
193214
"""
194-
Get available package versions from PyPI starting from the specified minimum version,
195-
but only include the latest micro version within each minor version series,
215+
Get available package versions from PyPI starting from the specified minimum
216+
version, but only include the latest micro version within each minor version series,
196217
along with their 'requires_python' specifiers.
197218
198219
Args:
199220
package_name (str): The name of the package on PyPI.
200221
min_version (Version): The minimum version to include.
201222
202223
Returns:
203-
dict[Version, str]: A mapping from the latest package versions in each minor version
204-
series to their 'requires_python' specifier.
224+
dict[Version, str]:
225+
A mapping from the latest package versions in each minor version series to
226+
their 'requires_python' specifier.
205227
206228
Raises:
207229
RuntimeError: If no 'requires_python' is found for a package version.
@@ -268,7 +290,10 @@ def main() -> None:
268290
continue
269291

270292
# Skip incompatible combinations
271-
if any(py_version >= py_min and np_version < np_min for py_min, np_min in MIN_VERSIONS):
293+
if any(
294+
py_version >= py_min and np_version < np_min
295+
for py_min, np_min in MIN_VERSIONS
296+
):
272297
continue
273298

274299
matrix_entries.append({

‎scripts/unstubbed_modules.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@
1111

1212
import scipy
1313

14-
BUNDLED = "scipy._lib.array_api_compat", "scipy._lib.array_api_extra", "scipy.fft._pocketfft"
14+
BUNDLED = (
15+
"scipy._lib.array_api_compat",
16+
"scipy._lib.array_api_extra",
17+
"scipy.fft._pocketfft",
18+
)
1519

1620

17-
def modules(mod: types.ModuleType, _seen: set[types.ModuleType] | None = None) -> list[str]:
21+
def modules(
22+
mod: types.ModuleType, _seen: set[types.ModuleType] | None = None
23+
) -> list[str]:
1824
seen = _seen or set()
1925
out: list[str] = []
2026

@@ -28,7 +34,11 @@ def modules(mod: types.ModuleType, _seen: set[types.ModuleType] | None = None) -
2834
mod_vars |= vars(mod)
2935

3036
for k, v in mod_vars.items():
31-
if isinstance(v, types.ModuleType) and v not in seen and v.__name__.startswith("scipy"):
37+
if (
38+
isinstance(v, types.ModuleType)
39+
and v not in seen
40+
and v.__name__.startswith("scipy")
41+
):
3242
seen.add(v)
3343
fname = v.__spec__.name if v.__spec__ else k
3444
if "." in fname:
@@ -51,7 +61,9 @@ def is_stubbed(mod: str) -> bool:
5161

5262
*subpackages, submod = submods
5363
subpackage_path = stubs_path.joinpath(*subpackages)
54-
return (subpackage_path / f"{submod}.pyi").is_file() or (subpackage_path / submod / "__init__.pyi").is_file()
64+
return (subpackage_path / f"{submod}.pyi").is_file() or (
65+
subpackage_path / submod / "__init__.pyi"
66+
).is_file()
5567

5668

5769
if __name__ == "__main__":

0 commit comments

Comments
 (0)