Skip to content

Commit

Permalink
Remove pytz from the package (#467)
Browse files Browse the repository at this point in the history
* Change from astimezone to replace for UTC

* Remove pytz from package
  • Loading branch information
klaasnicolaas committed Apr 19, 2024
1 parent 8658093 commit 830c139
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 52 deletions.
47 changes: 7 additions & 40 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ packages = [
aiohttp = ">=3.0.0"
python = "^3.11"
yarl = ">=1.6.0"
pytz = ">=2024.1,<2024.2.0"

[tool.poetry.urls]
"Bug Tracker" = "https://github.com/klaasnicolaas/python-liege/issues"
Expand All @@ -47,7 +46,6 @@ pytest = "8.1.1"
pytest-asyncio = "0.23.6"
pytest-cov = "5.0.0"
ruff = "0.4.0"
types-pytz = "2024.1.0.20240417"
yamllint = "1.35.1"

[tool.coverage.run]
Expand Down
8 changes: 2 additions & 6 deletions src/liege/liege.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,10 @@ async def _request(
response.raise_for_status()
except TimeoutError as exception:
msg = "Timeout occurred while connecting to the Open Data Platform API."
raise ODPLiegeConnectionError(
msg,
) from exception
raise ODPLiegeConnectionError(msg) from exception
except (ClientError, socket.gaierror) as exception:
msg = "Error occurred while communicating with Open Data Platform API."
raise ODPLiegeConnectionError(
msg,
) from exception
raise ODPLiegeConnectionError(msg) from exception

content_type = response.headers.get("Content-Type", "")
if "application/json" not in content_type:
Expand Down
6 changes: 2 additions & 4 deletions src/liege/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
from __future__ import annotations

from dataclasses import dataclass
from datetime import datetime
from datetime import UTC, datetime
from typing import Any

import pytz


@dataclass
class Garage:
Expand Down Expand Up @@ -130,7 +128,7 @@ def strptime(date_string: str, date_format: str, default: None = None) -> Any:
"""
try:
return datetime.strptime(date_string, date_format).astimezone(tz=pytz.utc)
return datetime.strptime(date_string, date_format).replace(tzinfo=UTC)
except (ValueError, TypeError):
return default

Expand Down

0 comments on commit 830c139

Please sign in to comment.