19
19
(Version ("3.11" ), Version ("1.25" )),
20
20
(Version ("3.12" ), Version ("1.26" )),
21
21
(Version ("3.13" ), Version ("2.1" )),
22
- ) # fmt: skip
22
+ )
23
23
24
24
25
25
class UVPythonVersionParts (TypedDict ):
@@ -81,7 +81,9 @@ def get_package_minimum_python_version(package: str) -> Version:
81
81
"""
82
82
raw_version = importlib .metadata .metadata (package )["Requires-Python" ]
83
83
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
+ )
85
87
86
88
return parse (raw_version .replace (">=" , "" ).replace ("~=" , "" ))
87
89
@@ -98,7 +100,8 @@ def get_dependency_minimum_version(package: str, dependency: str) -> Version:
98
100
Version: The minimum required version of the dependency.
99
101
100
102
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.
102
105
103
106
"""
104
107
requirements = importlib .metadata .requires (package )
@@ -107,33 +110,49 @@ def get_dependency_minimum_version(package: str, dependency: str) -> Version:
107
110
108
111
try :
109
112
# 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
+ )
111
118
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
113
122
114
123
# 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
+ )
116
127
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
+ )
118
131
119
132
# 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
+ )
121
136
return parse (version_str )
122
137
123
138
124
139
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 ,
126
143
) -> list [Version ]:
127
144
"""
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.
129
147
130
148
Args:
131
149
min_version (Version | None): The minimum Python version to include in the list.
132
150
max_version (Version | None): The maximum Python version to include in the list.
133
151
pre_releases (bool): Whether to include pre-release versions.
134
152
135
153
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.
137
156
138
157
Raises:
139
158
urllib.error.URLError: If fetching data fails.
@@ -189,19 +208,22 @@ def fetch_json(url: str) -> Any:
189
208
sys .exit (1 )
190
209
191
210
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 ]:
193
214
"""
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,
196
217
along with their 'requires_python' specifiers.
197
218
198
219
Args:
199
220
package_name (str): The name of the package on PyPI.
200
221
min_version (Version): The minimum version to include.
201
222
202
223
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.
205
227
206
228
Raises:
207
229
RuntimeError: If no 'requires_python' is found for a package version.
@@ -268,7 +290,10 @@ def main() -> None:
268
290
continue
269
291
270
292
# 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
+ ):
272
297
continue
273
298
274
299
matrix_entries .append ({
0 commit comments