fix mypy errors after version update

This commit is contained in:
Dima Gerasimov 2023-10-01 23:30:50 +01:00 committed by karlicoss
parent 8cd74a9fc4
commit fabcbab751
3 changed files with 15 additions and 9 deletions

11
demo.py
View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
from subprocess import check_call, DEVNULL
from shutil import copy, copytree
from shutil import copytree, ignore_patterns
import os
from os.path import abspath
from sys import executable as python
@ -9,12 +9,17 @@ from pathlib import Path
my_repo = Path(__file__).absolute().parent
def run():
def run() -> None:
# uses fixed paths; worth it for the sake of demonstration
# assumes we're in /tmp/my_demo now
# 1. clone git@github.com:karlicoss/my.git
copytree(my_repo, 'my_repo', symlinks=True)
copytree(
my_repo,
'my_repo',
symlinks=True,
ignore=ignore_patterns('.tox*'), # tox dir might have broken symlinks while tests are running in parallel
)
# 2. prepare repositories you'd be using. For this demo we only set up Hypothesis
tox = 'TOX' in os.environ

View file

@ -115,14 +115,15 @@ def pre_dataframe() -> Iterable[Res[SleepEntry]]:
yield group[0]
else:
err = RuntimeError(f'Multiple sleeps per night, not supported yet: {group}')
set_error_datetime(err, dt=dd)
set_error_datetime(err, dt=dd) # type: ignore[arg-type]
logger.exception(err)
yield err
def dataframe():
dicts: List[Dict] = []
dicts: List[Dict[str, Any]] = []
for s in pre_dataframe():
d: Dict[str, Any]
if isinstance(s, Exception):
dt = extract_error_datetime(s)
d = {
@ -141,7 +142,7 @@ def dataframe():
}
dicts.append(d)
import pandas as pd # type: ignore
import pandas as pd
return pd.DataFrame(dicts)
# TODO tz is in sleeps json

View file

@ -15,7 +15,7 @@ from typing import Dict, Any, NamedTuple
# print(line)
import matplotlib.pyplot as plt # type: ignore
from numpy import genfromtxt # type: ignore
from numpy import genfromtxt
import matplotlib.pylab as pylab # type: ignore
pylab.rcParams['figure.figsize'] = (32.0, 24.0)
@ -109,7 +109,7 @@ dates = [parse_date(u.date, yearfirst=True, dayfirst=False) for u in useful]
# TODO don't need this anymore? it's gonna be in dashboards package
from kython.plotting import plot_timestamped # type: ignore
for attr, lims, mavg, fig in [ # type: ignore
for attr, lims, mavg, fig in [
('light', (0, 400), 5, None),
('deep', (0, 600), 5, None),
('total', (200, 600), 5, None),
@ -128,7 +128,7 @@ for attr, lims, mavg, fig in [ # type: ignore
if mavg is not None:
mavgs.append((mavg, 'green'))
fig = plot_timestamped(
dts, # type: ignore
dts,
[getattr(u, attr) for u in useful],
marker='.',
ratio=(16, 4),