From 1994a8c7b423f4be4942fdb10e48841a1745efd0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 00:50:31 +0000 Subject: [PATCH 1/2] build(deps): update ruff requirement from <0.9 to <0.10 Updates the requirements on [ruff](https://github.com/astral-sh/ruff) to permit the latest version. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.0.18...0.9.1) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 42c5e8c..445d25e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,7 @@ dev = [ "pre-commit", # Ruff is using minor versions for breaking changes until their 1.0 release. # See https://docs.astral.sh/ruff/versioning/ - "ruff < 0.9", # keep in rough sync with pre-commit-config.yaml + "ruff < 0.10", # keep in rough sync with pre-commit-config.yaml ] [project.urls] From 20005317f414e20d52bf5eda8f1b12158fc65e6f Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Mon, 13 Jan 2025 08:42:09 -0300 Subject: [PATCH 2/2] Re-format code with ruff --- .pre-commit-config.yaml | 2 +- cumulus_etl/loaders/fhir/bulk_export.py | 2 +- cumulus_etl/loaders/i2b2/oracle/query.py | 4 ++-- tests/etl/base.py | 4 ++-- tests/etl/test_tasks.py | 4 ++-- tests/loaders/i2b2/test_i2b2_loader.py | 2 +- tests/loaders/i2b2/test_i2b2_oracle_query.py | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3fe7dc1..0dd9d05 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.0 # keep in rough sync with pyproject.toml + rev: v0.9.1 # keep in rough sync with pyproject.toml hooks: - name: Ruff formatting id: ruff-format diff --git a/cumulus_etl/loaders/fhir/bulk_export.py b/cumulus_etl/loaders/fhir/bulk_export.py index 4f4cd89..d5b467c 100644 --- a/cumulus_etl/loaders/fhir/bulk_export.py +++ b/cumulus_etl/loaders/fhir/bulk_export.py @@ -397,7 +397,7 @@ async def _download_all_ndjson_files(self, resource_json: dict, item_type: str) for file in files: count = resource_counts.get(file["type"], -1) + 1 resource_counts[file["type"]] = count - filename = f'{file["type"]}.{count:03}.ndjson' + filename = f"{file['type']}.{count:03}.ndjson" coroutines.append( self._download_ndjson_file( file["url"], diff --git a/cumulus_etl/loaders/i2b2/oracle/query.py b/cumulus_etl/loaders/i2b2/oracle/query.py index 0394b06..ff75e8a 100644 --- a/cumulus_etl/loaders/i2b2/oracle/query.py +++ b/cumulus_etl/loaders/i2b2/oracle/query.py @@ -39,7 +39,7 @@ def sql_visit() -> str: import_date = format_date("IMPORT_DATE") cols_dates = f"{start_date}, {end_date}, {import_date}, LENGTH_OF_STAY" - cols = "ENCOUNTER_NUM, PATIENT_NUM, LOCATION_CD, INOUT_CD, " f"{cols_dates}" + cols = f"ENCOUNTER_NUM, PATIENT_NUM, LOCATION_CD, INOUT_CD, {cols_dates}" return f"select {cols} \n from {Table.visit.value}" # noqa: S608 @@ -97,7 +97,7 @@ def sql_observation_fact(categories: list[str]) -> str: f"O.CONCEPT_CD, O.INSTANCE_NUM, {import_date}, O.TVAL_CHAR, " f"O.VALTYPE_CD, O.VALUEFLAG_CD, O.NVAL_NUM, O.UNITS_CD, O.OBSERVATION_BLOB" ) - cols = f"{cols_patient_dim}, {cols_provider_dim}, {cols_visit_dim}, " f"{cols_obs_fact}" + cols = f"{cols_patient_dim}, {cols_provider_dim}, {cols_visit_dim}, {cols_obs_fact}" matchers = [f"(concept_cd like '{category}:%')" for category in categories] diff --git a/tests/etl/base.py b/tests/etl/base.py index f629ac9..7b970a5 100644 --- a/tests/etl/base.py +++ b/tests/etl/base.py @@ -81,9 +81,9 @@ async def run_etl( if batch_size: args.append(f"--batch-size={batch_size}") if tasks: - args.append(f'--task={",".join(tasks)}') + args.append(f"--task={','.join(tasks)}") if tags: - args.append(f'--task-filter={",".join(tags)}') + args.append(f"--task-filter={','.join(tags)}") if philter: args.append("--philter") if export_to: diff --git a/tests/etl/test_tasks.py b/tests/etl/test_tasks.py index 55fdb27..2a7d4e9 100644 --- a/tests/etl/test_tasks.py +++ b/tests/etl/test_tasks.py @@ -389,7 +389,7 @@ async def test_contained_medications(self): self.assertEqual(1, med_req_format.write_records.call_count) batch = med_req_format.write_records.call_args[0][0] self.assertEqual( - f'#{self.codebook.db.resource_hash("123")}', + f"#{self.codebook.db.resource_hash('123')}", batch.rows[0]["medicationReference"]["reference"], ) @@ -440,7 +440,7 @@ async def test_external_medications(self, mock_download): batch = med_req_format.write_records.call_args[0][0] self.assertEqual([self.codebook.db.resource_hash("A")], [row["id"] for row in batch.rows]) self.assertEqual( - f'Medication/{self.codebook.db.resource_hash("123")}', + f"Medication/{self.codebook.db.resource_hash('123')}", batch.rows[0]["medicationReference"]["reference"], ) diff --git a/tests/loaders/i2b2/test_i2b2_loader.py b/tests/loaders/i2b2/test_i2b2_loader.py index 269d1b8..c006524 100644 --- a/tests/loaders/i2b2/test_i2b2_loader.py +++ b/tests/loaders/i2b2/test_i2b2_loader.py @@ -34,7 +34,7 @@ async def test_duplicate_ids(self): common.write_text( f"{tmpdir}/patient_dimension.csv", - "PATIENT_NUM,BIRTH_DATE\n" "123,1982-10-16\n" "123,1983-11-17\n" "456,2000-01-13\n", + "PATIENT_NUM,BIRTH_DATE\n123,1982-10-16\n123,1983-11-17\n456,2000-01-13\n", ) results = await i2b2_loader.load_resources({"Patient"}) diff --git a/tests/loaders/i2b2/test_i2b2_oracle_query.py b/tests/loaders/i2b2/test_i2b2_oracle_query.py index edb3bf7..11afe46 100644 --- a/tests/loaders/i2b2/test_i2b2_oracle_query.py +++ b/tests/loaders/i2b2/test_i2b2_oracle_query.py @@ -28,7 +28,7 @@ def shorten(sql: str) -> str: def count_by_date_group(table: schema.Table, column_date="import_date") -> str: return shorten( f""" - select {count_by_date(column_date, f'{column_date}_cnt')} + select {count_by_date(column_date, f"{column_date}_cnt")} from {table.value} group by {query.cast_date(column_date)} order by {query.cast_date(column_date)} desc