general/ci: mypy check tests
This commit is contained in:
parent
c63177e186
commit
07e7c62d02
7 changed files with 37 additions and 14 deletions
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
|
@ -50,12 +50,12 @@ jobs:
|
|||
- run: bash scripts/ci/run
|
||||
|
||||
- if: matrix.platform == 'ubuntu-latest' # no need to compute coverage for other platforms
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: .coverage.mypy-misc_${{ matrix.platform }}_${{ matrix.python-version }}
|
||||
path: .coverage.mypy-misc/
|
||||
- if: matrix.platform == 'ubuntu-latest' # no need to compute coverage for other platforms
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: .coverage.mypy-core_${{ matrix.platform }}_${{ matrix.python-version }}
|
||||
path: .coverage.mypy-core/
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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:
|
||||
|
|
12
tox.ini
12
tox.ini
|
@ -80,7 +80,7 @@ allowlist_externals = cat
|
|||
commands =
|
||||
pip install -e .[testing,optional]
|
||||
pip install orgparse # used it core.orgmode?
|
||||
# todo add tests?
|
||||
|
||||
{envpython} -m mypy --install-types --non-interactive \
|
||||
-p my.core \
|
||||
--txt-report .coverage.mypy-core \
|
||||
|
@ -88,10 +88,16 @@ commands =
|
|||
{posargs}
|
||||
cat .coverage.mypy-core/index.txt
|
||||
|
||||
# todo hmm might be better to move modules test in a separate subpackage?
|
||||
{envpython} -m mypy --install-types --non-interactive \
|
||||
tests \
|
||||
--exclude 'tests/(bluemaestro|emfit|takeout|pdfs|jawbone).py'
|
||||
|
||||
|
||||
# specific modules that are known to be mypy compliant (to avoid false negatives)
|
||||
# todo maybe split into separate jobs? need to add comment how to run
|
||||
[testenv:mypy-misc]
|
||||
allowlist_externals = cat
|
||||
commands =
|
||||
pip install -e .[testing,optional]
|
||||
|
||||
|
@ -132,6 +138,10 @@ commands =
|
|||
--html-report .coverage.mypy-misc \
|
||||
{posargs}
|
||||
# txt report is a bit more convenient to view on CI
|
||||
cat .coverage.mypy-misc/index.txt
|
||||
|
||||
{envpython} -m mypy --install-types --non-interactive \
|
||||
tests
|
||||
|
||||
# note: this comment doesn't seem relevant anymore, but keeping it in case the issue happens again
|
||||
# > ugh ... need to reset HOME, otherwise user's site-packages are somehow leaking into mypy's path...
|
||||
|
|
Loading…
Add table
Reference in a new issue