fix mypy, use more links to models
This commit is contained in:
parent
af810eb325
commit
a4e1deb458
4 changed files with 12 additions and 26 deletions
|
@ -43,7 +43,7 @@ Also read/run [demo.py](demo.py) for a full demonstration of setting up Hypothes
|
||||||
|
|
||||||
```
|
```
|
||||||
# see https://github.com/python/mypy/issues/1645 for --namespace-packages explanation
|
# see https://github.com/python/mypy/issues/1645 for --namespace-packages explanation
|
||||||
with_my --namespace-packages my/hypothesis.py
|
with_my --namespace-packages my
|
||||||
```
|
```
|
||||||
or, set up as `mypy.ini` file:
|
or, set up as `mypy.ini` file:
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,14 +1,5 @@
|
||||||
from functools import lru_cache
|
from my_configuration import paths
|
||||||
|
from my_configuration.repos.kobuddy.src.kobuddy import *
|
||||||
from .. import paths
|
|
||||||
|
|
||||||
@lru_cache()
|
|
||||||
def kobuddy_module():
|
|
||||||
from ..common import import_from
|
|
||||||
return import_from(paths.kobuddy.repo, 'kobuddy')
|
|
||||||
|
|
||||||
kobuddy = kobuddy_module()
|
|
||||||
from kobuddy import *
|
|
||||||
|
|
||||||
set_databases(paths.kobuddy.export_dir)
|
set_databases(paths.kobuddy.export_dir)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
from functools import lru_cache
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from my_configuration import paths
|
from my_configuration import paths
|
||||||
|
|
22
my/reddit.py
22
my/reddit.py
|
@ -1,14 +1,10 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from functools import lru_cache
|
|
||||||
from pathlib import Path, PosixPath
|
from pathlib import Path, PosixPath
|
||||||
from typing import List, Sequence
|
from typing import List, Sequence, Mapping
|
||||||
|
|
||||||
from . import paths
|
from my_configuration import paths
|
||||||
|
import my_configuration.repos.rexport.model as rexport
|
||||||
|
|
||||||
@lru_cache()
|
|
||||||
def rexport():
|
|
||||||
from .common import import_file
|
|
||||||
return import_file(Path(paths.rexport.repo) / 'model.py')
|
|
||||||
|
|
||||||
class CPath(PosixPath):
|
class CPath(PosixPath):
|
||||||
def open(self, *args, **kwargs):
|
def open(self, *args, **kwargs):
|
||||||
|
@ -24,7 +20,7 @@ def get_backup_files() -> Sequence[Path]:
|
||||||
|
|
||||||
|
|
||||||
def get_model():
|
def get_model():
|
||||||
model = rexport().Model(get_backup_files())
|
model = rexport.Model(get_backup_files())
|
||||||
return model
|
return model
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
@ -33,8 +29,8 @@ def get_logger():
|
||||||
return logging.getLogger('my.reddit')
|
return logging.getLogger('my.reddit')
|
||||||
|
|
||||||
|
|
||||||
Save = rexport().Save
|
Save = rexport.Save
|
||||||
Sid = rexport().Sid
|
Sid = rexport.Sid
|
||||||
|
|
||||||
|
|
||||||
def get_saves() -> List[Save]:
|
def get_saves() -> List[Save]:
|
||||||
|
@ -94,7 +90,7 @@ def _get_state(bfile: Path) -> Dict[Sid, SaveWithDt]:
|
||||||
|
|
||||||
bdt = _get_bdate(bfile)
|
bdt = _get_bdate(bfile)
|
||||||
|
|
||||||
saves = [SaveWithDt(save, bdt) for save in rexport().Model([bfile]).saved()]
|
saves = [SaveWithDt(save, bdt) for save in rexport.Model([bfile]).saved()]
|
||||||
from kython import make_dict
|
from kython import make_dict
|
||||||
return make_dict(
|
return make_dict(
|
||||||
sorted(saves, key=lambda p: p.save.created),
|
sorted(saves, key=lambda p: p.save.created),
|
||||||
|
@ -111,11 +107,11 @@ def _get_events(backups: Sequence[Path], parallel: bool) -> List[Event]:
|
||||||
logger = get_logger()
|
logger = get_logger()
|
||||||
|
|
||||||
events: List[Event] = []
|
events: List[Event] = []
|
||||||
prev_saves: Dict[Sid, Save] = {}
|
prev_saves: Mapping[Sid, Save] = {}
|
||||||
# TODO suppress first batch??
|
# TODO suppress first batch??
|
||||||
# TODO for initial batch, treat event time as creation time
|
# TODO for initial batch, treat event time as creation time
|
||||||
|
|
||||||
states: Iterable[Dict[Sid, Save]]
|
states: Iterable[Mapping[Sid, Save]]
|
||||||
if parallel:
|
if parallel:
|
||||||
with Pool() as p:
|
with Pool() as p:
|
||||||
states = p.map(_get_state, backups)
|
states = p.map(_get_state, backups)
|
||||||
|
|
Loading…
Add table
Reference in a new issue