12
12
import sys
13
13
import warnings
14
14
from abc import ABCMeta , abstractmethod
15
+ from collections .abc import Collection , Iterator , Mapping
15
16
from glob import glob
16
17
from traceback import print_exc
17
- from typing import Any , Collection , Dict , Iterator , List , Mapping , Set , cast
18
+ from typing import Any , cast
18
19
from urllib import request
19
20
from urllib .error import HTTPError
20
21
from xml .etree import ElementTree
@@ -160,7 +161,7 @@ def get_pyproject_toml(self) -> Mapping[str, Any]:
160
161
os .environ [FACET_PATH_ENV ], self .project , "pyproject.toml"
161
162
)
162
163
log (f"Reading build configuration from { pyproject_toml_path } " )
163
- with open (pyproject_toml_path , "rt" ) as f :
164
+ with open (pyproject_toml_path ) as f :
164
165
self .pyproject_toml = pyproject_toml = toml .load (f )
165
166
166
167
return pyproject_toml
@@ -184,7 +185,7 @@ def validate_release_version(self) -> None:
184
185
185
186
log (f"Testing package version: { package } { new_version } " )
186
187
187
- released_versions : List [Version ] = self ._get_existing_releases (package )
188
+ released_versions : list [Version ] = self ._get_existing_releases (package )
188
189
189
190
if new_version in released_versions :
190
191
raise AssertionError (
@@ -215,7 +216,7 @@ def validate_release_version(self) -> None:
215
216
f"release of major/minor version { new_version } can go ahead"
216
217
)
217
218
218
- def _get_existing_releases (self , package : str ) -> List [Version ]:
219
+ def _get_existing_releases (self , package : str ) -> list [Version ]:
219
220
releases_uri = f"https://pypi.org/rss/project/{ package } /releases.xml"
220
221
log (f"Getting existing releases from { releases_uri } " )
221
222
try :
@@ -234,7 +235,7 @@ def _get_existing_releases(self, package: str) -> List[Version]:
234
235
tree = ElementTree .fromstring (releases_xml )
235
236
releases_nodes = tree .findall (path = ".//channel//item//title" )
236
237
237
- released_versions : List [Version ] = sorted (
238
+ released_versions : list [Version ] = sorted (
238
239
Version (r ) for r in [r .text for r in releases_nodes ]
239
240
)
240
241
@@ -256,7 +257,7 @@ def expose_package_dependencies(self) -> Mapping[str, str]:
256
257
257
258
requirements_to_expose = self ._get_requirements_to_expose ()
258
259
259
- environment_version_variables : Dict [str , str ] = {
260
+ environment_version_variables : dict [str , str ] = {
260
261
# replace non-word characters with '_' to make valid environment variable
261
262
# names
262
263
(
@@ -270,7 +271,7 @@ def expose_package_dependencies(self) -> Mapping[str, str]:
270
271
export_environment_variable (name = package , value = version )
271
272
272
273
# get packages to be built from source
273
- build_no_binaries : List [str ] = (
274
+ build_no_binaries : list [str ] = (
274
275
self .get_pyproject_toml ()[TOML_BUILD ]
275
276
.get (TOML_NO_BINARY , {})
276
277
.get (self .dependency_type , [])
@@ -303,7 +304,7 @@ def _get_run_dependencies(self) -> Mapping[str, str]:
303
304
flit_metadata = self .get_pyproject_toml ()[TOML_TOOL ][TOML_FLIT ][TOML_METADATA ]
304
305
305
306
python_version = flit_metadata [TOML_REQUIRES_PYTHON ]
306
- run_dependencies : Dict [str , str ] = {
307
+ run_dependencies : dict [str , str ] = {
307
308
name : validate_pip_version_spec (
308
309
dependency_type = DEP_DEFAULT , package = name , spec = version .lstrip ()
309
310
)
@@ -328,12 +329,12 @@ def _get_requirements_to_expose(self) -> Mapping[str, str]:
328
329
329
330
# get full project specification from the TOML file
330
331
# get the matrix test dependencies (min and max)
331
- build_matrix_definition : Dict [str , Dict [str , str ]] = self .get_pyproject_toml ()[
332
+ build_matrix_definition : dict [str , dict [str , str ]] = self .get_pyproject_toml ()[
332
333
TOML_BUILD
333
334
][TOML_MATRIX ]
334
335
335
- def get_matrix_dependencies (matrix_type : str ) -> Dict [str , str ]:
336
- dependencies : Dict [str , str ] = build_matrix_definition .get (matrix_type , {})
336
+ def get_matrix_dependencies (matrix_type : str ) -> dict [str , str ]:
337
+ dependencies : dict [str , str ] = build_matrix_definition .get (matrix_type , {})
337
338
if not dependencies :
338
339
return {}
339
340
return {
@@ -345,11 +346,11 @@ def get_matrix_dependencies(matrix_type: str) -> Dict[str, str]:
345
346
for name , version in dependencies .items ()
346
347
}
347
348
348
- min_dependencies : Dict [str , str ] = get_matrix_dependencies (DEP_MIN )
349
- max_dependencies : Dict [str , str ] = get_matrix_dependencies (DEP_MAX )
349
+ min_dependencies : dict [str , str ] = get_matrix_dependencies (DEP_MIN )
350
+ max_dependencies : dict [str , str ] = get_matrix_dependencies (DEP_MAX )
350
351
351
352
# check that the min and max dependencies supersede all default dependencies
352
- dependencies_not_covered_in_matrix : Set [str ] = (
353
+ dependencies_not_covered_in_matrix : set [str ] = (
353
354
run_dependencies .keys () - min_dependencies .keys ()
354
355
) | (run_dependencies .keys () - max_dependencies .keys ())
355
356
@@ -556,7 +557,7 @@ def build(self, exposed_package_dependencies: Mapping[str, str]) -> None:
556
557
for package in glob (os .path .join (project_repo_path , package_glob ))
557
558
]
558
559
# store index.html
559
- with open (project_index_html_path , "wt " ) as f :
560
+ with open (project_index_html_path , "w " ) as f :
560
561
f .writelines (package_file_links )
561
562
562
563
log (f"Local PyPi Index created at: { pypi_index_path } " )
@@ -596,8 +597,8 @@ def _patch_tox_ini(self, exposed_version_variables: Collection[str]) -> str:
596
597
# file, unless they reference a facet dependency environment variable which
597
598
# has not been exported
598
599
599
- removed_lines : List [str ] = []
600
- with open (tox_ini_path , "rt" ) as f_in , open (tox_ini_tmp_path , "wt " ) as f_out :
600
+ removed_lines : list [str ] = []
601
+ with open (tox_ini_path ) as f_in , open (tox_ini_tmp_path , "w " ) as f_out :
601
602
for line in f_in .readlines ():
602
603
# get all environment variables referenced in the line
603
604
# these use the tox.ini `{env:` syntax and start with the
@@ -641,7 +642,7 @@ def get_projects_root_path() -> str:
641
642
return facet_path
642
643
643
644
644
- def get_known_projects () -> Set [str ]:
645
+ def get_known_projects () -> set [str ]:
645
646
dir_entries : Iterator [os .DirEntry ] = cast (
646
647
Iterator [os .DirEntry ], os .scandir (get_projects_root_path ())
647
648
)
0 commit comments