Downloader.__init__ in papis_scihub/plugin.py calls self.logger.warning(...) before the parent papis.downloaders.Downloader.__init__. since self.logger and self.session are both set up by the parent's __init__, this crashes with an AttributeError.
Reproduce
papis add --from scihub https://doi.org/10.1080/17499518.2025.2581567
Traceback
Traceback (most recent call last):
File ".../papis/importer/__init__.py", line 216, in match
importer = cls.match(uri)
File ".../papis_scihub/plugin.py", line 54, in match
return Downloader(url)
File ".../papis_scihub/plugin.py", line 37, in __init__
self.logger.warning(WARNING_NOTICE)
^^^^^^^^^^^
AttributeError: 'Downloader' object has no attribute 'logger'
Cause
in plugin.py, the parent __init__ is called after self.logger is used:
class Downloader(papis.downloaders.Downloader):
def __init__(self, uri: str) -> None:
self.logger.warning(WARNING_NOTICE)
papis.downloaders.Downloader.__init__(self, uri=uri, name="sci-hub")
self.logger and self.session are both initialised inside papis.downloaders.Downloader.__init__, so they don't exist when line 37 runs.
Suggested fix
class Downloader(papis.downloaders.Downloader):
def __init__(self, uri: str) -> None:
- self.logger.warning(WARNING_NOTICE)
papis.downloaders.Downloader.__init__(self, uri=uri, name="sci-hub")
+ self.logger.warning(WARNING_NOTICE)
My Env
- papis: 0.15.0
- papis-scihub: 0.1.3 (commit
4a7b88b)
- Python: 3.13
Downloader.__init__inpapis_scihub/plugin.pycallsself.logger.warning(...)before the parentpapis.downloaders.Downloader.__init__. sinceself.loggerandself.sessionare both set up by the parent's__init__, this crashes with anAttributeError.Reproduce
Traceback
Cause
in
plugin.py, the parent__init__is called afterself.loggeris used:self.loggerandself.sessionare both initialised insidepapis.downloaders.Downloader.__init__, so they don't exist when line 37 runs.Suggested fix
class Downloader(papis.downloaders.Downloader): def __init__(self, uri: str) -> None: - self.logger.warning(WARNING_NOTICE) papis.downloaders.Downloader.__init__(self, uri=uri, name="sci-hub") + self.logger.warning(WARNING_NOTICE)My Env
4a7b88b)