Skip to content

Commit d1797a9

Browse files
Adding ruff rule (#366)
## Description This came up on ticket #213 where the import order of modules seemed a little funky: ```python import json from typing import TypedDict from augmentation.models.application import TTCAugmenterOutput from augmentation.services.eicr_augmenter import EICRAugmenter from aws_lambda_typing import context as lambda_context from aws_lambda_typing import events as lambda_events from shared_models import TTCAugmenterInput from augmentation.models import TTCAugmenterConfig ``` I couldn't quite figure out why augmentation.models was separated. I thought this rule might be the lowest lift in terms of getting an order that seemed to make sense to me, but for anyone more versed in ruff, curious if there's a better option! ## Related Issues ## Additional Notes [Add any additional context or notes that reviewers should know about.] <--------------------- REMOVE THE LINES BELOW BEFORE MERGING ---------------------> ## Checklist Please review and complete the following checklist before submitting your pull request: - [ ] I have ensured that the pull request is of a manageable size, allowing it to be reviewed within a single session. - [ ] I have reviewed my changes to ensure they are clear, concise, and well-documented. - [ ] I have updated the documentation, if applicable. - [ ] I have added or updated test cases to cover my changes, if applicable. - [ ] I have minimized the number of reviewers to include only those essential for the review. ## Checklist for Reviewers Please review and complete the following checklist during the review process: - [ ] The code follows best practices and conventions. - [ ] The changes implement the desired functionality or fix the reported issue. - [ ] The tests cover the new changes and pass successfully. - [ ] Any potential edge cases or error scenarios have been considered.
1 parent a190fde commit d1797a9

File tree

25 files changed

+32
-21
lines changed

25 files changed

+32
-21
lines changed

packages/augmentation-lambda/src/augmentation_lambda/lambda_function.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import json
22
from typing import TypedDict
33

4-
from augmentation.models.application import TTCAugmenterOutput
5-
from augmentation.services.eicr_augmenter import EICRAugmenter
64
from aws_lambda_typing import context as lambda_context
75
from aws_lambda_typing import events as lambda_events
8-
from shared_models import TTCAugmenterInput
96

107
from augmentation.models import TTCAugmenterConfig
8+
from augmentation.models.application import TTCAugmenterOutput
9+
from augmentation.services.eicr_augmenter import EICRAugmenter
10+
from shared_models import TTCAugmenterInput
1111

1212

1313
class HandlerResponse(TypedDict):

packages/augmentation-lambda/tests/test_augmentation_lambda_function.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import json
22

3+
from augmentation.models import Metadata
34
from augmentation_lambda import lambda_function
45
from shared_models import TTCAugmenterInput
56

6-
from augmentation.models import Metadata
7-
87

98
class FakeAugmenter:
109
def __init__(self, document: str, nonstandard_codes: list[object], config: object) -> None:

packages/augmentation/src/augmentation/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
from io import BytesIO
44

5-
from lambda_handler.lambda_handler import put_file
6-
from shared_models import TTCAugmenterInput
7-
85
from augmentation.models import Metadata
96
from augmentation.models import TTCAugmenterConfig
107
from augmentation.services.eicr_augmenter import EICRAugmenter
8+
from lambda_handler.lambda_handler import put_file
9+
from shared_models import TTCAugmenterInput
1110

1211

1312
def _retrieve_eicr(eicr_id: str) -> str:

packages/augmentation/src/augmentation/models/application.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from pydantic import BaseModel
44
from pydantic import ConfigDict
5+
56
from shared_models import NonstandardCodeInstance
67

78

packages/augmentation/src/augmentation/models/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from pydantic import BaseModel
22
from pydantic import ConfigDict
33
from pydantic import model_validator
4+
45
from shared_models import DataField
56

67
from .application import ApplicationCode

packages/augmentation/src/augmentation/services/eicr_augmenter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
from lxml import etree
55
from lxml.etree import Element
6-
from shared_models import NonstandardCodeInstance
76

87
from augmentation.models import ApplicationCode
98
from augmentation.models import Metadata
109
from augmentation.models import TTCAugmenterConfig
1110
from augmentation.models.application import NonstandardCodeInstanceMetadata
1211
from augmentation.services.augmenter import Augmenter
12+
from shared_models import NonstandardCodeInstance
1313

1414

1515
class EICRAugmenter(Augmenter):

packages/augmentation/tests/unit/test_eicr_augmenter.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
from zoneinfo import ZoneInfo
55

66
import pytest
7+
from pytest_mock import MockerFixture
8+
from pytest_snapshot.plugin import Snapshot
9+
10+
from augmentation.models import Metadata
11+
from augmentation.models import NonstandardCodeInstanceMetadata
712
from augmentation.models.config import ApplicationCode
813
from augmentation.models.config import AugmenterConfig
914
from augmentation.models.config import TTCAugmenterConfig
1015
from augmentation.services.eicr_augmenter import EICRAugmenter
11-
from pytest_mock import MockerFixture
12-
from pytest_snapshot.plugin import Snapshot
1316
from shared_models import Code
1417
from shared_models import DataField
1518
from shared_models import NonstandardCodeInstance
1619

17-
from augmentation.models import Metadata
18-
from augmentation.models import NonstandardCodeInstanceMetadata
19-
2020
EXAMPLE_EICRS_DIRECTORY = Path(__file__).parent.parent / "assets"
2121
DATA_CONFIG: AugmenterConfig = TTCAugmenterConfig()
2222
BASE_XPATH = "/ClinicalDocument/component/structuredBody/component/section/entry/component/observation/code/originalText/text()"

packages/augmentation/tests/unit/test_model_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
23
from augmentation.models.application import ApplicationCode
34
from augmentation.models.config import AugmenterConfig
45
from augmentation.models.config import TTCAugmenterConfig

packages/lambda-handler/tests/test_lambda_handler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import io
22

3-
import lambda_handler
43
import pytest
54

5+
import lambda_handler
6+
67

78
class TestCreateS3Client:
89
def test_create_s3_client(self, moto_setup):

packages/text-to-code-lambda/src/text_to_code_lambda/lambda_function.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
import json
33
import os
44

5-
import lambda_handler
65
from aws_lambda_powertools import Logger
76
from aws_lambda_powertools.utilities.data_classes import SQSEvent
87
from aws_lambda_powertools.utilities.data_classes import SQSRecord
98
from aws_lambda_powertools.utilities.data_classes import event_source
109
from aws_lambda_powertools.utilities.typing import LambdaContext
1110
from botocore.client import BaseClient
1211
from opensearchpy import OpenSearch
12+
13+
import lambda_handler
1314
from text_to_code.models import eicr as eicr_models
1415
from text_to_code.models import query as query_models
1516
from text_to_code.services import eicr_processor

0 commit comments

Comments
 (0)