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
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.
The text was updated successfully, but these errors were encountered:
MrGreenTea
changed the title
pendulum.datetime using hardcoded class in methods
pendulum.DateTime using hardcoded pendulum.datetime in methods
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.
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:
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.
The text was updated successfully, but these errors were encountered: