use lambdas so imports dont run, use __qualname__
This commit is contained in:
parent
48865039bf
commit
e79f51c25d
3 changed files with 13 additions and 6 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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 *
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue