Skip to content

Commit

Permalink
Removed mass changes that replaced instances of `dictionary.get("key"…
Browse files Browse the repository at this point in the history
…)` with the seemingly equivalent `dictionary.get("key", )`.
  • Loading branch information
christophertubbs committed Jul 20, 2023
1 parent e65c323 commit ef6c08b
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion python/lib/communication/dmod/communication/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class SessionInitResponse(Response):

@root_validator(pre=True)
def _coerce_data_field(cls, values):
data = values.get("data", )
data = values.get("data")

if data is None:
details = "Instantiated SessionInitResponse object without session data; defaulting to failure"
Expand Down
2 changes: 1 addition & 1 deletion python/lib/core/dmod/core/meta_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def __new__(cls, *_, **kwargs) -> Self:

@root_validator(pre=True)
def coerce_times_if_datetime_pattern(cls, values):
datetime_ptr = values.get("datetime_pattern", )
datetime_ptr = values.get("datetime_pattern")

if datetime_ptr is not None:
# If there is a datetime pattern, then expect begin and end to parse properly to datetime objects
Expand Down
4 changes: 2 additions & 2 deletions python/lib/evaluations/dmod/evaluations/specification/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class DataSourceSpecification(LoaderSpecification):
@pydantic.root_validator
def ensure_name_is_present(cls, values):
if "name" not in values:
values['name'] = values.get("value_field", )
values['name'] = values.get("value_field")
return values

def __eq__(self, other: "DataSourceSpecification"):
Expand Down Expand Up @@ -159,7 +159,7 @@ def apply_configuration(
for mapping in configuration.get("field_mapping", list()):
matching_mapping = find(
self.field_mapping,
lambda field_mapping: field_mapping.field == mapping.get("field", )
lambda field_mapping: field_mapping.field == mapping.get("field")
)

if matching_mapping:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def apply_configuration(
for observation_configuration in configuration.get("observations"):
matching_observations = find(
self.observations,
lambda observations: observations.name == observation_configuration.get("name", )
lambda observations: observations.name == observation_configuration.get("name")
)

if matching_observations:
Expand All @@ -104,7 +104,7 @@ def apply_configuration(
for prediction_configuration in configuration.get("predictions"):
matching_predictions = find(
self.predictions,
lambda predictions: predictions.name == prediction_configuration.get("name", )
lambda predictions: predictions.name == prediction_configuration.get("name")
)

if matching_predictions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ def validate_self(self) -> typing.Sequence[str]:
@root_validator
def _format_path(cls, values):
path_starts_at_root = False
path = values.get("path", )
path = values.get("path")

if path is None and values.get("name", ) is not None:
if path is None and values.get("name") is not None:
values['path'] = [values['name']]
elif isinstance(path, str):
path_starts_at_root = path.startswith("/")
Expand All @@ -124,7 +124,7 @@ def _format_path(cls, values):
if 'path' not in values and 'name' not in path:
raise ValueError("Associated fields must define a name and/or path")

if values.get("datatype", ):
if values.get("datatype"):
values['datatype'] = values['datatype'].lower()

return values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def apply_configuration(
metric_definitions = configuration.get("metrics", list())

for definition in metric_definitions:
name = definition.get("name", )
name = definition.get("name")

if not name:
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def get_source_actions(
# Get the data that came through the server
try:
action_declaration = json.loads(message)
action_declaration = action_declaration.get("event", ) or action_declaration.get("action", )
action_declaration = action_declaration.get("event") or action_declaration.get("action")
except:
action_declaration = message.decode() if isinstance(message, bytes) else message

Expand Down Expand Up @@ -110,7 +110,7 @@ async def get_target_actions(
"""
try:
payload = json.loads(message)
payload = payload.get("event", ) or payload.get("action", )
payload = payload.get("event") or payload.get("action")
except:
payload = message.decode() if isinstance(message, bytes) else message

Expand Down Expand Up @@ -275,7 +275,7 @@ async def get_source_actions(
# Get the data that came through the server
try:
action_declaration = json.loads(message)
action_declaration = action_declaration.get("event", ) or action_declaration.get("action", )
action_declaration = action_declaration.get("event") or action_declaration.get("action")
except:
action_declaration = message.decode() if isinstance(message, bytes) else message

Expand Down Expand Up @@ -322,7 +322,7 @@ async def get_target_actions(
"""
try:
payload = json.loads(message)
payload = payload.get("event", ) or payload.get("action", )
payload = payload.get("event") or payload.get("action")
except:
payload = message

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

class LaunchEvaluation(APIView):
def post(self, request, *args, **kwargs):
evaluation_id = request.POST.get("evaluation_id", )
evaluation_id = request.POST.get("evaluation_id")
evaluation_id = evaluation_id.replace(" ", "_").replace(":", ".")
instructions = request.POST.get("instructions", )
instructions = request.POST.get("instructions")

if 'HTTP_REFERER' in request.META:
response_url = reverse("evaluation_service:Listen", kwargs={"channel_name": evaluation_id})
Expand Down

0 comments on commit ef6c08b

Please sign in to comment.