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
pendulum.DateTime using hardcoded pendulum.datetime in methods #203
I found 4 methods in pendulum.datetime that return a new pendulum.datetime object. The pendulum.datetime class is hardcoded in these, which could cause some inconstistencies when subclassing:
import pendulum
class MyDateTime(pendulum.DateTime):
pass
MyDateTime.now()
The output is an instance of pendulum.DateTime while I would expect it to be an instance of MyDateTime.
This makes extending the library a bit of a hassle.
changed the title [-]pendulum.datetime using hardcoded class in methods[/-][+]pendulum.DateTime using hardcoded pendulum.datetime in methods[/+]on May 9, 2018
Hey @sdispater, I think I can handle this if you wish.
What made you move the implementations from DateTime to __init__.py in v2?
The issue could be fixed by moving the functions back to DateTime (as private methods if there are not part of the public API). Then use now = DateTime.now in __init__.py like in v1.
for what it's worth, I ran into this as well, trying to make our code compatible with 2.x. There are similar problems with the parse method, because the parser will just call directly out to pendulum.datetime et al.
I'm also struggling to understand what's going on with __new__, the constructor, and generally the original intent to have all datetimes be timezone aware by default.
I think its effectively infeasible for us to upgrade, unfortunately.
Activity
[-]pendulum.datetime using hardcoded class in methods[/-][+]pendulum.DateTime using hardcoded pendulum.datetime in methods[/+]Delgan commentedon May 18, 2018
Hey @sdispater, I think I can handle this if you wish.
What made you move the implementations from
DateTimeto__init__.pyin v2?The issue could be fixed by moving the functions back to
DateTime(as private methods if there are not part of the public API). Then usenow = DateTime.nowin__init__.pylike in v1.Do you have any other plan?
DanCardin commentedon Jul 9, 2019
for what it's worth, I ran into this as well, trying to make our code compatible with 2.x. There are similar problems with the
parsemethod, because the parser will just call directly out topendulum.datetimeet al.I'm also struggling to understand what's going on with
__new__, the constructor, and generally the original intent to have all datetimes be timezone aware by default.I think its effectively infeasible for us to upgrade, unfortunately.