Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F11023473
D6797.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
811 B
Subscribers
None
D6797.id.diff
View Options
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
Details
Attached
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
Attached To
D6797: model: Add support for None to the type checker
Event Timeline
Log In to Comment