Page MenuHomeSoftware Heritage

D6797.id.diff
No OneTemporary

D6797.id.diff

diff --git a/swh/model/model.py b/swh/model/model.py
--- a/swh/model/model.py
+++ b/swh/model/model.py
@@ -96,6 +96,9 @@
if type_ is object or type_ is Any:
return True
+ if type_ is None:
+ return value is None
+
origin = getattr(type_, "__origin__", None)
# Non-generic type, check it directly
diff --git a/swh/model/tests/test_model.py b/swh/model/tests/test_model.py
--- a/swh/model/tests/test_model.py
+++ b/swh/model/tests/test_model.py
@@ -137,6 +137,7 @@
[None, bytearray(b"\x12\x34"), "123", 0, 123, (), (1, 2, 3), ImmutableDict()],
),
(str, ["", "123"], [None, b"123", b"", 0, (), (1, 2, 3), ImmutableDict()]),
+ (None, [None], [b"", b"123", "", "foo", 0, 123, ImmutableDict(), float("NaN")]),
# unions:
(
Optional[int],

File Metadata

Mime Type
text/plain
Expires
Wed, Sep 17, 4:37 PM (18 h, 42 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3225473

Event Timeline