You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TimeDelta includes some methods that don't apply #6828
It looks like TimeDelta includes some methods it probably shouldn't. For example TimeDelta.now() doesn't make sense, and maybe TimeDelta.light_travel_time.
@taldcroft - these methods are inherited directly from Time. To avoid this, should we have a TimeBase from which both Time and TimeDelta inherit? It is rather painful in that then isinstance(..., Time) will no longer catch a TimeDelta. But I'm not sure how else to solve this.
@mhvk - just to check, why should isinstance(..., Time) catch TimeDelta? Those are two quite different things, so in fact isinstance(..., Time) returning True for TimeDelta seems like a bug to me :)
@astrofrog - I agree with you that conceptually they're different and it makes sense to have a TimeBase. It is just that this may break code, as it is not how it is implemented...
Activity
mhvk commentedon Nov 10, 2017
@taldcroft - these methods are inherited directly from
Time. To avoid this, should we have aTimeBasefrom which bothTimeandTimeDeltainherit? It is rather painful in that thenisinstance(..., Time)will no longer catch aTimeDelta. But I'm not sure how else to solve this.Cadair commentedon Nov 11, 2017
Could some combo of ABCs and subclass hooks fix the
isinstance(..., TIme)work?taldcroft commentedon Nov 12, 2017
Good point. The only question is if we are getting into "perfect is the enemy of good" territory (unless @Cadair can produce the appropriate magic).
astrofrog commentedon Nov 12, 2017
@mhvk - just to check, why should
isinstance(..., Time)catchTimeDelta? Those are two quite different things, so in factisinstance(..., Time)returningTrueforTimeDeltaseems like a bug to me :)astrofrog commentedon Nov 12, 2017
Just to clarify my comment, here's what I get with the datetime module:
There's really no reason
TimeDeltashould be as a subclass ofTime(conceptually) so I think @mhvk's suggestion of aTimeBasemakes sense.mhvk commentedon Nov 12, 2017
@astrofrog - I agree with you that conceptually they're different and it makes sense to have a
TimeBase. It is just that this may break code, as it is not how it is implemented...