Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/tests-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
pip install -e .

- name: Run tests with coverage
# Use the --record-mode=rewrite if you need to re-record the cassetts.
run: |
python -m pytest -rxs --cov=erddapy tests

Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ repos:
- id: add-trailing-comma

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.10
rev: v0.17.1
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand Down Expand Up @@ -82,7 +82,7 @@ repos:
- id: pyproject-fmt

- repo: https://github.com/woodruffw/zizmor-pre-commit
rev: v1.30.1
rev: v1.31.1
hooks:
- id: zizmor

Expand Down
10 changes: 5 additions & 5 deletions erddapy/core/url.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""URL handling."""

import copy
import datetime
import datetime as dt
import functools
import io
from collections import OrderedDict
Expand Down Expand Up @@ -244,7 +244,7 @@ def _is_quoted(url: str) -> bool:


def parse_dates(
date_time: datetime.datetime | str,
date_time: dt.datetime | str,
*,
dayfirst: bool = False,
yearfirst: bool = False,
Expand All @@ -268,9 +268,9 @@ def parse_dates(

# Naive datetimes tzinfo must be replaced, tz-aware should be converted.
if not parse_date_time.tzinfo:
parse_date_time = parse_date_time.replace(tzinfo=datetime.UTC)
parse_date_time = parse_date_time.replace(tzinfo=dt.UTC)
else:
parse_date_time = parse_date_time.astimezone(datetime.UTC)
parse_date_time = parse_date_time.astimezone(dt.UTC)

return parse_date_time.timestamp()

Expand Down Expand Up @@ -351,7 +351,7 @@ def get_search_url( # noqa: PLR0913, PLR0917
search_for = parse.quote_plus(search_for)
base += "&searchFor={searchFor}"

# Convert dates from datetime.datetime to secs since 1970-01-01T00:00:00Z.
# Convert dates from dt.datetime to secs since 1970-01-01T00:00:00Z.
min_time = kwargs.pop("min_time", "")
max_time = kwargs.pop("max_time", "")
if min_time and not _check_substrings(min_time):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_erddapy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Test ERDDAP functionality."""

import datetime
import datetime as dt
from zoneinfo import ZoneInfo

import pytest
Expand All @@ -17,13 +17,13 @@

def test_parse_dates_utc_datetime():
"""UTC timestamp at 1970-1-1 must be 0."""
d = datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.UTC)
d = dt.datetime(1970, 1, 1, 0, 0, tzinfo=dt.UTC)
assert parse_dates(d) == 0


def test_parse_dates_nonutc_datetime():
"""Non-UTC timestamp at 1970-1-1 must have the zone offset."""
d = datetime.datetime(1970, 1, 1, tzinfo=ZoneInfo("US/Eastern"))
d = dt.datetime(1970, 1, 1, tzinfo=ZoneInfo("US/Eastern"))
assert parse_dates(d) == abs(d.utcoffset().total_seconds())


Expand Down
Loading