general/ci: mypy check tests

This commit is contained in:
Dima Gerasimov 2023-02-20 23:57:31 +00:00 committed by karlicoss
parent c63177e186
commit 07e7c62d02
7 changed files with 37 additions and 14 deletions

View file

@ -1,13 +1,26 @@
#!/usr/bin/env python3
from pathlib import Path
from typing import TYPE_CHECKING, Iterator, Any
from more_itertools import one
import pytest # type: ignore
import pytest
if TYPE_CHECKING:
from my.bluemaestro import Measurement
else:
Measurement = Any
def ok_measurements() -> Iterator[Measurement]:
from my.bluemaestro import measurements
for m in measurements():
assert not isinstance(m, Exception)
yield m
def test() -> None:
from my.bluemaestro import measurements
res2020 = [m for m in measurements() if '2020' in str(m.dt)]
res2020 = [m for m in ok_measurements() if '2020' in str(m.dt)]
tp = [x for x in res2020 if x.temp == 2.1]
assert len(tp) > 0
@ -24,8 +37,7 @@ def test() -> None:
def test_old_db() -> None:
from my.bluemaestro import measurements
res = list(measurements())
res = list(ok_measurements())
r1 = one(x for x in res if x.dt.strftime('%Y%m%d %H:%M:%S') == '20181003 09:07:00')
r2 = one(x for x in res if x.dt.strftime('%Y%m%d %H:%M:%S') == '20181003 09:19:00')

View file

@ -4,7 +4,7 @@ from datetime import date, time
# todo private test.. move away
def test_tz() -> None:
from my.jawbone import sleeps_by_date
from my.jawbone import sleeps_by_date # type: ignore[attr-defined]
sleeps = sleeps_by_date()
for s in sleeps.values():
assert s.sleep_start.tzinfo is not None

View file

@ -23,7 +23,8 @@ def test_with_error(with_config, tmp_path: Path) -> None:
g = root / 'garbage.pdf'
g.write_text('garbage')
from my.config import pdfs
del pdfs.roots # meh. otherwise legacy config value 'wins'
# meh. otherwise legacy config value 'wins'
del pdfs.roots # type: ignore[attr-defined]
pdfs.paths = (root,)
from my.pdfs import annotations

View file

@ -13,7 +13,7 @@ from more_itertools import ilen
def test_location_perf() -> None:
# 2.80 s for 10 iterations and 10K points
# TODO try switching to jq and see how it goes? not sure..
print(ilen(islice(LT.iter_locations(), 0, 10000)))
print(ilen(islice(LT.iter_locations(), 0, 10000))) # type: ignore
# in theory should support any HTML takeout file?

View file

@ -6,11 +6,11 @@ from my.core.cfg import tmp_config
import pytest
def _init_default_config():
def _init_default_config() -> None:
import my.config
class default_config:
count = 5
my.config.simple = default_config # type: ignore[attr-defined]
my.config.simple = default_config # type: ignore[attr-defined,assignment,misc]
def test_tmp_config() -> None: