From dd928964e6be25b41389683651b02c9a859089c1 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Sun, 19 Dec 2021 18:31:15 +0000 Subject: [PATCH] general: fix mypy errors after mypy and pytz stubs updates see https://github.com/python/typeshed/blame/968fd6d01d23470e0c8368e7ee7c43f54aaedc0e/stubs/pytz/pytz/tzinfo.pyi#L6 it says all concrete instances should not be None --- my/calendar/holidays.py | 4 ++-- my/core/common.py | 2 +- my/core/orgmode.py | 2 +- my/time/tz/via_location.py | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/my/calendar/holidays.py b/my/calendar/holidays.py index 567ddad..6fa3560 100644 --- a/my/calendar/holidays.py +++ b/my/calendar/holidays.py @@ -20,8 +20,8 @@ def _calendar(): # TODO would be nice to do it dynamically depending on the past timezones... tz = LTZ._get_tz(datetime.now()) assert tz is not None - - code = zone_to_countrycode(tz.zone) + zone = tz.zone; assert zone is not None + code = zone_to_countrycode(zone) Cal = registry.get_calendars()[code] return Cal() diff --git a/my/core/common.py b/my/core/common.py index ee7533c..96ab44c 100644 --- a/my/core/common.py +++ b/my/core/common.py @@ -572,7 +572,7 @@ def test_guess_datetime() -> None: def is_namedtuple(thing: Any) -> bool: # basic check to see if this is namedtuple-like _asdict = getattr(thing, '_asdict', None) - return _asdict and callable(_asdict) + return (_asdict is not None) and callable(_asdict) def asdict(thing: Any) -> Json: diff --git a/my/core/orgmode.py b/my/core/orgmode.py index f869bdd..5894b23 100644 --- a/my/core/orgmode.py +++ b/my/core/orgmode.py @@ -45,7 +45,7 @@ class TypedTable(Table): if len(header) == 2: # TODO later interpret first line as types header = header[1:] - tt._blocks = [header, *blocks[1:]] + setattr(tt, '_blocks', [header, *blocks[1:]]) return tt @property diff --git a/my/time/tz/via_location.py b/my/time/tz/via_location.py index 2d627ad..fe3cd69 100644 --- a/my/time/tz/via_location.py +++ b/my/time/tz/via_location.py @@ -67,7 +67,8 @@ def _iter_local_dates(start=0, stop=None) -> Iterator[DayWithZone]: warnings.append("local time goes backwards {ldt} ({tz}) < {pdt}") continue pdt = ldt - yield DayWithZone(day=ndate, zone=tz.zone) + z = tz.zone; assert z is not None + yield DayWithZone(day=ndate, zone=z) def most_common(l):