Skip to content

Commit

Permalink
ruff fixes resulting from Python version change
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyestein committed Jan 20, 2025
1 parent 99d50a8 commit 8512c9b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pixl_core/src/core/patient_queue/subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@

if TYPE_CHECKING:
from collections.abc import Awaitable, Callable
from typing import Self

Check warning on line 37 in pixl_core/src/core/patient_queue/subscriber.py

View check run for this annotation

Codecov / codecov/patch

pixl_core/src/core/patient_queue/subscriber.py#L37

Added line #L37 was not covered by tests

from aio_pika.abc import AbstractIncomingMessage
from typing_extensions import Self

from core.patient_queue.message import Message
from core.token_buffer.tokens import TokenBucket
Expand Down
4 changes: 2 additions & 2 deletions pixl_core/src/core/uploader/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from datetime import datetime, timezone
from datetime import UTC, datetime
from typing import TYPE_CHECKING, Any, Optional

from loguru import logger
Expand Down Expand Up @@ -77,7 +77,7 @@ def upload_dicom_and_update_database(self, study_id: str) -> None:
study_tags.pseudo_anon_image_id,
)

update_exported_at(study_tags.pseudo_anon_image_id, datetime.now(tz=timezone.utc))
update_exported_at(study_tags.pseudo_anon_image_id, datetime.now(tz=UTC))

@abstractmethod
def _upload_dicom_image(
Expand Down
4 changes: 2 additions & 2 deletions pixl_core/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def rows_in_session(db_session) -> Session:
mrn="mrn",
study_uid="1.2.3",
extract=extract,
exported_at=datetime.datetime.now(tz=datetime.timezone.utc),
exported_at=datetime.datetime.now(tz=datetime.UTC),
pseudo_study_uid=generate_uid(entropy_srcs=["already_exported"]),
)
image_not_exported = Image(
Expand Down Expand Up @@ -221,5 +221,5 @@ def mock_message() -> Message:
project_name="test project",
extract_generated_timestamp=datetime.datetime.strptime(
"Dec 7 2023 2:08PM", "%b %d %Y %I:%M%p"
).replace(tzinfo=datetime.timezone.utc),
).replace(tzinfo=datetime.UTC),
)
8 changes: 4 additions & 4 deletions pixl_core/tests/uploader/test_ftps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import filecmp
import os
from collections.abc import Generator
from datetime import datetime, timezone
from datetime import UTC, datetime
from pathlib import Path

import pandas as pd
Expand Down Expand Up @@ -92,7 +92,7 @@ def test_send_via_ftps(
def test_update_exported_and_save(rows_in_session) -> None:
"""Tests that the exported_at field is updated when a file is uploaded"""
# ARRANGE
expected_export_time = datetime.now(tz=timezone.utc)
expected_export_time = datetime.now(tz=UTC)

# ACT
update_exported_at(generate_uid(entropy_srcs=["not_yet_exported"]), expected_export_time)
Expand All @@ -101,7 +101,7 @@ def test_update_exported_and_save(rows_in_session) -> None:
.filter(Image.pseudo_study_uid == generate_uid(entropy_srcs=["not_yet_exported"]))
.one()
)
actual_export_time = new_row.exported_at.replace(tzinfo=timezone.utc)
actual_export_time = new_row.exported_at.replace(tzinfo=UTC)

# ASSERT
assert actual_export_time == expected_export_time
Expand All @@ -119,7 +119,7 @@ def parquet_export(export_dir) -> ParquetExport:
"""
return ParquetExport(
project_name_raw="i-am-a-project",
extract_datetime=datetime.now(tz=timezone.utc),
extract_datetime=datetime.now(tz=UTC),
export_dir=export_dir,
)

Expand Down
10 changes: 5 additions & 5 deletions pixl_imaging/tests/test_imaging_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def message() -> Message:
accession_number=ACCESSION_NUMBER,
study_uid=STUDY_UID,
study_date=datetime.datetime.strptime("01/01/1234 01:23:45", "%d/%m/%Y %H:%M:%S").replace(
tzinfo=datetime.timezone.utc
tzinfo=datetime.UTC
),
procedure_occurrence_id=234,
project_name="test project",
Expand All @@ -79,7 +79,7 @@ def no_uid_message() -> Message:
accession_number=ACCESSION_NUMBER,
study_uid="",
study_date=datetime.datetime.strptime("01/01/1234 01:23:45", "%d/%m/%Y %H:%M:%S").replace(
tzinfo=datetime.timezone.utc
tzinfo=datetime.UTC
),
procedure_occurrence_id=234,
project_name="test project",
Expand All @@ -95,7 +95,7 @@ def pacs_message() -> Message:
accession_number=PACS_ACCESSION_NUMBER,
study_uid=PACS_STUDY_UID,
study_date=datetime.datetime.strptime("01/01/1234 01:23:45", "%d/%m/%Y %H:%M:%S").replace(
tzinfo=datetime.timezone.utc
tzinfo=datetime.UTC
),
procedure_occurrence_id=234,
project_name="test project",
Expand All @@ -111,7 +111,7 @@ def pacs_no_uid_message() -> Message:
accession_number=PACS_ACCESSION_NUMBER,
study_uid="ialsodontexist",
study_date=datetime.datetime.strptime("01/01/1234 01:23:45", "%d/%m/%Y %H:%M:%S").replace(
tzinfo=datetime.timezone.utc
tzinfo=datetime.UTC
),
procedure_occurrence_id=234,
project_name="test project",
Expand All @@ -127,7 +127,7 @@ def missing_message() -> Message:
accession_number=MISSING_ACCESSION_NUMBER,
study_uid=MISSING_STUDY_UID,
study_date=datetime.datetime.strptime("01/01/1234 01:23:45", "%d/%m/%Y %H:%M:%S").replace(
tzinfo=datetime.timezone.utc
tzinfo=datetime.UTC
),
procedure_occurrence_id=345,
project_name="test project",
Expand Down
4 changes: 2 additions & 2 deletions pytest-pixl/src/pytest_pixl/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

import subprocess
from time import sleep
from typing import TYPE_CHECKING, Callable, Optional
from typing import TYPE_CHECKING, Optional

if TYPE_CHECKING:
from collections.abc import Sequence
from collections.abc import Callable, Sequence

Check warning on line 23 in pytest-pixl/src/pytest_pixl/helpers.py

View check run for this annotation

Codecov / codecov/patch

pytest-pixl/src/pytest_pixl/helpers.py#L23

Added line #L23 was not covered by tests
from pathlib import Path

from loguru import logger
Expand Down

0 comments on commit 8512c9b

Please sign in to comment.