Skip to content

Commit

Permalink
Fix time subtraction (#1312)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carlstrom <[email protected]>
Co-authored-by: Shane Loretz <[email protected]>
  • Loading branch information
InvincibleRMC and sloretz authored Aug 8, 2024
1 parent b25877f commit 2949554
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rclpy/rclpy/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Protocol, Tuple, Union
from typing import overload, Protocol, Tuple, Union

import builtin_interfaces.msg

Expand Down Expand Up @@ -95,6 +95,12 @@ def __add__(self, other: Duration) -> 'Time':
def __radd__(self, other: Duration) -> 'Time':
return self.__add__(other)

@overload
def __sub__(self, other: 'Time') -> Duration: ...

@overload
def __sub__(self, other: Duration) -> 'Time': ...

def __sub__(self, other: Union['Time', Duration]) -> Union['Time', Duration]:
if isinstance(other, Time):
if self.clock_type != other.clock_type:
Expand Down

0 comments on commit 2949554

Please sign in to comment.