Skip to content

Commit 8f16c28

Browse files
authored
Merge pull request #377 from BCG-X-Official/dev/3.0.1
2 parents bded8ec + 6f86268 commit 8f16c28

File tree

22 files changed

+308
-203
lines changed

22 files changed

+308
-203
lines changed

.pre-commit-config.yaml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
repos:
2+
- repo: https://github.com/asottile/pyupgrade
3+
rev: v3.16.0
4+
hooks:
5+
- id: pyupgrade
6+
args: [--py310-plus]
7+
28
- repo: https://github.com/PyCQA/isort
39
rev: 5.12.0
410
hooks:
511
- id: isort
612

7-
- repo: https://github.com/psf/black
13+
- repo: https://github.com/psf/black-pre-commit-mirror
814
rev: 24.4.2
915
hooks:
1016
- id: black
1117
language: python
12-
language_version: python311
18+
language_version: python310
1319

1420
- repo: https://github.com/pycqa/flake8
1521
rev: 7.0.0
@@ -18,7 +24,7 @@ repos:
1824
name: flake8
1925
entry: flake8 --config tox.ini
2026
language: python
21-
language_version: python311
27+
language_version: python310
2228
additional_dependencies:
2329
- flake8-comprehensions ~= 3.10
2430
types: [ python ]
@@ -37,8 +43,13 @@ repos:
3743
rev: v1.10.0
3844
hooks:
3945
- id: mypy
40-
files: src|sphinx|test
46+
entry: mypy src/ test/ sphinx/
47+
args: [--config-file, pyproject.toml]
48+
files: \.pyi?$
4149
language: python
42-
language_version: python311
50+
language_version: python310
51+
pass_filenames: false
4352
additional_dependencies:
4453
- numpy~=1.24
54+
- pytest
55+
- packaging

RELEASE_NOTES.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ Release Notes
99
-------------
1010

1111
*pytools* 3.0 adds support for language features introduced up to and including
12-
Python 3.11, and drops support for Python versions.
12+
Python 3.10, and drops support for Python versions.
13+
14+
*pytools* 3.0.1
15+
~~~~~~~~~~~~~~~
16+
17+
- BUILD: add support for Python 3.10
1318

1419

1520
*pytools* 3.0.0
@@ -78,8 +83,8 @@ Python 3.11, and drops support for Python versions.
7883
class of two types
7984
- new function :func:`.get_common_generic_subclass` to retrieve the common generic
8085
subclass of two types
81-
- new function :func:`.get_generic_bases` to retrieve the generic base classes of a
82-
type
86+
- new function :func:`~pytools.typing.get_generic_bases` to retrieve the generic base
87+
classes of a type
8388
- new function :func:`.get_generic_instance` to retrieve the generic instance of a
8489
type
8590
- new function :func:`.get_type_arguments` to retrieve the type arguments of a generic
@@ -94,7 +99,7 @@ Python 3.11, and drops support for Python versions.
9499
- API: new class :class:`.HTMLStyle` for rendering HTML content with drawers
95100
- API: new function :func:`.is_running_in_notebook` to check if the code is running
96101
in a Jupyter or Colab notebook
97-
- API: new property :attr:`.hex` for :class:`.RgbColor` and :class:`.RgbaColor` to
102+
- API: new property :attr:`.RgbColor.hex` and :attr:`.RgbaColor.hex` to
98103
return the color as a hexadecimal string
99104

100105
- Various adjustments to maintain compatibility with recent Python versions

azure-pipelines.yml

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ stages:
5151
steps:
5252
- task: UsePythonVersion@0
5353
inputs:
54-
versionSpec: '3.11'
55-
displayName: 'use Python 3.11'
54+
versionSpec: '3.10'
55+
displayName: 'use Python 3.10'
5656
- script: |
5757
python -m pip install isort~=5.12
5858
python -m isort --check --diff .
@@ -62,8 +62,8 @@ stages:
6262
steps:
6363
- task: UsePythonVersion@0
6464
inputs:
65-
versionSpec: '3.11'
66-
displayName: 'use Python 3.11'
65+
versionSpec: '3.10'
66+
displayName: 'use Python 3.10'
6767
- script: |
6868
python -m pip install black~=24.4.2
6969
python -m black --check .
@@ -73,8 +73,8 @@ stages:
7373
steps:
7474
- task: UsePythonVersion@0
7575
inputs:
76-
versionSpec: '3.11'
77-
displayName: 'use Python 3.11'
76+
versionSpec: '3.10'
77+
displayName: 'use Python 3.10'
7878
- script: |
7979
python -m pip install flake8~=7.0 flake8-comprehensions~=3.10
8080
python -m flake8 --config tox.ini -v .
@@ -84,11 +84,17 @@ stages:
8484
steps:
8585
- task: UsePythonVersion@0
8686
inputs:
87-
versionSpec: '3.11'
88-
displayName: 'use Python 3.11'
87+
versionSpec: '3.10'
88+
displayName: 'use Python 3.10'
8989
- script: |
90-
python -m pip install mypy~=1.10.0 numpy~=1.24
91-
python -m mypy src
90+
# package dependencies for mypy
91+
dependencies=(
92+
numpy~=1.24
93+
packaging
94+
pytest
95+
)
96+
python -m pip install mypy "${dependencies[@]}"
97+
python -m mypy src --config-file pyproject.toml
9298
displayName: 'Run mypy'
9399
94100
# detect whether the build config (pyproject.toml) was changed -> then we must run a build test
@@ -144,8 +150,8 @@ stages:
144150
steps:
145151
- task: UsePythonVersion@0
146152
inputs:
147-
versionSpec: '3.11'
148-
displayName: 'use Python 3.11'
153+
versionSpec: '3.10'
154+
displayName: 'use Python 3.10'
149155

150156
- checkout: self
151157

@@ -223,7 +229,7 @@ stages:
223229
BUILD_SYSTEM: 'conda'
224230
PKG_DEPENDENCIES: 'max'
225231
minimum_dependencies_tox:
226-
FACET_V_PYTHON_BUILD: '=3.11'
232+
FACET_V_PYTHON_BUILD: '=3.10'
227233
BUILD_SYSTEM: 'tox'
228234
PKG_DEPENDENCIES: 'min'
229235
maximum_dependencies_tox:
@@ -305,23 +311,23 @@ stages:
305311
strategy:
306312
matrix:
307313
default_dependencies_conda:
308-
FACET_V_PYTHON_BUILD: '=3.11'
314+
FACET_V_PYTHON_BUILD: '=3.10'
309315
BUILD_SYSTEM: 'conda'
310316
PKG_DEPENDENCIES: 'default'
311317
minimum_dependencies_conda:
312-
FACET_V_PYTHON_BUILD: '=3.11'
318+
FACET_V_PYTHON_BUILD: '=3.10'
313319
BUILD_SYSTEM: 'conda'
314320
PKG_DEPENDENCIES: 'min'
315321
maximum_dependencies_conda:
316322
FACET_V_PYTHON_BUILD: '=3.12'
317323
BUILD_SYSTEM: 'conda'
318324
PKG_DEPENDENCIES: 'max'
319325
default_dependencies_tox:
320-
FACET_V_PYTHON_BUILD: '=3.11'
326+
FACET_V_PYTHON_BUILD: '=3.10'
321327
BUILD_SYSTEM: 'tox'
322328
PKG_DEPENDENCIES: 'default'
323329
minimum_dependencies_tox:
324-
FACET_V_PYTHON_BUILD: '=3.11'
330+
FACET_V_PYTHON_BUILD: '=3.10'
325331
BUILD_SYSTEM: 'tox'
326332
PKG_DEPENDENCIES: 'min'
327333
maximum_dependencies_tox:
@@ -441,8 +447,8 @@ stages:
441447
steps:
442448
- task: UsePythonVersion@0
443449
inputs:
444-
versionSpec: '3.11'
445-
displayName: 'use Python 3.11'
450+
versionSpec: '3.10'
451+
displayName: 'use Python 3.10'
446452

447453
- checkout: pytools
448454
- checkout: self
@@ -506,8 +512,8 @@ stages:
506512
steps:
507513
- task: UsePythonVersion@0
508514
inputs:
509-
versionSpec: '3.11'
510-
displayName: 'use Python 3.11'
515+
versionSpec: '3.10'
516+
displayName: 'use Python 3.10'
511517

512518
- checkout: pytools
513519
- checkout: self
@@ -634,8 +640,8 @@ stages:
634640
steps:
635641
- task: UsePythonVersion@0
636642
inputs:
637-
versionSpec: '3.11'
638-
displayName: 'use Python 3.11'
643+
versionSpec: '3.10'
644+
displayName: 'use Python 3.10'
639645

640646
- task: InstallSSHKey@0
641647
inputs:

environment.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
name: pytools-develop
22
channels:
33
- conda-forge
4-
- bcg_gamma
54
dependencies:
65
# run
76
- joblib ~= 1.2
8-
- matplotlib ~= 3.7
7+
- matplotlib ~= 3.6
98
- numpy ~= 1.24
109
- pandas ~= 2.0
11-
- python ~= 3.10
10+
- python ~= 3.10.14
1211
- scipy ~= 1.10
1312
- typing_extensions ~= 4.3
14-
- typing_inspect ~= 0.7
13+
- typing_inspect ~= 0.9
1514
# test
1615
- pytest ~= 7.2.1
1716
- pytest-cov ~= 2.12.1

make.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
import sys
1313
import warnings
1414
from abc import ABCMeta, abstractmethod
15+
from collections.abc import Collection, Iterator, Mapping
1516
from glob import glob
1617
from traceback import print_exc
17-
from typing import Any, Collection, Dict, Iterator, List, Mapping, Set, cast
18+
from typing import Any, cast
1819
from urllib import request
1920
from urllib.error import HTTPError
2021
from xml.etree import ElementTree
@@ -160,7 +161,7 @@ def get_pyproject_toml(self) -> Mapping[str, Any]:
160161
os.environ[FACET_PATH_ENV], self.project, "pyproject.toml"
161162
)
162163
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:
164165
self.pyproject_toml = pyproject_toml = toml.load(f)
165166

166167
return pyproject_toml
@@ -184,7 +185,7 @@ def validate_release_version(self) -> None:
184185

185186
log(f"Testing package version: {package} {new_version}")
186187

187-
released_versions: List[Version] = self._get_existing_releases(package)
188+
released_versions: list[Version] = self._get_existing_releases(package)
188189

189190
if new_version in released_versions:
190191
raise AssertionError(
@@ -215,7 +216,7 @@ def validate_release_version(self) -> None:
215216
f"release of major/minor version {new_version} can go ahead"
216217
)
217218

218-
def _get_existing_releases(self, package: str) -> List[Version]:
219+
def _get_existing_releases(self, package: str) -> list[Version]:
219220
releases_uri = f"https://pypi.org/rss/project/{package}/releases.xml"
220221
log(f"Getting existing releases from {releases_uri}")
221222
try:
@@ -234,7 +235,7 @@ def _get_existing_releases(self, package: str) -> List[Version]:
234235
tree = ElementTree.fromstring(releases_xml)
235236
releases_nodes = tree.findall(path=".//channel//item//title")
236237

237-
released_versions: List[Version] = sorted(
238+
released_versions: list[Version] = sorted(
238239
Version(r) for r in [r.text for r in releases_nodes]
239240
)
240241

@@ -256,7 +257,7 @@ def expose_package_dependencies(self) -> Mapping[str, str]:
256257

257258
requirements_to_expose = self._get_requirements_to_expose()
258259

259-
environment_version_variables: Dict[str, str] = {
260+
environment_version_variables: dict[str, str] = {
260261
# replace non-word characters with '_' to make valid environment variable
261262
# names
262263
(
@@ -270,7 +271,7 @@ def expose_package_dependencies(self) -> Mapping[str, str]:
270271
export_environment_variable(name=package, value=version)
271272

272273
# get packages to be built from source
273-
build_no_binaries: List[str] = (
274+
build_no_binaries: list[str] = (
274275
self.get_pyproject_toml()[TOML_BUILD]
275276
.get(TOML_NO_BINARY, {})
276277
.get(self.dependency_type, [])
@@ -303,7 +304,7 @@ def _get_run_dependencies(self) -> Mapping[str, str]:
303304
flit_metadata = self.get_pyproject_toml()[TOML_TOOL][TOML_FLIT][TOML_METADATA]
304305

305306
python_version = flit_metadata[TOML_REQUIRES_PYTHON]
306-
run_dependencies: Dict[str, str] = {
307+
run_dependencies: dict[str, str] = {
307308
name: validate_pip_version_spec(
308309
dependency_type=DEP_DEFAULT, package=name, spec=version.lstrip()
309310
)
@@ -328,12 +329,12 @@ def _get_requirements_to_expose(self) -> Mapping[str, str]:
328329

329330
# get full project specification from the TOML file
330331
# 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()[
332333
TOML_BUILD
333334
][TOML_MATRIX]
334335

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, {})
337338
if not dependencies:
338339
return {}
339340
return {
@@ -345,11 +346,11 @@ def get_matrix_dependencies(matrix_type: str) -> Dict[str, str]:
345346
for name, version in dependencies.items()
346347
}
347348

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)
350351

351352
# 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] = (
353354
run_dependencies.keys() - min_dependencies.keys()
354355
) | (run_dependencies.keys() - max_dependencies.keys())
355356

@@ -556,7 +557,7 @@ def build(self, exposed_package_dependencies: Mapping[str, str]) -> None:
556557
for package in glob(os.path.join(project_repo_path, package_glob))
557558
]
558559
# store index.html
559-
with open(project_index_html_path, "wt") as f:
560+
with open(project_index_html_path, "w") as f:
560561
f.writelines(package_file_links)
561562

562563
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:
596597
# file, unless they reference a facet dependency environment variable which
597598
# has not been exported
598599

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:
601602
for line in f_in.readlines():
602603
# get all environment variables referenced in the line
603604
# these use the tox.ini `{env:` syntax and start with the
@@ -641,7 +642,7 @@ def get_projects_root_path() -> str:
641642
return facet_path
642643

643644

644-
def get_known_projects() -> Set[str]:
645+
def get_known_projects() -> set[str]:
645646
dir_entries: Iterator[os.DirEntry] = cast(
646647
Iterator[os.DirEntry], os.scandir(get_projects_root_path())
647648
)

0 commit comments

Comments
 (0)