Skip to content

Commit 257b033

Browse files
committed
Add Rotation return type hint to Rotation.__mul__()
Without this type hint, some tools (including PyCharm) infer the more generic return type from typing.NamedTuple. To improve user experience, I've added a narrower type hint. However, the typing of this method is still 'flawed' as the only properly supported input is another Rotation. This is a narrower input type and therefore violates the Liskov substitution principle. Therefore I left the input parameter untyped. For more info: https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
1 parent 1256153 commit 257b033

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

jax/_src/scipy/spatial/transform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def __len__(self):
130130
else:
131131
return self.quat.shape[0]
132132

133-
def __mul__(self, other):
133+
def __mul__(self, other) -> Rotation:
134134
"""Compose this rotation with the other."""
135135
return Rotation.from_quat(_compose_quat(self.quat, other.quat))
136136

0 commit comments

Comments
 (0)