my.reddit: better handling for legacy reddit config

prior to this change it would error with

    @dataclass
>   class pushshift_config(uconfig.pushshift):
E   AttributeError: type object 'test_config' has no attribute 'pushshift'
This commit is contained in:
Dima Gerasimov 2021-12-23 10:09:18 +00:00 committed by karlicoss
parent 5e9cc2a6a0
commit be21606075
2 changed files with 8 additions and 1 deletions

View file

@ -12,6 +12,9 @@ from my.core.common import Paths, Stats
from dataclasses import dataclass from dataclasses import dataclass
from my.core.cfg import make_config from my.core.cfg import make_config
# note: keeping pushshift import before config import, so it's handled gracefully by import_source
from pushshift_comment_export.dal import read_file, PComment
from my.config import reddit as uconfig from my.config import reddit as uconfig
@dataclass @dataclass
@ -29,7 +32,6 @@ from my.core import get_files
from typing import Sequence, Iterator from typing import Sequence, Iterator
from pathlib import Path from pathlib import Path
from pushshift_comment_export.dal import read_file, PComment
def inputs() -> Sequence[Path]: def inputs() -> Sequence[Path]:

View file

@ -11,6 +11,11 @@ def test_basic() -> None:
assert len(list(saved())) > 0 assert len(list(saved())) > 0
def test_comments() -> None:
from my.reddit.all import comments
assert len(list(comments())) > 0
def test_unfav() -> None: def test_unfav() -> None:
from my.reddit import events, saved from my.reddit import events, saved
ev = events() ev = events()