diff --git a/my/config.py b/my/config.py index 0b30d9a..b6f91e6 100644 --- a/my/config.py +++ b/my/config.py @@ -45,6 +45,9 @@ class bluemaestro: class stackexchange: export_path: Paths = '' +class pinboard: + export_dir: Paths = '' + class google: takeout_path: Paths = '' diff --git a/my/kobo.py b/my/kobo.py index 51a86f1..337d9c7 100644 --- a/my/kobo.py +++ b/my/kobo.py @@ -2,9 +2,12 @@ [[https://uk.kobobooks.com/products/kobo-aura-one][Kobo]] e-ink reader: annotations and reading stats """ -# TODO require installing kobuddy, need to upload to pypi as well? -from dataclasses import dataclass -from .core import Paths +REQUIRES = [ + 'kobuddy', +] + + +from .core import Paths, dataclass from my.config import kobo as user_config @dataclass class kobo(user_config): @@ -31,11 +34,9 @@ from kobuddy import * -def stats(): - from .core import stat - return { - **stat(get_highlights), - } +from .core import stat, Stats +def stats() -> Stats: + return stat(get_highlights) ## TODO hmm. not sure if all this really belongs here?... perhaps orger? @@ -63,7 +64,7 @@ def by_annotation(predicatish: Predicatish, **kwargs) -> List[Highlight]: return res -def get_todos(): +def get_todos() -> List[Highlight]: def with_todo(ann): if ann is None: ann = '' @@ -71,6 +72,6 @@ def get_todos(): return by_annotation(with_todo) -def test_todos(): +def test_todos() -> None: todos = get_todos() assert len(todos) > 3 diff --git a/my/pinboard.py b/my/pinboard.py index d37ba07..354f15c 100644 --- a/my/pinboard.py +++ b/my/pinboard.py @@ -1,21 +1,26 @@ """ [[https://pinboard.in][Pinboard]] bookmarks """ -from .common import get_files +REQUIRES = [ + 'git+https://github.com/karlicoss/pinbexport', +] -from my.config.repos.pinbexport import dal as pinbexport from my.config import pinboard as config -# TODO would be nice to make interfaces available for mypy... + +import pinbexport.dal as pinbexport + Bookmark = pinbexport.Bookmark # yep; clearly looks that the purpose of my. package is to wire files to DAL implicitly; otherwise it's just passtrhough. -def dal(): - sources = get_files(config.export_dir, glob='*.json') - model = pinbexport.DAL(sources) +def dal() -> pinbexport.DAL: + from .core import get_files + inputs = get_files(config.export_dir) # todo rename to export_path + model = pinbexport.DAL(inputs) return model -def bookmarks(): +from typing import Iterable +def bookmarks() -> Iterable[pinbexport.Bookmark]: return dal().bookmarks() diff --git a/tox.ini b/tox.ini index 9dd4e17..eee4796 100644 --- a/tox.ini +++ b/tox.ini @@ -74,6 +74,7 @@ commands = hpi module install my.pocket hpi module install my.reddit hpi module install my.stackexchange.stexport + hpi module install my.pinboard # TODO fuck. -p my.github isn't checking the subpackages?? wtf... python3 -m mypy \ @@ -84,6 +85,7 @@ commands = -p my.pocket \ -p my.reddit \ -p my.stackexchange.stexport \ + -p my.pinboard \ -p my.body.exercise.cardio \ -p my.body.exercise.cross_trainer \ -p my.bluemaestro \