From bf6a96a44dd6f67a0dc1b4330d256d7fb8905bfd Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Mon, 20 Feb 2023 23:40:13 +0000 Subject: [PATCH] general/ci: clean up mypy-misc pipeline, only exclude specific files instead marked some module configs which aren't really ready for public use as type: ignore --- my/body/blood.py | 2 +- my/body/weight.py | 2 +- my/books/kobo.py | 2 +- my/coding/codeforces.py | 4 +- my/coding/topcoder.py | 4 +- my/config.py | 82 ++++++++++++++++++++++++++++++++++ my/fbmessenger/android.py | 2 +- my/jawbone/__init__.py | 2 +- my/jawbone/plots.py | 6 +-- my/photos/main.py | 2 +- my/runnerup.py | 2 +- my/telegram/telegram_backup.py | 2 +- my/twitter/archive.py | 2 +- my/vk/favorites.py | 3 +- tox.ini | 79 +++++++++++++------------------- 15 files changed, 132 insertions(+), 64 deletions(-) diff --git a/my/body/blood.py b/my/body/blood.py index c1d66e2..e282068 100644 --- a/my/body/blood.py +++ b/my/body/blood.py @@ -13,7 +13,7 @@ import pandas as pd # type: ignore import orgparse -from my.config import blood as config +from my.config import blood as config # type: ignore[attr-defined] class Entry(NamedTuple): diff --git a/my/body/weight.py b/my/body/weight.py index 28688b6..659b759 100644 --- a/my/body/weight.py +++ b/my/body/weight.py @@ -10,7 +10,7 @@ from ..core.error import Res, set_error_datetime, extract_error_datetime from .. import orgmode -from my.config import weight as config +from my.config import weight as config # type: ignore[attr-defined] log = LazyLogger('my.body.weight') diff --git a/my/books/kobo.py b/my/books/kobo.py index d5f5416..2a469d0 100644 --- a/my/books/kobo.py +++ b/my/books/kobo.py @@ -4,4 +4,4 @@ warnings.high('my.books.kobo is deprecated! Please use my.kobo instead!') from ..core.util import __NOT_HPI_MODULE__ -from ..kobo import * +from ..kobo import * # type: ignore[no-redef] diff --git a/my/coding/codeforces.py b/my/coding/codeforces.py index 3793988..a4c7de2 100644 --- a/my/coding/codeforces.py +++ b/my/coding/codeforces.py @@ -1,11 +1,13 @@ #!/usr/bin/env python3 -from my.config import codeforces as config +from my.config import codeforces as config # type: ignore[attr-defined] + from datetime import datetime, timezone from typing import NamedTuple import json from typing import Dict, Iterator + from ..core import get_files, Res, unwrap from ..core.compat import cached_property from ..core.konsume import ignore, wrap diff --git a/my/coding/topcoder.py b/my/coding/topcoder.py index 5711254..32a9ff8 100644 --- a/my/coding/topcoder.py +++ b/my/coding/topcoder.py @@ -1,11 +1,13 @@ #!/usr/bin/env python3 -from my.config import topcoder as config +from my.config import topcoder as config # type: ignore[attr-defined] + from datetime import datetime from typing import NamedTuple import json from typing import Dict, Iterator + from ..core import get_files, Res, unwrap, Json from ..core.compat import cached_property from ..core.error import Res, unwrap diff --git a/my/config.py b/my/config.py index 313b464..bfae86e 100644 --- a/my/config.py +++ b/my/config.py @@ -14,8 +14,14 @@ from my.core import init ### +from datetime import tzinfo +from pathlib import Path +from typing import List + + from my.core import Paths, PathIsh + class hypothesis: # expects outputs from https://github.com/karlicoss/hypexport # (it's just the standard Hypothes.is export format) @@ -139,6 +145,10 @@ class hackernews: export_path: Paths +class materialistic: + export_path: Paths + + class fbmessenger: class fbmessengerexport: export_db: PathIsh @@ -155,6 +165,11 @@ class twitter: class talon: export_path: Paths + +class twint: + export_path: Paths + + class browser: class export: export_path: Paths = '' @@ -167,3 +182,70 @@ class telegram: export_path: PathIsh = '' +class demo: + data_path: Paths + username: str + timezone: tzinfo + + +class simple: + count: int + + +class vk_messages_backup: + storage_path: Path + + +class kobo: + export_path: Paths + + +class feedly: + export_path: Paths + + +class feedbin: + export_path: Paths + + +class taplog: + export_path: Paths + + +class lastfm: + export_path: Paths + + +class rescuetime: + export_path: Paths + + +class runnerup: + export_path: Paths + + +class emfit: + export_path: Path + timezone: tzinfo + excluded_sids: List[str] + + +class foursquare: + export_path: Paths + + +class rtm: + export_path: Paths + + +class imdb: + export_path: Paths + + +class roamresearch: + export_path: Paths + username: str + + + + diff --git a/my/fbmessenger/android.py b/my/fbmessenger/android.py index 6a8a0eb..69555cb 100644 --- a/my/fbmessenger/android.py +++ b/my/fbmessenger/android.py @@ -113,7 +113,7 @@ def _process_db(db: sqlite3.Connection) -> Iterator[Res[Entity]]: yield s self_id = config.facebook_id - thread_users: Dict[str, List[str]] = {} + thread_users: Dict[str, List[Sender]] = {} for r in db.execute('SELECT * from thread_participants'): thread_key = r['thread_key'] user_key = r['user_key'] diff --git a/my/jawbone/__init__.py b/my/jawbone/__init__.py index 50932bf..89f104a 100644 --- a/my/jawbone/__init__.py +++ b/my/jawbone/__init__.py @@ -10,7 +10,7 @@ from ..core.common import LazyLogger logger = LazyLogger(__name__) -from my.config import jawbone as config +from my.config import jawbone as config # type: ignore[attr-defined] BDIR = config.export_dir diff --git a/my/jawbone/plots.py b/my/jawbone/plots.py index 195ddb5..5332fe6 100755 --- a/my/jawbone/plots.py +++ b/my/jawbone/plots.py @@ -85,7 +85,7 @@ def iter_useful(data_file: str): # TODO <<< hmm. these files do contain deep and light sleep?? # also steps stats?? -from my.config import jawbone as config +from my.config import jawbone as config # type: ignore[attr-defined] p = config.export_dir / 'old_csv' # TODO with_my? @@ -95,7 +95,7 @@ files = [ p / "2017.csv", ] -from kython import concat, parse_date +from kython import concat, parse_date # type: ignore useful = concat(*(list(iter_useful(str(f))) for f in files)) # for u in useful: @@ -108,7 +108,7 @@ dates = [parse_date(u.date, yearfirst=True, dayfirst=False) for u in useful] # TODO filter outliers? # TODO don't need this anymore? it's gonna be in dashboards package -from kython.plotting import plot_timestamped +from kython.plotting import plot_timestamped # type: ignore for attr, lims, mavg, fig in [ # type: ignore ('light', (0, 400), 5, None), ('deep', (0, 600), 5, None), diff --git a/my/photos/main.py b/my/photos/main.py index 6be3163..69e5a46 100644 --- a/my/photos/main.py +++ b/my/photos/main.py @@ -19,7 +19,7 @@ from ..core.common import LazyLogger, mcachew, fastermime from ..core.error import Res, sort_res_by from ..core.cachew import cache_dir -from my.config import photos as config +from my.config import photos as config # type: ignore[attr-defined] logger = LazyLogger(__name__) diff --git a/my/runnerup.py b/my/runnerup.py index 8e31770..6140236 100644 --- a/my/runnerup.py +++ b/my/runnerup.py @@ -13,7 +13,7 @@ from typing import Iterable from .core import Res, get_files from .core.common import isoparse, Json -import tcxparser +import tcxparser # type: ignore[import] from my.config import runnerup as config diff --git a/my/telegram/telegram_backup.py b/my/telegram/telegram_backup.py index 6c33e39..cd82577 100644 --- a/my/telegram/telegram_backup.py +++ b/my/telegram/telegram_backup.py @@ -51,7 +51,7 @@ def _message_from_row(r: sqlite3.Row, *, chats: Chats) -> Message: id=r['message_id'], time=time, chat=chat, - sender=sender, + sender=User(id=sender.id, name=sender.name), text=r['text'], ) diff --git a/my/twitter/archive.py b/my/twitter/archive.py index c59d7a1..bdd1497 100644 --- a/my/twitter/archive.py +++ b/my/twitter/archive.py @@ -12,7 +12,7 @@ except ImportError as ie: # must be caused by something else raise ie try: - from my.config import twitter as user_config # type: ignore[misc] + from my.config import twitter as user_config # type: ignore[misc,assignment] except ImportError: raise ie # raise the original exception.. must be something else else: diff --git a/my/vk/favorites.py b/my/vk/favorites.py index e6ccbf3..eb1a89b 100644 --- a/my/vk/favorites.py +++ b/my/vk/favorites.py @@ -3,7 +3,8 @@ from datetime import datetime import json from typing import NamedTuple, Iterable, Sequence, Optional -from my.config import vk as config + +from my.config import vk as config # type: ignore[attr-defined] class Favorite(NamedTuple): diff --git a/tox.ini b/tox.ini index 5ae76f3..a8af102 100644 --- a/tox.ini +++ b/tox.ini @@ -96,57 +96,38 @@ commands = pip install -e .[testing,optional] hpi module install --parallel \ - my.browser.export \ - my.orgmode \ - my.endomondo \ - my.github.ghexport \ - my.hypothesis \ - my.instapaper \ - my.pocket \ - my.reddit.rexport \ - my.reddit.pushshift \ - my.stackexchange.stexport \ - my.tinder.android \ - my.pinboard \ - my.arbtt \ - my.coding.commits \ - my.goodreads \ - my.pdfs \ - my.smscalls \ - my.location.gpslogger \ - my.location.via_ip \ - my.google.takeout.parser + my.arbtt \ + my.coding.commits \ + my.browser.export \ + my.github.ghexport \ + my.emfit \ + my.endomondo \ + my.fbmessenger.export \ + my.goodreads \ + my.google.takeout.parser \ + my.orgmode \ + my.hypothesis \ + my.instapaper \ + my.kobo \ + my.location.gpslogger \ + my.location.via_ip \ + my.pdfs \ + my.pinboard \ + my.pocket \ + my.reddit.pushshift \ + my.reddit.rexport \ + my.rescuetime \ + my.runnerup \ + my.stackexchange.stexport \ + my.smscalls \ + my.tinder.android + - # todo fuck. -p my.github isn't checking the subpackages?? wtf... - # guess it wants .pyi file?? {envpython} -m mypy --install-types --non-interactive \ - -p my.browser \ - -p my.endomondo \ - -p my.github.ghexport \ - -p my.github.gdpr \ - -p my.hypothesis \ - -p my.instapaper \ - -p my.pocket \ - -p my.smscalls \ - -p my.reddit \ - -p my.stackexchange.stexport \ - -p my.pinboard \ - -p my.body.exercise.cardio \ - -p my.body.exercise.cross_trainer \ - -p my.bluemaestro \ - -p my.location.google \ - -p my.location.google_takeout \ - -p my.location.via_ip \ - -p my.location.gpslogger \ - -p my.ip.common \ - -p my.time.tz.via_location \ - -p my.calendar.holidays \ - -p my.arbtt \ - -p my.coding.commits \ - -p my.goodreads \ - -p my.pdfs \ - -p my.bumble.android \ - -p my.tinder.android \ + -p my \ + --exclude 'my/coding/codeforces.py' \ + --exclude 'my/coding/topcoder.py' \ + --exclude 'my/jawbone/.*' \ --txt-report .coverage.mypy-misc \ --html-report .coverage.mypy-misc \ {posargs}