Skip to content

Commit

Permalink
Run black #2714
Browse files Browse the repository at this point in the history
  • Loading branch information
iamleeg committed Jul 26, 2022
1 parent 40e0ad8 commit c5b1520
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

observers = []


def make_custom_case_class(name: str, field_models=[]) -> type:
"""Generate a class extending the DayZeroCase class with additional fields.
field_models is a list of model objects describing the fields for the data dictionary
Expand Down Expand Up @@ -66,7 +67,9 @@ def remove_case_class_observer(observer: Callable[[type], None]) -> None:
def reset_custom_case_fields() -> None:
"""When you want to get back to where you started, for example to load the field definitions from
storage or if you're writing tests that modify the Case class."""
day_zero_field_definitions = json.loads(importlib.resources.read_text('data_service', 'day_zero_fields.json'))
day_zero_field_definitions = json.loads(
importlib.resources.read_text("data_service", "day_zero_fields.json")
)
day_zero_fields = [Field.from_dict(f) for f in day_zero_field_definitions]
make_custom_case_class("Case", day_zero_fields)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@dataclasses.dataclass
class Document:
"""The base class for anything that's going into the database."""

custom_fields = []

def to_dict(self):
Expand Down
12 changes: 6 additions & 6 deletions data-serving/reusable-data-service/data_service/model/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Field(Document):
INTEGER: int,
LOCATION: Feature,
"CaseReference": CaseReference,
"CaseExclusion": CaseExclusionMetadata
"CaseExclusion": CaseExclusionMetadata,
}
acceptable_types = type_map.keys()

Expand All @@ -44,11 +44,11 @@ def model_type(cls, name: str) -> type:
@classmethod
def from_dict(cls, dictionary):
return cls(
dictionary.get('key'),
dictionary.get('type'),
dictionary.get('data_dictionary_text'),
dictionary.get('required'),
dictionary.get('default', None)
dictionary.get("key"),
dictionary.get("type"),
dictionary.get("data_dictionary_text"),
dictionary.get("required"),
dictionary.get("default", None),
)

def python_type(self) -> type:
Expand Down

0 comments on commit c5b1520

Please sign in to comment.