geopython / OWSLib

OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service (hence OWS) interface standards, and their related content models.
https://owslib.readthedocs.io
BSD 3-Clause "New" or "Revised" License
392 stars 278 forks source link

Remove dependency on the Pytz library #949

Closed spillner closed 1 month ago

spillner commented 1 month ago

Pytz no longer supports the latest Python releases, and not much of it was actually used by OWSLib anyway.

Recreated the previous PR #921 to permit branching my source repository, to better manage the rebase and elide false-positive merge conflicts reported by GitHub.

coveralls commented 1 month ago

Coverage Status

coverage: 60.113% (-0.02%) from 60.128% when pulling 5e8f39ade909cf0ecbf95c74d41a636267fc0999 on spillner:remove-pytz into d4e7080531cd4805ad23c7cd7829e53f15afdbcc on geopython:master.

geographika commented 1 month ago

Thanks @spillner for updating the pull request. Would it be possible to add a very simple test to test_util.py to parse a date using the new TimeZone_UTC class and check the output?

I'm +1 on merging once that is in place.

geographika commented 1 month ago

Tested the branch locally - all working as expected:

>>> import pytz
>>> from datetime import datetime, timedelta
>>> dt = datetime.utcnow()
>>> dt.replace(tzinfo=pytz.utc)
datetime.datetime(2024, 10, 8, 10, 7, 59, 167706, tzinfo=<UTC>)
>>> from owslib.util import TimeZone_UTC
>>> datetime.utcnow().replace(tzinfo=TimeZone_UTC())
datetime.datetime(2024, 10, 8, 10, 9, 31, 262084, tzinfo=<owslib.util.TimeZone_UTC object at 0x0000015D9D187CD0>)
spillner commented 1 month ago

Added two unit tests, one for datetime normalization as a standalone operation, and one for proper operation of extract_time() as a whole.

I also took advantage of the shift to 3.10 and newer to drop the TimeZone_UTC class in favor of the standard datetime.timezone.utc. If anyone needs to restore support for 3.8 and earlier, you could just roll back the very last commit in this series.

geographika commented 1 month ago

@spillner - thanks very much for this. Removing a dependency and being able to use the standard library is excellent.