Closed jackklika closed 8 months ago
@g-battaglia Hello, can you review this PR?
Hello, thank you very much for the pull request, I've been pretty busy lately so I was not able to take a good look a the PR, I'll try to check it and merge this week. Sorry for the delay!
@jackklika Ok I've just merged it and released on PyPI, since the change it's potentially breaking some dependencies the version is 4.3.0
Overview
pyproject.toml
.dict()
and.json()
) to their new pydantic 2 namesLunarPhaseModel
degrees_between_s_m
attribute was being cast to int and changed expected svgs accordinglyAll tests are passing after these changes.
Rationale
Pydantic v1 will not be supported in June 30, 2025 according to the pydantic version policy. It's a long ways away, but will need to happen eventually. This was a quick fix so I implemented it.
Additionally if a project that uses this package is using pydantic 2, it will be unable to use the latest
4.2
version of this package that adds pydantic 1 support. This is what led me to make the change :-)The only difficulties I anticipate are if projects that use this or dependent packages require pydantic 1 vs pydantic 2. But these will likely switch to pydantic 2 in the future. After all pydantic 2 is not released until summer 2024 so this could be premature. But merge if you'd like.
Float/int presidence bug
Initially I ran the pytest suite with the pydantic 2 upgrade and saw the following failures. These were only happening on pydantic 2 and worked on pydantic 1.
I narrowed this down to the ordering of
Union[int, float]
in the following:Where it was casting to floats to ints in pydantic 1 since by default it was doing
left_to_right
union mode. Since pydantic 2 is using "smart" union it is correctly keeps it as a float. See docs here.I changed the order of the union to make this more explicit and fixed the tests to the new (correct) svg values.