Skip to content
Advertisement

MyPy complains about datetime difference

MyPy complains about the line of code where bar is assigned the difference of two datetimes.

The type of foo is datetime.timedelta.

The error message from MyPy is “int not callable”.

What am I missing?

import arrow

t1 = arrow.now()
t2 = arrow.now()
foo = t1 - t2
bar = foo.total_seconds()

Advertisement

Answer

This turned out to be a known issue. For details, see the following:

https://github.com/python/mypy/issues/11613

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement