general: fix mypy errors after mypy and pytz stubs updates

see 968fd6d01d/stubs/pytz/pytz/tzinfo.pyi (L6)
it says all concrete instances should not be None
This commit is contained in:
Dima Gerasimov 2021-12-19 18:31:15 +00:00 committed by karlicoss
parent 9578b13fca
commit dd928964e6
4 changed files with 6 additions and 5 deletions

View file

@ -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()

View file

@ -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:

View file

@ -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

View file

@ -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):