Skip to content

Commit

Permalink
use type(None) instead
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaps0dy committed May 10, 2024
1 parent 00f38cd commit 2011aee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 2 additions & 3 deletions databind/src/databind/json/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import datetime
import decimal
import enum
from types import NoneType
import typing as t

from typeapi import (
Expand Down Expand Up @@ -395,7 +394,7 @@ class PlainDatatypeConverter(Converter):
(int, float): float,
(float, int): _int_lossless,
(bool, bool): bool,
(NoneType, NoneType): lambda x: x,
(type(None), type(None)): lambda x: x,
}

# Used only during deserialization if the #fieldinfo.strict is disabled.
Expand All @@ -408,7 +407,7 @@ class PlainDatatypeConverter(Converter):
(int, str): str,
(float, str): str,
(bool, str): str,
(NoneType, NoneType): lambda x: x,
(type(None), type(None)): lambda x: x,
}
)

Expand Down
3 changes: 1 addition & 2 deletions databind/src/databind/json/tests/converters_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import decimal
import enum
import sys
from types import NoneType
import typing as t
import uuid
from collections import namedtuple
Expand Down Expand Up @@ -80,7 +79,7 @@ def test_plain_datatype_converter(direction: Direction) -> None:
mapper.convert(direction, "foobar", int)

# None should behave the same in both cases
assert mapper.convert(direction, None, NoneType) is None
assert mapper.convert(direction, None, type(None)) is None
assert mapper.convert(direction, None, None) is None


Expand Down

0 comments on commit 2011aee

Please sign in to comment.