diff --git a/my/arbtt.py b/my/arbtt.py index 94590af..e672e5b 100644 --- a/my/arbtt.py +++ b/my/arbtt.py @@ -21,7 +21,7 @@ def inputs() -> Sequence[Path]: return get_files(user_config.logfiles) -from .core import dataclass, Json, Res, PathIsh, datetime_aware +from .core import dataclass, Json, PathIsh, datetime_aware from .core.common import isoparse diff --git a/my/bluemaestro.py b/my/bluemaestro.py index 97668c3..3b73b79 100755 --- a/my/bluemaestro.py +++ b/my/bluemaestro.py @@ -71,7 +71,7 @@ def measurements() -> Iterable[Measurement]: try: datas = db.execute(f'SELECT "{f.name}" as name, Time, Temperature, Humidity, Pressure, Dewpoint FROM data ORDER BY log_index') oldfmt = True - db_dts = list(db.execute(f'SELECT last_download FROM info'))[0][0] + db_dts = list(db.execute('SELECT last_download FROM info'))[0][0] if db_dts == 'N/A': # ??? happens for 20180923-20180928 continue diff --git a/my/body/blood.py b/my/body/blood.py index dfb86b6..51a5114 100755 --- a/my/body/blood.py +++ b/my/body/blood.py @@ -5,8 +5,7 @@ Blood tracking (manual org-mode entries) from datetime import datetime from typing import Iterable, NamedTuple, Optional -from ..core.common import listify -from ..core.error import Res, echain +from ..core.error import Res from ..core.orgmode import parse_org_datetime, one_table diff --git a/my/coding/codeforces.py b/my/coding/codeforces.py index 4a5007d..659a2d9 100644 --- a/my/coding/codeforces.py +++ b/my/coding/codeforces.py @@ -3,13 +3,12 @@ from my.config import codeforces as config from datetime import datetime from typing import NamedTuple -from pathlib import Path import json -from typing import Dict, Iterator, Any +from typing import Dict, Iterator from ..common import cproperty, get_files from ..error import Res, unwrap -from ..core.konsume import zoom, ignore, wrap +from ..core.konsume import ignore, wrap from kython import fget # TODO remove diff --git a/my/coding/commits.py b/my/coding/commits.py index fcb3170..87db35c 100644 --- a/my/coding/commits.py +++ b/my/coding/commits.py @@ -39,7 +39,7 @@ def config() -> commits_cfg: ########################## import git # type: ignore -from git.repo.fun import is_git_dir, find_worktree_git_dir # type: ignore +from git.repo.fun import is_git_dir # type: ignore log = LazyLogger(__name__, level='info') diff --git a/my/coding/topcoder.py b/my/coding/topcoder.py index 419cbe1..43a2c8a 100644 --- a/my/coding/topcoder.py +++ b/my/coding/topcoder.py @@ -3,9 +3,8 @@ from my.config import topcoder as config from datetime import datetime from typing import NamedTuple -from pathlib import Path import json -from typing import Dict, Iterator, Any +from typing import Dict, Iterator from ..common import cproperty, get_files from ..error import Res, unwrap diff --git a/my/core/cfg.py b/my/core/cfg.py index a1fc478..b23fa86 100644 --- a/my/core/cfg.py +++ b/my/core/cfg.py @@ -26,7 +26,6 @@ def make_config(cls: Type[C], migration: Callable[[Attrs], Attrs]=lambda x: x) - F = TypeVar('F') from contextlib import contextmanager -import inspect from typing import Iterator @contextmanager def override_config(config: F) -> Iterator[F]: diff --git a/my/core/core_config.py b/my/core/core_config.py index 7c52b0a..a883db4 100644 --- a/my/core/core_config.py +++ b/my/core/core_config.py @@ -99,7 +99,7 @@ config = make_config(Config) ### tests start -from typing import Iterator, Any +from typing import Iterator from contextlib import contextmanager as ctx @ctx def _reset_config() -> Iterator[Config]: diff --git a/my/core/init.py b/my/core/init.py index 3c607c6..1fc9e88 100644 --- a/my/core/init.py +++ b/my/core/init.py @@ -29,7 +29,6 @@ del ModuleType def setup_config() -> None: import sys import warnings - from typing import Optional from .preinit import get_mycfg_dir mycfg_dir = get_mycfg_dir() diff --git a/my/core/orgmode.py b/my/core/orgmode.py index c769dc3..f869bdd 100644 --- a/my/core/orgmode.py +++ b/my/core/orgmode.py @@ -36,7 +36,6 @@ def one_table(o: OrgNode) -> Table: return one(collect(o, lambda n: (x for x in n.body_rich if isinstance(x, Table)))) -from typing import Iterator, Dict, Any class TypedTable(Table): def __new__(cls, orig: Table) -> 'TypedTable': tt = super().__new__(TypedTable) diff --git a/my/core/pandas.py b/my/core/pandas.py index 03450f2..9cf037f 100644 --- a/my/core/pandas.py +++ b/my/core/pandas.py @@ -5,7 +5,7 @@ Various pandas helpers and convenience functions # NOTE: this file is meant to be importable without Pandas installed from datetime import datetime from pprint import pformat -from typing import Optional, TYPE_CHECKING, Any, Iterable, Type, List, Dict +from typing import Optional, TYPE_CHECKING, Any, Iterable, Type, Dict from . import warnings, Res from .common import LazyLogger, Json, asdict diff --git a/my/core/time.py b/my/core/time.py index fec90ba..b55fae3 100644 --- a/my/core/time.py +++ b/my/core/time.py @@ -1,5 +1,5 @@ from functools import lru_cache -from datetime import datetime, tzinfo +from datetime import tzinfo from typing import Sequence import pytz # type: ignore diff --git a/my/core/util.py b/my/core/util.py index 21850a6..222cdec 100644 --- a/my/core/util.py +++ b/my/core/util.py @@ -3,7 +3,6 @@ from itertools import chain from importlib import import_module import os import pkgutil -import re import sys from typing import List, Iterable, Optional diff --git a/my/emfit/__init__.py b/my/emfit/__init__.py index acf302c..3ad2b15 100755 --- a/my/emfit/__init__.py +++ b/my/emfit/__init__.py @@ -4,7 +4,6 @@ Consumes data exported by https://github.com/karlicoss/emfitexport """ -from datetime import date from pathlib import Path from typing import Dict, List, Iterable, Any, Optional diff --git a/my/foursquare.py b/my/foursquare.py index a2f9878..7325f3c 100755 --- a/my/foursquare.py +++ b/my/foursquare.py @@ -5,9 +5,7 @@ Foursquare/Swarm checkins from datetime import datetime, timezone, timedelta from itertools import chain from pathlib import Path -from typing import List, Dict, NamedTuple, Union, Any, Tuple, Set import json -from pathlib import Path # TODO pytz for timezone??? diff --git a/my/github/gdpr.py b/my/github/gdpr.py index a4d352b..8d4fbf8 100644 --- a/my/github/gdpr.py +++ b/my/github/gdpr.py @@ -2,7 +2,6 @@ Github data (uses [[https://github.com/settings/admin][official GDPR export]]) """ -from datetime import datetime import json from typing import Iterable, Dict, Any diff --git a/my/github/ghexport.py b/my/github/ghexport.py index c88a6e0..faf4de4 100644 --- a/my/github/ghexport.py +++ b/my/github/ghexport.py @@ -7,7 +7,7 @@ REQUIRES = [ from dataclasses import dataclass from typing import Optional -from ..core import Paths, PathIsh +from ..core import Paths from my.config import github as user_config @@ -42,7 +42,7 @@ except ModuleNotFoundError as e: ############################ -from typing import Tuple, Iterable, Dict, Sequence +from typing import Tuple, Dict, Sequence from ..core import get_files, Path from ..core.common import mcachew @@ -127,7 +127,7 @@ def _get_summary(e) -> Tuple[str, Optional[str], Optional[str]]: link = com['html_url'] iss = pl['issue'] title = iss['title'] - return f"{rname}: commented on issue {title}", link, f'issue_comment_' + link + return f"{rname}: commented on issue {title}", link, 'issue_comment_' + link elif tp == "ReleaseEvent": action = pl['action'] rel = pl['release'] diff --git a/my/google/takeout/html.py b/my/google/takeout/html.py index 9aa741c..d4d6830 100644 --- a/my/google/takeout/html.py +++ b/my/google/takeout/html.py @@ -7,7 +7,7 @@ import re from pathlib import Path from datetime import datetime from html.parser import HTMLParser -from typing import List, Dict, Optional, Any, Callable, Iterable, Tuple +from typing import List, Optional, Any, Callable, Iterable, Tuple from collections import OrderedDict from urllib.parse import unquote import pytz diff --git a/my/google/takeout/paths.py b/my/google/takeout/paths.py index 6c42635..ee3e1e7 100644 --- a/my/google/takeout/paths.py +++ b/my/google/takeout/paths.py @@ -23,7 +23,7 @@ config = make_config(google) from pathlib import Path from typing import Optional, Iterable -from ...core.kompress import kopen, kexists +from ...core.kompress import kexists def get_takeouts(*, path: Optional[str]=None) -> Iterable[Path]: diff --git a/my/hypothesis.py b/my/hypothesis.py index bd0aedc..1241534 100644 --- a/my/hypothesis.py +++ b/my/hypothesis.py @@ -6,7 +6,7 @@ REQUIRES = [ ] from dataclasses import dataclass from datetime import datetime -from typing import Optional, Callable +from typing import Callable from .core import Paths diff --git a/my/jawbone/__init__.py b/my/jawbone/__init__.py index c21d455..06cb262 100755 --- a/my/jawbone/__init__.py +++ b/my/jawbone/__init__.py @@ -155,7 +155,6 @@ def stats(): #### NOTE: most of the stuff below is deprecated and remnants of my old code! #### sorry for it, feel free to remove if you don't need it -import numpy as np # type: ignore import matplotlib.pyplot as plt # type: ignore from matplotlib.figure import Figure # type: ignore from matplotlib.axes import Axes # type: ignore @@ -170,7 +169,6 @@ def hhmm(time: datetime): # return fromstart / tick import matplotlib.dates as mdates # type: ignore -from matplotlib.ticker import MultipleLocator, FixedLocator # type: ignore def plot_one(sleep: SleepEntry, fig: Figure, axes: Axes, xlims=None, showtext=True): span = sleep.completed - sleep.created diff --git a/my/jawbone/plots.py b/my/jawbone/plots.py index eb04200..195ddb5 100755 --- a/my/jawbone/plots.py +++ b/my/jawbone/plots.py @@ -5,7 +5,7 @@ from pathlib import Path from csv import DictReader from itertools import islice -from typing import Dict, Any, NamedTuple, Dict +from typing import Dict, Any, NamedTuple # sleep = [] # with open('2017.csv', 'r') as fo: @@ -14,7 +14,6 @@ from typing import Dict, Any, NamedTuple, Dict # sleep # print(line) -import numpy as np # type: ignore import matplotlib.pyplot as plt # type: ignore from numpy import genfromtxt # type: ignore import matplotlib.pylab as pylab # type: ignore @@ -77,7 +76,6 @@ class SleepData(NamedTuple): def iter_useful(data_file: str): - from csv import DictReader with open(data_file) as fo: reader = DictReader(fo) for d in reader: diff --git a/my/lastfm.py b/my/lastfm.py index 51ccb7e..ffec05c 100755 --- a/my/lastfm.py +++ b/my/lastfm.py @@ -20,7 +20,7 @@ config = make_config(lastfm) from datetime import datetime import json from pathlib import Path -from typing import NamedTuple, Any, Sequence, Iterable +from typing import NamedTuple, Sequence, Iterable import pytz diff --git a/my/location/google.py b/my/location/google.py index 721d1f3..f196301 100644 --- a/my/location/google.py +++ b/my/location/google.py @@ -6,12 +6,11 @@ REQUIRES = [ 'ijson', ] -import json from datetime import datetime, timezone from itertools import islice from pathlib import Path from subprocess import Popen, PIPE -from typing import Any, Collection, Iterable, NamedTuple, Optional, Sequence, IO, Tuple +from typing import Iterable, NamedTuple, Optional, Sequence, IO, Tuple import re # pip3 install geopy diff --git a/my/location/home.py b/my/location/home.py index dc17d12..60b31c5 100644 --- a/my/location/home.py +++ b/my/location/home.py @@ -4,7 +4,7 @@ Simple location provider, serving as a fallback when more detailed data isn't av from dataclasses import dataclass from datetime import datetime, date, time, timezone from functools import lru_cache -from typing import Optional, Sequence, Tuple, Union, cast +from typing import Sequence, Tuple, Union, cast from ..core.common import fromisoformat diff --git a/my/media/imdb.py b/my/media/imdb.py index 23bccd7..c7d5299 100644 --- a/my/media/imdb.py +++ b/my/media/imdb.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 import csv -import json from datetime import datetime from typing import Iterator, List, NamedTuple diff --git a/my/orgmode.py b/my/orgmode.py index 0643653..30ca9d0 100644 --- a/my/orgmode.py +++ b/my/orgmode.py @@ -6,11 +6,11 @@ REQUIRES = [ 'orgparse', ] -from datetime import datetime, date +from datetime import datetime from pathlib import Path from typing import List, Sequence, Iterable, NamedTuple, Optional -from .core import PathIsh, get_files +from .core import get_files from .core.common import mcachew from .core.cachew import cache_dir from .core.orgmode import collect diff --git a/my/pdfs.py b/my/pdfs.py index c537a94..9459a75 100755 --- a/my/pdfs.py +++ b/my/pdfs.py @@ -10,8 +10,6 @@ from datetime import datetime from dataclasses import dataclass import io from pathlib import Path -import re -import sys import time from typing import NamedTuple, List, Optional, Iterator, Sequence diff --git a/my/photos/main.py b/my/photos/main.py index c2ea37e..6be3163 100644 --- a/my/photos/main.py +++ b/my/photos/main.py @@ -11,7 +11,7 @@ from concurrent.futures import ProcessPoolExecutor as Pool from datetime import datetime import json from pathlib import Path -from typing import Tuple, Dict, Optional, NamedTuple, Iterator, Iterable, List +from typing import Optional, NamedTuple, Iterator, Iterable, List from geopy.geocoders import Nominatim # type: ignore diff --git a/my/pocket.py b/my/pocket.py index ff80967..912806d 100644 --- a/my/pocket.py +++ b/my/pocket.py @@ -5,7 +5,6 @@ REQUIRES = [ 'git+https://github.com/karlicoss/pockexport', ] from dataclasses import dataclass -from typing import Optional from .core import Paths @@ -36,7 +35,6 @@ except ModuleNotFoundError as e: Article = dal.Article -from pathlib import Path from typing import Sequence, Iterable diff --git a/my/reading/polar.py b/my/reading/polar.py index 8547bee..f57a18d 100755 --- a/my/reading/polar.py +++ b/my/reading/polar.py @@ -2,7 +2,7 @@ [[https://github.com/burtonator/polar-bookshelf][Polar]] articles and highlights """ from pathlib import Path -from typing import Type, Any, cast, TYPE_CHECKING +from typing import cast, TYPE_CHECKING import my.config @@ -40,12 +40,10 @@ from datetime import datetime from typing import List, Dict, Iterable, NamedTuple, Sequence, Optional import json -import pytz - from ..core import LazyLogger, Json from ..core.common import isoparse from ..error import Res, echain, sort_res_by -from ..core.konsume import wrap, zoom, ignore, Zoomable, Wdict +from ..core.konsume import wrap, Zoomable, Wdict logger = LazyLogger(__name__) diff --git a/my/reddit.py b/my/reddit.py index fd882ac..bbafe92 100755 --- a/my/reddit.py +++ b/my/reddit.py @@ -5,7 +5,6 @@ REQUIRES = [ 'git+https://github.com/karlicoss/rexport', ] -from typing import Optional from .core.common import Paths from my.config import reddit as uconfig @@ -95,7 +94,7 @@ def upvoted() -> Iterator[Upvote]: ### the rest of the file is some elaborate attempt of restoring favorite/unfavorite times -from typing import Dict, Union, Iterable, Iterator, NamedTuple, Any +from typing import Dict, Iterable, Iterator, NamedTuple from functools import lru_cache import pytz import re @@ -183,7 +182,7 @@ def _get_events(backups: Sequence[Path], parallel: bool=True) -> Iterator[Event] assert not first yield Event( dt=bdt, # TODO average wit ps.save_dt? - text=f"unfavorited", + text="unfavorited", kind=ps, eid=f'unf-{ps.sid}', url=ps.url, diff --git a/my/rescuetime.py b/my/rescuetime.py index 03547d9..5d64375 100644 --- a/my/rescuetime.py +++ b/my/rescuetime.py @@ -6,7 +6,7 @@ REQUIRES = [ ] from pathlib import Path -from datetime import datetime, timedelta +from datetime import timedelta from typing import Sequence, Iterable from .core import get_files, LazyLogger @@ -38,7 +38,6 @@ def entries() -> Iterable[Res[Entry]]: def groups(gap: timedelta=timedelta(hours=3)) -> Iterable[Res[Sequence[Entry]]]: vit, eit = split_errors(entries(), ET=Exception) yield from eit - import more_itertools from more_itertools import split_when yield from split_when(vit, lambda a, b: (b.dt - a.dt) > gap) diff --git a/my/rss/feedly.py b/my/rss/feedly.py index cc9331f..df38435 100644 --- a/my/rss/feedly.py +++ b/my/rss/feedly.py @@ -7,7 +7,7 @@ from my.config import feedly as config from pathlib import Path from typing import Sequence -from ..core.common import listify, get_files, isoparse +from ..core.common import listify, get_files from .common import Subscription diff --git a/my/rtm.py b/my/rtm.py index 4dbe3d0..2fc783f 100755 --- a/my/rtm.py +++ b/my/rtm.py @@ -7,8 +7,7 @@ REQUIRES = [ ] import re -from pathlib import Path -from typing import Dict, List, Optional, Iterator +from typing import Dict, List, Iterator from datetime import datetime from .common import LazyLogger, get_files, group_by_key, cproperty, make_dict diff --git a/my/runnerup.py b/my/runnerup.py index f0fd63d..8e31770 100644 --- a/my/runnerup.py +++ b/my/runnerup.py @@ -6,9 +6,9 @@ REQUIRES = [ 'python-tcxparser', ] -from datetime import datetime, timedelta +from datetime import timedelta from pathlib import Path -from typing import NamedTuple, Iterable +from typing import Iterable from .core import Res, get_files from .core.common import isoparse, Json diff --git a/my/time/tz/via_location.py b/my/time/tz/via_location.py index ae4f4eb..ca0f628 100644 --- a/my/time/tz/via_location.py +++ b/my/time/tz/via_location.py @@ -10,9 +10,8 @@ REQUIRES = [ from collections import Counter from datetime import date, datetime from functools import lru_cache -from itertools import groupby, islice -from pathlib import Path -from typing import Dict, Iterator, List, NamedTuple, Optional, Tuple +from itertools import groupby +from typing import Iterator, NamedTuple, Optional from more_itertools import seekable import pytz diff --git a/my/twitter/archive.py b/my/twitter/archive.py index edd26d2..0bb3151 100755 --- a/my/twitter/archive.py +++ b/my/twitter/archive.py @@ -32,14 +32,11 @@ config = make_config(twitter_archive) from datetime import datetime -from typing import Union, List, Dict, Set, Optional, Iterable, Any, NamedTuple, Sequence +from typing import List, Optional, Iterable, NamedTuple, Sequence from pathlib import Path import json -import zipfile -import pytz - -from ..common import PathIsh, get_files, LazyLogger, Json +from ..common import get_files, LazyLogger, Json from ..core import kompress diff --git a/my/vk/vk_messages_backup.py b/my/vk/vk_messages_backup.py index b933757..0e8dc45 100644 --- a/my/vk/vk_messages_backup.py +++ b/my/vk/vk_messages_backup.py @@ -6,7 +6,6 @@ VK data (exported by [[https://github.com/Totktonada/vk_messages_backup][Totkton from datetime import datetime import json -from pathlib import Path from typing import Dict, Iterable, NamedTuple import pytz