diff --git a/my/core/source.py b/my/core/source.py index 753c5aa..6f62754 100644 --- a/my/core/source.py +++ b/my/core/source.py @@ -8,8 +8,8 @@ def import_source(factory: Callable[[], Any], default: Any) -> Any: try: res = factory() return res - except ImportError: # presumable means the user hasn't installed the module - warn(f"Module {factory.__name__} could not be imported, or isn't configured propertly") + except ModuleNotFoundError: # presumable means the user hasn't installed the module + warn(f"Module {factory.__qualname__} could not be imported, or isn't configured propertly") return default @@ -20,7 +20,7 @@ def import_source_iter(factory: Callable[[], Iterator[T]], default: Optional[Ite try: res = factory() yield from res - except ImportError: # presumable means the user hasn't installed the module - warn(f"Module {factory.__name__} could not be imported, or isn't configured propertly") + except ModuleNotFoundError: # presumable means the user hasn't installed the module + warn(f"Module {factory.__qualname__} could not be imported, or isn't configured propertly") yield from default diff --git a/my/reddit/__init__.py b/my/reddit/__init__.py index 7b05d51..5a16577 100644 --- a/my/reddit/__init__.py +++ b/my/reddit/__init__.py @@ -9,6 +9,13 @@ since that allows for easier overriding using namespace packages https://github.com/karlicoss/HPI/issues/102 """ +# For now, including this here, since importing the module +# causes .rexport to be imported, which requires rexport +REQUIRES = [ + 'git+https://github.com/karlicoss/rexport', +] + + # TODO: add warning here from .rexport import * diff --git a/my/reddit/all.py b/my/reddit/all.py index 4f7b4e4..d4cf137 100644 --- a/my/reddit/all.py +++ b/my/reddit/all.py @@ -16,14 +16,14 @@ def _rexport_import() -> Any: return source def _rexport_comments() -> Iterator[Comment]: - yield from imp(_rexport_import().comments) + yield from imp(lambda: _rexport_import().comments()) def _pushshift_import() -> Any: from . import pushshift as source return source def _pushshift_comments() -> Iterator[Comment]: - yield from imp(_pushshift_import().comments) + yield from imp(lambda: _pushshift_import().comments()) # Merged functions