Skip to content

Commit 1cad8f9

Browse files
Fix truediv type-checking for ValueType2 (#88)
- ValueType2 (the generic parameter of ValueArray ) was defined as invariant. - This prevents FrequencyArray (which is ValueArray[Frequency]) from being compatible with ValueArray[Value]. - As a result, mypy could not match the __truediv__ operator on ValueArray and fell back to Value.__rtruediv__ , which also failed. Fixes internal bug b/507121233
2 parents 143b06f + 6518c46 commit 1cad8f9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tunits/core/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class UnitArray:
129129

130130
NumericalT = TypeVar('NumericalT', default=float, bound=float | int)
131131
ValueType = TypeVar('ValueType', bound='Value')
132-
ValueType2 = TypeVar('ValueType2', default='Value', bound='Value')
132+
ValueType2 = TypeVar('ValueType2', default='Value', bound='Value', covariant=True)
133133
ArrayType = TypeVar('ArrayType', bound='ValueArray')
134134

135135
@overload

0 commit comments

Comments
 (0)