|
return PY_TYPES_MAPPING[type(value)](value) |
The library looks up types in a map using type(value) and raises an exception if the type does not exist in the map. This means any type derived from those types cannot be passed to the library. This creates errors at runtime for derived types that cannot be caught by type checkers. A common example will be StrEnum values, which are a subtype of str.
It's better to use isinstance(value, tuple(PY_TYPES_MAPPING)) to check for compatible types, and ensure that the underlying connection to ClickHouse accepts the types.
aiochclient/aiochclient/types.py
Line 456 in 463533c
The library looks up types in a map using
type(value)and raises an exception if the type does not exist in the map. This means any type derived from those types cannot be passed to the library. This creates errors at runtime for derived types that cannot be caught by type checkers. A common example will beStrEnumvalues, which are a subtype ofstr.It's better to use
isinstance(value, tuple(PY_TYPES_MAPPING))to check for compatible types, and ensure that the underlying connection to ClickHouse accepts the types.