Skip to content

Commit 1efd52c

Browse files
author
Lukas Pühringer
authored
Merge pull request #1975 from abs007/1937
Checking for None instead of falsyness
2 parents 83f2eee + 79d924a commit 1efd52c

1 file changed

Lines changed: 28 additions & 7 deletions

File tree

tuf/api/metadata.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ def __init__(
134134
):
135135
self.signed: T = signed
136136
self.signatures = signatures if signatures is not None else {}
137-
self.unrecognized_fields: Dict[str, Any] = unrecognized_fields or {}
137+
if unrecognized_fields is None:
138+
unrecognized_fields = {}
139+
140+
self.unrecognized_fields = unrecognized_fields
138141

139142
def __eq__(self, other: Any) -> bool:
140143
if not isinstance(other, Metadata):
@@ -519,7 +522,10 @@ def __init__(
519522
raise ValueError(f"version must be > 0, got {version}")
520523
self.version = version
521524

522-
self.unrecognized_fields: Dict[str, Any] = unrecognized_fields or {}
525+
if unrecognized_fields is None:
526+
unrecognized_fields = {}
527+
528+
self.unrecognized_fields = unrecognized_fields
523529

524530
def __eq__(self, other: Any) -> bool:
525531
if not isinstance(other, Signed):
@@ -639,7 +645,10 @@ def __init__(
639645
self.keytype = keytype
640646
self.scheme = scheme
641647
self.keyval = keyval
642-
self.unrecognized_fields: Dict[str, Any] = unrecognized_fields or {}
648+
if unrecognized_fields is None:
649+
unrecognized_fields = {}
650+
651+
self.unrecognized_fields = unrecognized_fields
643652

644653
def __eq__(self, other: Any) -> bool:
645654
if not isinstance(other, Key):
@@ -797,7 +806,10 @@ def __init__(
797806
raise ValueError("threshold should be at least 1!")
798807
self.keyids = keyids
799808
self.threshold = threshold
800-
self.unrecognized_fields: Dict[str, Any] = unrecognized_fields or {}
809+
if unrecognized_fields is None:
810+
unrecognized_fields = {}
811+
812+
self.unrecognized_fields = unrecognized_fields
801813

802814
def __eq__(self, other: Any) -> bool:
803815
if not isinstance(other, Role):
@@ -1068,7 +1080,10 @@ def __init__(
10681080
self.version = version
10691081
self.length = length
10701082
self.hashes = hashes
1071-
self.unrecognized_fields: Dict[str, Any] = unrecognized_fields or {}
1083+
if unrecognized_fields is None:
1084+
unrecognized_fields = {}
1085+
1086+
self.unrecognized_fields = unrecognized_fields
10721087

10731088
def __eq__(self, other: Any) -> bool:
10741089
if not isinstance(other, MetaFile):
@@ -1454,7 +1469,10 @@ def __init__(
14541469
)
14551470

14561471
self.roles = roles
1457-
self.unrecognized_fields = unrecognized_fields or {}
1472+
if unrecognized_fields is None:
1473+
unrecognized_fields = {}
1474+
1475+
self.unrecognized_fields = unrecognized_fields
14581476

14591477
def __eq__(self, other: Any) -> bool:
14601478
if not isinstance(other, Delegations):
@@ -1532,7 +1550,10 @@ def __init__(
15321550
self.length = length
15331551
self.hashes = hashes
15341552
self.path = path
1535-
self.unrecognized_fields = unrecognized_fields or {}
1553+
if unrecognized_fields is None:
1554+
unrecognized_fields = {}
1555+
1556+
self.unrecognized_fields = unrecognized_fields
15361557

15371558
@property
15381559
def custom(self) -> Any:

0 commit comments

Comments
 (0)