Skip to content

Commit 8228ca8

Browse files
fix: set PolicyBreak's detector_name and detector_group_name as optional to fix backwards compatibility
1 parent be13fe7 commit 8228ca8

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

pygitguardian/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ class DiffKind(str, Enum):
216216

217217
class PolicyBreakSchema(BaseSchema):
218218
break_type = fields.String(data_key="type", required=True)
219-
detector_name = fields.String(required=True)
220-
detector_group_name = fields.String(required=True)
219+
detector_name = fields.String(required=False)
220+
detector_group_name = fields.String(required=False)
221221
documentation_url = fields.String(
222222
required=False, load_default=None, dump_default=None
223223
)
@@ -251,11 +251,11 @@ class PolicyBreak(FromDictWithBase):
251251
def __init__(
252252
self,
253253
break_type: str,
254-
detector_name: str,
255-
detector_group_name: str,
256254
policy: str,
257255
validity: str,
258256
matches: List[Match],
257+
detector_name: Optional[str] = None,
258+
detector_group_name: Optional[str] = None,
259259
documentation_url: Optional[str] = None,
260260
known_secret: bool = False,
261261
incident_url: Optional[str] = None,

tests/test_models.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ def test_document_handle_surrogates(self):
117117
PolicyBreak,
118118
{
119119
"type": "hello",
120-
"detector_name": "hello",
121-
"detector_group_name": "hello",
122-
"documentation_url": None,
123120
"policy": "hello",
124121
"validity": "hey",
125122
"matches": [{"match": "hello", "type": "hello"}],

0 commit comments

Comments
 (0)