From ff5c739296e551f83f7961d9cb14594bb3f63e5d Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 24 Apr 2024 14:46:17 -0400 Subject: [PATCH] fix: Restore support for Python 3.9 (#82) --- .github/workflows/build-test.yaml | 2 +- src/rapids_dependency_file_generator/_config.py | 13 +++++++------ .../_rapids_dependency_file_generator.py | 11 ++++++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index abec04ac..53970221 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -25,7 +25,7 @@ jobs: path: ${{ env.OUTPUT_DIR }} wheel: runs-on: ubuntu-latest - container: python:3 + container: python:3.9 steps: - uses: actions/checkout@v4 with: diff --git a/src/rapids_dependency_file_generator/_config.py b/src/rapids_dependency_file_generator/_config.py index 40a86343..d6500370 100644 --- a/src/rapids_dependency_file_generator/_config.py +++ b/src/rapids_dependency_file_generator/_config.py @@ -1,3 +1,4 @@ +import typing from dataclasses import dataclass, field from enum import Enum from os import PathLike @@ -43,7 +44,7 @@ class FileExtras: table: str """The ``table`` field.""" - key: str | None = None + key: typing.Union[str, None] = None """The ``key`` field.""" @@ -57,7 +58,7 @@ class File: includes: list[str] """The list of dependency sets to include.""" - extras: FileExtras | None = None + extras: typing.Union[FileExtras, None] = None """Optional extra information for the file generator.""" matrix: dict[str, list[str]] = field(default_factory=dict) @@ -88,7 +89,7 @@ class CommonDependencies: output_types: set[Output] """The set of output types for this entry.""" - packages: list[str | PipRequirements] + packages: list[typing.Union[str, PipRequirements]] """The list of packages for this entry.""" @@ -99,7 +100,7 @@ class MatrixMatcher: matrix: dict[str, str] """The set of matrix values to match.""" - packages: list[str | PipRequirements] + packages: list[typing.Union[str, PipRequirements]] """The list of packages for this entry.""" @@ -142,7 +143,7 @@ class Config: """The dependency sets, keyed by name.""" -def _parse_outputs(outputs: str | list[str]) -> set[Output]: +def _parse_outputs(outputs: typing.Union[str, list[str]]) -> set[Output]: if isinstance(outputs, str): outputs = [outputs] if outputs == ["none"]: @@ -177,7 +178,7 @@ def get_extras(): ) -def _parse_requirement(requirement: str | dict[str, str]) -> str | PipRequirements: +def _parse_requirement(requirement: typing.Union[str, dict[str, str]]) -> typing.Union[str, PipRequirements]: if isinstance(requirement, str): return requirement diff --git a/src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py b/src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py index 75432dea..96d99316 100644 --- a/src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py +++ b/src/rapids_dependency_file_generator/_rapids_dependency_file_generator.py @@ -2,6 +2,7 @@ import itertools import os import textwrap +import typing from collections import defaultdict from collections.abc import Generator @@ -40,8 +41,8 @@ def delete_existing_files(root: os.PathLike) -> None: def dedupe( - dependencies: list[str | _config.PipRequirements], -) -> list[str | dict[str, str]]: + dependencies: list[typing.Union[str, _config.PipRequirements]], +) -> list[typing.Union[str, dict[str, str]]]: """Generate the unique set of dependencies contained in a dependency list. Parameters @@ -96,7 +97,7 @@ def make_dependency_file( config_file: os.PathLike, output_dir: os.PathLike, conda_channels: list[str], - dependencies: list[str | dict[str, list[str]]], + dependencies: list[typing.Union[str, dict[str, list[str]]]], extras: _config.FileExtras, ): """Generate the contents of the dependency file. @@ -314,8 +315,8 @@ def should_use_specific_entry(matrix_combo: dict[str, str], specific_entry_matri def make_dependency_files( parsed_config: _config.Config, file_keys: list[str], - output: set[_config.Output] | None, - matrix: dict[str, list[str]] | None, + output: typing.Union[set[_config.Output], None], + matrix: typing.Union[dict[str, list[str]], None], prepend_channels: list[str], to_stdout: bool, ):