Skip to content

Commit 46ad1c9

Browse files
committed
DOC: Use correct constructor for unit subclasses.
Use `object.__new__` was raising for _everything_ that wasn't an `object` (aka, everything in the examples). It's necessary to use the actual class's `__new__`, which fixes the special initialization that was in the `try`.
1 parent 513c00b commit 46ad1c9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

examples/units/basic_units.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def __new__(cls, value, unit):
127127
methods['__getitem__'] = cls._getitem
128128
subcls = type(f'TaggedValue_of_{value_class.__name__}',
129129
(cls, value_class), methods)
130-
return object.__new__(subcls)
130+
return value_class.__new__(subcls)
131131
except TypeError:
132132
return object.__new__(cls)
133133

0 commit comments

Comments
 (0)