Skip to content

Commit ffb5857

Browse files
committed
fix(models): None in ExtraSignatureData is not required with default_factory (#284)
1 parent cde6120 commit ffb5857

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

pyoaev/signatures/models.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ def is_expectation_type(cls, value: str) -> str:
4747
class ExtraSignatureData(BaseModel):
4848
"""Format for extra signatures added to the default signatures"""
4949

50-
detection: dict[str, JsonValue] | None = Field(default_factory=dict)
51-
prevention: dict[str, JsonValue] | None = Field(default_factory=dict)
52-
vulnerability: dict[str, JsonValue] | None = Field(default_factory=dict)
50+
detection: dict[str, JsonValue] = Field(default_factory=dict)
51+
prevention: dict[str, JsonValue] = Field(default_factory=dict)
52+
vulnerability: dict[str, JsonValue] = Field(default_factory=dict)
5353

5454
def get_extra(self, expectation_type: str) -> dict[str, JsonValue]:
5555
if expectation_type.lower() == "detection":
56-
return self.detection or {}
56+
return self.detection
5757
if expectation_type.lower() == "prevention":
58-
return self.prevention or {}
58+
return self.prevention
5959
if expectation_type.lower() == "vulnerability":
60-
return self.vulnerability or {}
60+
return self.vulnerability
6161
raise ValueError(
6262
f"Expectation type should be one of the available parameters: {list(self.model_fields.keys())}"
6363
)
@@ -179,9 +179,11 @@ def build_from_models(
179179
execution_message=execution_details.execution_message,
180180
execution_output_structured=signatures.model_dump_json(exclude_none=True),
181181
execution_status=execution_details.execution_status,
182-
execution_duration=math.ceil(execution_details.execution_duration)
183-
if execution_details.execution_duration is not None
184-
else None,
182+
execution_duration=(
183+
math.ceil(execution_details.execution_duration)
184+
if execution_details.execution_duration is not None
185+
else None
186+
),
185187
execution_action=execution_details.execution_action,
186188
)
187189

0 commit comments

Comments
 (0)