Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pendulum dependency #453

Open
massi1008 opened this issue Oct 28, 2024 · 2 comments
Open

Remove pendulum dependency #453

massi1008 opened this issue Oct 28, 2024 · 2 comments
Assignees
Labels
needs-triage Needs to be reviewed
Milestone

Comments

@massi1008
Copy link

Hello,
as discusses over in the pendulum repo that library is "on live support" with the owner being more or less absent.
A big problem is, that there are no wheels for pendulum under Python 3.13. That means that rust/cargo is necessary to install/build pendulum (and in extension fastapi-cache) under that python versions. In my use case that is an additional bothersome complexity; that is why I am exploring ways to remedy this.

fastapi-cache only uses pendulum in one instance, for date/datetime encoding.
Unfortunately I do not fully understand this use case.

  1. Why is this encoding here even necessary?
  2. Is it possible to remove this encoding, or replace it with something from the main library?

Hopefully pendulum can gain some active maintainers and provide wheels for current and future python versions but until then it might be smart to detach from that library.

@vicchi vicchi added the needs-triage Needs to be reviewed label Nov 9, 2024
@vicchi vicchi self-assigned this Nov 9, 2024
@vicchi vicchi added this to the Version 0.3.0 milestone Nov 9, 2024
@vicchi
Copy link
Collaborator

vicchi commented Nov 9, 2024

@massi1008 After an admittedly cursory look, it would appear that Pendulum is used to parse and validate datetime.date and datetime.datetime objects during JSON encoding. It should, in principle, be possible to swap out Pendulum for python-dateutil's parsers.

@Langdi
Copy link

Langdi commented Nov 22, 2024

A thing I observed is that, contrary to their documentation, pendulum is not a drop-in replacement for datetime.datetime, because it does not support naive timestamps:

It also removes the notion of naive datetimes: each DateTime instance is timezone-aware and by default in UTC for ease of use.
(https://github.com/sdispater/pendulum?tab=readme-ov-file#why-pendulum)

I cannot understand their reason for this, but it's clearly a design decision and won't be changed there.

For fastapi_cache this means naive timestamps can never be (correctly) deserialized.

I.e. even in the most basic example

>>> t=pendulum.parse("2020-01-01 15:00:00")
>>> t
DateTime(2020, 1, 1, 15, 0, 0, tzinfo=Timezone('UTC')

pendulum hallucinates a UTC timezone out of nowhere.

So even without the maintainer problem of pendulum, this dependency is quite problematic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage Needs to be reviewed
Projects
None yet
Development

No branches or pull requests

3 participants