Skip to content

Commit 43c5229

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

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Changed
2+
3+
- Set PolicyBreak's detector_name and detector_group_name fields as optional to fix backwards compatibility with the GitGuardian API

pygitguardian/models.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,10 @@ 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, load_default=None, dump_default=None)
220+
detector_group_name = fields.String(
221+
required=False, load_default=None, dump_default=None
222+
)
221223
documentation_url = fields.String(
222224
required=False, load_default=None, dump_default=None
223225
)
@@ -251,11 +253,11 @@ class PolicyBreak(FromDictWithBase):
251253
def __init__(
252254
self,
253255
break_type: str,
254-
detector_name: str,
255-
detector_group_name: str,
256256
policy: str,
257257
validity: str,
258258
matches: List[Match],
259+
detector_name: Optional[str] = None,
260+
detector_group_name: Optional[str] = None,
259261
documentation_url: Optional[str] = None,
260262
known_secret: bool = False,
261263
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)