Skip to content

Commit f38a112

Browse files
linter/formatting
1 parent ec36437 commit f38a112

13 files changed

Lines changed: 43 additions & 56 deletions

File tree

backend/compact-connect/lambdas/python/common/cc_common/data_model/data_client.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2726,7 +2726,6 @@ def encumber_home_jurisdiction_license_privileges(
27262726
# Add PUT transaction for privilege update record
27272727
transaction_items.append(self._generate_put_transaction_item(privilege_update_record))
27282728

2729-
27302729
# Execute transactions in batches of 100 (DynamoDB limit)
27312730
batch_size = 100
27322731
while transaction_items:
@@ -2742,9 +2741,9 @@ def encumber_home_jurisdiction_license_privileges(
27422741

27432742
logger.info('Successfully encumbered associated privileges for license')
27442743

2745-
return (unencumbered_privileges_associated_with_license
2746-
+ previously_encumbered_privileges_associated_with_license)
2747-
2744+
return (
2745+
unencumbered_privileges_associated_with_license + previously_encumbered_privileges_associated_with_license
2746+
)
27482747

27492748
@logger_inject_kwargs(logger, 'compact', 'provider_id', 'jurisdiction', 'license_type_abbreviation')
27502749
def lift_home_jurisdiction_license_privilege_encumbrances(

backend/compact-connect/lambdas/python/common/cc_common/data_model/provider_record_util.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ def populate_provider_record(
245245

246246
@staticmethod
247247
def get_enriched_history_with_synthetic_updates_from_privilege(
248-
privilege: dict,
249-
history: list[dict],
248+
privilege: dict,
249+
history: list[dict],
250250
) -> list[dict]:
251251
"""
252252
Enrich the privilege history with 'synthetic updates'.
@@ -367,8 +367,7 @@ def get_enriched_history_with_synthetic_updates_from_privilege(
367367

368368
@staticmethod
369369
def construct_simplified_privilege_history_object(
370-
privilege_data: list[dict],
371-
should_include_encumbrance_details: bool = True
370+
privilege_data: list[dict], should_include_encumbrance_details: bool = True
372371
) -> dict:
373372
"""
374373
Construct a simplified list of history events to be easily consumed by the front end
@@ -393,10 +392,7 @@ def construct_simplified_privilege_history_object(
393392
and should_include_encumbrance_details
394393
):
395394
event['note'] = event['encumbranceDetails']['clinicalPrivilegeActionCategory']
396-
elif (
397-
event['updateType'] == UpdateCategory.DEACTIVATION
398-
and event.get('deactivationDetails')
399-
):
395+
elif event['updateType'] == UpdateCategory.DEACTIVATION and event.get('deactivationDetails'):
400396
event['note'] = event['deactivationDetails']['note']
401397

402398
unsanitized_history = {

backend/compact-connect/lambdas/python/common/cc_common/data_model/schema/military_affiliation/api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,3 @@ class MilitaryAffiliationReadPrivateResponseSchema(ForgivingSchema):
6565
# this will only be present for compact admins
6666
documentKeys = List(String(required=True, allow_none=False), required=False, allow_none=False)
6767
downloadLinks = List(Dict(required=True, allow_none=False), required=False, allow_none=False)
68-

backend/compact-connect/lambdas/python/common/cc_common/data_model/schema/privilege/record.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class DeactivationDetailsSchema(Schema):
5151
deactivatedByStaffUserId = UUID(required=True, allow_none=False)
5252
deactivatedByStaffUserName = String(required=True, allow_none=False)
5353

54+
5455
class EncumbranceDetailsSchema(Schema):
5556
"""
5657
Schema for tracking details about an encumbrance.
@@ -61,6 +62,7 @@ class EncumbranceDetailsSchema(Schema):
6162
# present if update is created by upstream license encumbrance
6263
licenseJurisdiction = Jurisdiction(required=False, allow_none=False)
6364

65+
6466
@BaseRecordSchema.register_schema('privilege')
6567
class PrivilegeRecordSchema(BaseRecordSchema, ValidatesLicenseTypeMixin):
6668
"""

backend/compact-connect/lambdas/python/common/cc_common/data_model/schema/provider/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class ProviderReadPrivateResponseSchema(ForgivingSchema):
8585
dateOfBirth = Raw(required=True, allow_none=False)
8686
ssnLastFour = String(required=False, allow_none=False, validate=Length(equal=4))
8787

88+
8889
class ProviderGeneralResponseSchema(ForgivingSchema):
8990
"""
9091
Provider object fields that are sanitized for users with the 'readGeneral' permission.

backend/compact-connect/lambdas/python/common/common_test/test_data_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def generate_default_privilege_update(
357357

358358
@staticmethod
359359
def put_default_privilege_update_record_in_provider_table(
360-
value_overrides: dict | None = None
360+
value_overrides: dict | None = None,
361361
) -> PrivilegeUpdateData:
362362
"""
363363
Creates a default privilege update and stores it in the provider table.

backend/compact-connect/lambdas/python/common/tests/unit/test_provider_record_util.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -879,9 +879,7 @@ def test_construct_simplified_privilege_history_object_returns_deactivation_note
879879
]
880880

881881
# Enrich the privilege history
882-
history = ProviderRecordUtility.construct_simplified_privilege_history_object(
883-
privilege_data
884-
)
882+
history = ProviderRecordUtility.construct_simplified_privilege_history_object(privilege_data)
885883

886884
# Define the expected issuance update
887885
expected_history = {
@@ -896,7 +894,7 @@ def test_construct_simplified_privilege_history_object_returns_deactivation_note
896894
'dateOfUpdate': datetime.fromisoformat('2024-01-01T00:00:00+00:00'),
897895
'effectiveDate': datetime.fromisoformat('2024-01-01T00:00:00+00:00'),
898896
'type': 'privilegeUpdate',
899-
'updateType': 'issuance'
897+
'updateType': 'issuance',
900898
},
901899
{
902900
'createDate': datetime.fromisoformat('2025-06-16T00:00:00+04:00'),
@@ -905,8 +903,8 @@ def test_construct_simplified_privilege_history_object_returns_deactivation_note
905903
'type': 'privilegeUpdate',
906904
'updateType': 'deactivation',
907905
'note': 'test deactivation note',
908-
}
909-
]
906+
},
907+
],
910908
}
911909

912910
# Check that the history contains exactly one update with the expected values
@@ -959,9 +957,7 @@ def test_construct_simplified_privilege_history_object_returns_encumbrance_notes
959957
]
960958

961959
# Enrich the privilege history
962-
history = ProviderRecordUtility.construct_simplified_privilege_history_object(
963-
privilege_data
964-
)
960+
history = ProviderRecordUtility.construct_simplified_privilege_history_object(privilege_data)
965961

966962
# Define the expected issuance update
967963
expected_history = {
@@ -976,7 +972,7 @@ def test_construct_simplified_privilege_history_object_returns_encumbrance_notes
976972
'dateOfUpdate': datetime.fromisoformat('2024-01-01T00:00:00+00:00'),
977973
'effectiveDate': datetime.fromisoformat('2024-01-01T00:00:00+00:00'),
978974
'type': 'privilegeUpdate',
979-
'updateType': 'issuance'
975+
'updateType': 'issuance',
980976
},
981977
{
982978
'createDate': datetime.fromisoformat('2025-06-16T00:00:00+04:00'),
@@ -985,8 +981,8 @@ def test_construct_simplified_privilege_history_object_returns_encumbrance_notes
985981
'type': 'privilegeUpdate',
986982
'updateType': 'encumbrance',
987983
'note': 'Non-compliance With Requirements',
988-
}
989-
]
984+
},
985+
],
990986
}
991987

992988
# Check that the history contains exactly one update with the expected values
@@ -1040,9 +1036,7 @@ def test_construct_simplified_privilege_history_object_does_not_return_encumbran
10401036
]
10411037

10421038
# Enrich the privilege history
1043-
history = ProviderRecordUtility.construct_simplified_privilege_history_object(
1044-
privilege_data, False
1045-
)
1039+
history = ProviderRecordUtility.construct_simplified_privilege_history_object(privilege_data, False)
10461040

10471041
# Define the expected issuance update
10481042
expected_history = {
@@ -1057,22 +1051,23 @@ def test_construct_simplified_privilege_history_object_does_not_return_encumbran
10571051
'dateOfUpdate': datetime.fromisoformat('2024-01-01T00:00:00+00:00'),
10581052
'effectiveDate': datetime.fromisoformat('2024-01-01T00:00:00+00:00'),
10591053
'type': 'privilegeUpdate',
1060-
'updateType': 'issuance'
1054+
'updateType': 'issuance',
10611055
},
10621056
{
10631057
'createDate': datetime.fromisoformat('2025-06-16T00:00:00+04:00'),
10641058
'dateOfUpdate': datetime.fromisoformat('2025-06-16T00:00:00+04:00'),
10651059
'effectiveDate': datetime.fromisoformat('2025-06-16T00:00:00+04:00'),
10661060
'type': 'privilegeUpdate',
10671061
'updateType': 'encumbrance',
1068-
}
1069-
]
1062+
},
1063+
],
10701064
}
10711065

10721066
# Check that the history contains exactly one update with the expected values
10731067
self.maxDiff = None
10741068
self.assertEqual(expected_history, history)
10751069

1070+
10761071
class TestProviderRecordUtilityActiveSinceCalculation(TstLambdas):
10771072
def setUp(self):
10781073
from cc_common.data_model.provider_record_util import ProviderRecordUtility

backend/compact-connect/lambdas/python/data-events/handlers/encumbrance_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def license_encumbrance_listener(message: dict):
209209
license_type_abbreviation=license_type_abbreviation,
210210
effective_date=effective_date,
211211
adverse_action_category=adverse_action_category,
212-
adverse_action_id=adverse_action_id
212+
adverse_action_id=adverse_action_id,
213213
):
214214
logger.info('Processing license encumbrance event')
215215

backend/compact-connect/lambdas/python/data-events/tests/function/test_encumbrance_events.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,14 @@ def test_license_encumbrance_listener_handles_all_privileges_already_encumbered(
235235
self.assertEqual(1, len(privilege_update_records['Items']))
236236
update_record = privilege_update_records['Items'][0]
237237
update_encumbrance_details = update_record['encumbranceDetails']
238-
self.assertEqual({
239-
'adverseActionId': DEFAULT_ADVERSE_ACTION_ID,
240-
'licenseJurisdiction': 'oh',
241-
'clinicalPrivilegeActionCategory': 'Unsafe Practice or Substandard Care'
242-
}, update_encumbrance_details)
238+
self.assertEqual(
239+
{
240+
'adverseActionId': DEFAULT_ADVERSE_ACTION_ID,
241+
'licenseJurisdiction': 'oh',
242+
'clinicalPrivilegeActionCategory': 'Unsafe Practice or Substandard Care',
243+
},
244+
update_encumbrance_details,
245+
)
243246

244247
# Verify one event was published for the privilege update
245248
mock_publish_event.assert_called_once()

backend/compact-connect/lambdas/python/feature-flag/feature_flag_client.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ def check_flag(self, request: FeatureFlagRequest) -> FeatureFlagResult:
8282
:return: FeatureFlagResult indicating if flag is enabled
8383
:raises FeatureFlagException: If flag check fails
8484
"""
85-
pass
8685

8786
def _get_secret(self, secret_name: str) -> dict[str, Any]:
8887
"""
@@ -103,9 +102,7 @@ def _get_secret(self, secret_name: str) -> dict[str, Any]:
103102
response = client.get_secret_value(SecretId=secret_name)
104103

105104
# Parse the secret string as JSON
106-
secret_data = json.loads(response['SecretString'])
107-
108-
return secret_data
105+
return json.loads(response['SecretString'])
109106

110107
except ClientError as e:
111108
error_code = e.response['Error']['Code']
@@ -120,14 +117,10 @@ def _get_secret(self, secret_name: str) -> dict[str, Any]:
120117
class FeatureFlagException(Exception):
121118
"""Base exception for feature flag operations"""
122119

123-
pass
124-
125120

126121
class FeatureFlagValidationException(FeatureFlagException):
127122
"""Exception raised when feature flag validation fails"""
128123

129-
pass
130-
131124

132125
# Implementing Classes
133126

@@ -174,8 +167,8 @@ def __init__(self, environment: str):
174167
self._is_initialized = False
175168

176169
# Retrieve StatSig configuration from AWS Secrets Manager
170+
secret_name = f'compact-connect/env/{environment}/statsig/credentials'
177171
try:
178-
secret_name = f'compact-connect/env/{environment}/statsig/credentials'
179172
secret_data = self._get_secret(secret_name)
180173
self._server_secret_key = secret_data.get('serverKey')
181174

@@ -252,11 +245,10 @@ def check_flag(self, request: FeatureFlagRequest) -> FeatureFlagResult:
252245
flag_name=request.flagName,
253246
)
254247

255-
except Exception as e:
248+
except (FeatureFlagException, FeatureFlagValidationException) as e:
256249
# If it's already a FeatureFlagException, re-raise it
257-
if isinstance(e, (FeatureFlagException, FeatureFlagValidationException)):
258-
raise
259-
250+
raise e
251+
except Exception as e:
260252
# Otherwise, wrap it in a FeatureFlagException
261253
raise FeatureFlagException(f"Failed to check feature flag '{request.flagName}': {e}") from e
262254

0 commit comments

Comments
 (0)