Skip to content

Time subclasses and using them to initialize Times #10654

Closed

Description

@mhvk

Time.__new__ has special treatment for Time instances, essentially passing them through with perhaps a scale change. It turned out this included TimeDelta, so that Time(TimeDelta(...)) returned a TimeDelta instance, which was surprising and caused #10651. In #10652, the bug was fixed by restricting the special case to instances of the class proper. But as @taldcroft notes, in general one would like for Time(TimeSubClass(...)) to work and to return a Time instance. It would be good to allow that.

Part of the problem is that TimeDelta should probably not be a subclass of Time - indeed, as noted in #6828 it shares methods such as .now() and .light_travel_time() that really make no sense. In #6828, it was suggested a better scheme might be to have both Time and TimeDelta inherit from a common TimeBase.

Activity

  1. self-assigned this
    on Aug 14, 2020
  2. pllim commented on Aug 14, 2020

    @pllim
    Member

    So, is this "enhancement" or "bug"? 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions