From: Daniele Varrazzo Date: Sat, 4 Jan 2025 01:11:16 +0000 (+0100) Subject: chore: fix problems reported by mypy 1.14.1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F982%2Fhead;p=thirdparty%2Fpsycopg.git chore: fix problems reported by mypy 1.14.1 --- diff --git a/tests/types/test_datetime.py b/tests/types/test_datetime.py index 907abe6dd..a387d6dc4 100644 --- a/tests/types/test_datetime.py +++ b/tests/types/test_datetime.py @@ -775,16 +775,17 @@ def as_date(s): return dt.date(*map(int, s.split(","))) if "," in s else getattr(dt.date, s) -def as_time(s): - if "~" in s: - s, off = s.split("~") +def as_time(ts): + if "~" in ts: + ts, off = ts.split("~") else: off = None - if "," in s: - rv = dt.time(*map(int, s.split(","))) + if "," in ts: + h, m, s, u = (tuple(map(int, ts.split(","))) + (0,) * 3)[:4] + rv = dt.time(h, m, s, u) else: - rv = getattr(dt.time, s) + rv = getattr(dt.time, ts) if off: rv = rv.replace(tzinfo=as_tzinfo(off)) @@ -802,11 +803,12 @@ def as_dt(s): return rv -def as_naive_dt(s): - if "," in s: - rv = dt.datetime(*map(int, s.split(","))) +def as_naive_dt(ts): + if "," in ts: + y, m, d, h, mi, s, u = (tuple(map(int, ts.split(","))) + (0,) * 6)[:7] + rv = dt.datetime(y, m, d, h, mi, s, u) else: - rv = getattr(dt.datetime, s) + rv = getattr(dt.datetime, ts) return rv