Skip to content

Commit 3e7416e

Browse files
committed
Use is for type comparisons
1 parent 9f92f6c commit 3e7416e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: src/betterproto/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -944,9 +944,9 @@ def _postprocess_single(
944944
elif meta.proto_type == TYPE_MESSAGE:
945945
cls = self._betterproto.cls_by_field[field_name]
946946

947-
if cls == datetime:
947+
if cls is datetime:
948948
value = _Timestamp().parse(value).to_datetime()
949-
elif cls == timedelta:
949+
elif cls is timedelta:
950950
value = _Duration().parse(value).to_timedelta()
951951
elif meta.wraps:
952952
# This is a Google wrapper value message around a single
@@ -1105,9 +1105,9 @@ def to_dict(
11051105
elif field_is_repeated:
11061106
# Convert each item.
11071107
cls = self._betterproto.cls_by_field[field_name]
1108-
if cls == datetime:
1108+
if cls is datetime:
11091109
value = [_Timestamp.timestamp_to_json(i) for i in value]
1110-
elif cls == timedelta:
1110+
elif cls is timedelta:
11111111
value = [_Duration.delta_to_json(i) for i in value]
11121112
else:
11131113
value = [

0 commit comments

Comments
 (0)