Skip to content

Commit 1b30c68

Browse files
committed
style: fix UP038 isinstance union syntax in _types.py (Python >=3.11)
1 parent 3c050e2 commit 1b30c68

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

coordinode/coordinode/_types.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ def to_property_value(py_val: PyValue) -> Any:
3333
pv.string_value = py_val
3434
elif isinstance(py_val, bytes):
3535
pv.bytes_value = py_val
36-
elif isinstance(py_val, (list, tuple)):
36+
elif isinstance(py_val, list | tuple):
3737
# Homogeneous float list → Vector; mixed/str list → PropertyList.
3838
# bool is a subclass of int, so exclude it explicitly — [True, False] must
3939
# not be serialised as a Vector of 1.0/0.0 but as a PropertyList.
40-
if py_val and all(isinstance(v, (int, float)) and not isinstance(v, bool) for v in py_val):
40+
# list | tuple union syntax is valid in isinstance() for Python ≥3.10 (PEP 604).
41+
# This project targets Python ≥3.11 (pyproject.toml: requires-python = ">=3.11").
42+
if py_val and all(isinstance(v, int | float) and not isinstance(v, bool) for v in py_val):
4143
vec = Vector(values=[float(v) for v in py_val])
4244
pv.vector_value.CopyFrom(vec)
4345
else:

0 commit comments

Comments
 (0)