From 4ebb5049f03bcaafc2ec5ca8daac94c60adb5a0b Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Wed, 20 Nov 2024 07:50:45 -0500 Subject: [PATCH] build!: require python >= 3.11 (#445) * https://github.com/GenomicMedLab/software-templates/pull/66 --- .github/workflows/checks.yaml | 2 +- pyproject.toml | 4 ++-- src/therapy/database/dynamodb.py | 2 +- src/therapy/etl/wikidata.py | 4 +--- src/therapy/query.py | 8 ++++---- tests/scripts/build_wikidata_data.py | 2 +- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index e0a373ff..5cd1c1cd 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -14,7 +14,7 @@ jobs: THERAPY_TEST: true strategy: matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 diff --git a/pyproject.toml b/pyproject.toml index 183430f7..4ca02d9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,11 +16,11 @@ classifiers = [ "Topic :: Scientific/Engineering :: Bio-Informatics", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ] -requires-python = ">=3.10" +requires-python = ">=3.11" description = "VICC normalization routines for therapeutics" license = {file = "LICENSE"} dependencies = [ diff --git a/src/therapy/database/dynamodb.py b/src/therapy/database/dynamodb.py index 276d9a43..64db5869 100644 --- a/src/therapy/database/dynamodb.py +++ b/src/therapy/database/dynamodb.py @@ -608,7 +608,7 @@ def delete_source(self, src_name: SourceName) -> None: "concept_id": record["concept_id"], } ) - except ClientError as e: # noqa: PERF203 + except ClientError as e: raise DatabaseWriteError(e) from e def complete_write_transaction(self) -> None: diff --git a/src/therapy/etl/wikidata.py b/src/therapy/etl/wikidata.py index 33895e55..4e50f92c 100644 --- a/src/therapy/etl/wikidata.py +++ b/src/therapy/etl/wikidata.py @@ -120,9 +120,7 @@ def _get_latest_version() -> str: :return: formatted string for the current date """ - return datetime.datetime.now(tz=datetime.timezone.utc).strftime( - DATE_VERSION_PATTERN - ) + return datetime.datetime.now(tz=datetime.UTC).strftime(DATE_VERSION_PATTERN) def _get_data_handler(self, data_path: Path | None = None) -> DataSource: """Construct data handler instance for source. Overwrites base class method diff --git a/src/therapy/query.py b/src/therapy/query.py index 2f1e2d58..a85aca95 100644 --- a/src/therapy/query.py +++ b/src/therapy/query.py @@ -144,7 +144,7 @@ def _fetch_records( raise KeyError(msg) (response, src) = self._add_record(response, match, match_type) matched_sources.add(src) - except ClientError as e: # noqa: PERF203 + except ClientError as e: logger.error(e.response["Error"]["Message"]) return response, matched_sources @@ -339,7 +339,7 @@ def search( response = self._get_search_response(query_str, query_sources, infer) response["service_meta_"] = ServiceMeta( - response_datetime=datetime.datetime.now(tz=datetime.timezone.utc), + response_datetime=datetime.datetime.now(tz=datetime.UTC), ).model_dump() return SearchService(**response) @@ -358,7 +358,7 @@ def _add_merged_meta(self, response: NormalizationService) -> NormalizationServi for src in sources: try: src_name = SourceName(PREFIX_LOOKUP[src]) - except KeyError: # noqa: PERF203 + except KeyError: # not an imported source continue else: @@ -522,7 +522,7 @@ def _prepare_normalized_response(self, query: str) -> dict[str, Any]: "match_type": MatchType.NO_MATCH, "warnings": self._emit_char_warnings(query), "service_meta_": ServiceMeta( - response_datetime=datetime.datetime.now(tz=datetime.timezone.utc) + response_datetime=datetime.datetime.now(tz=datetime.UTC) ), } diff --git a/tests/scripts/build_wikidata_data.py b/tests/scripts/build_wikidata_data.py index f824c2e6..0eb84d2e 100644 --- a/tests/scripts/build_wikidata_data.py +++ b/tests/scripts/build_wikidata_data.py @@ -30,7 +30,7 @@ test_data.append(params) TEST_DATA_DIR = Path(__file__).resolve().parents[1] / "data" / "wikidata" -date = datetime.datetime.now(tz=datetime.timezone.utc).strftime("%Y-%m-%d") +date = datetime.datetime.now(tz=datetime.UTC).strftime("%Y-%m-%d") outfile_path = TEST_DATA_DIR / f"wikidata_{date}.json" with outfile_path.open("w+") as f: json.dump(test_data, f, indent=2)