Missing names in aiogoogle.__all__
Closed this issue · 5 comments
Following imports:
aiogoogle/aiogoogle/__init__.py
Lines 15 to 22 in 4eef158
Is not listed in __all__
aiogoogle/aiogoogle/__init__.py
Line 1 in 4eef158
Shouldn't the Aiogoogle
class be included in the __all__
of client.py not that of __init__.py
. I'm not sure though.
Yeah it would be simple fix but not sure if this is Pycharm reading wrong or not. I see no issue on pylint default config.
For pycharm:
from aiogoogle import Aiogoogle # Aiogoogle is not declared in __all__
assert Aiogoogle
from aiogoogle.client import Aiogoogle # No warning
assert Aiogoogle
First case throw issue because it is imported from __init__.py
so it look __all__
inside it, second case no warning because it's reading from client.py
's __all__
I intentionally created demo code in hope to see it trigger warning on pylint, but sadly it doesn't - I can say pylint don't check it at all, and I can't find any official guideline on where it should read from.
I do see other modules' top-level __init__.py
extending to child libraries' __all__
, which looks promising - but just to make sure I'll ask on StackOverFlow if there's any official reference or guideline about it.
EDIT: While researching to fill up details in SO question, I found that python's official libraries explicitly concatenate all submodule's __all__
to top-level module's __all__
.
"""The asyncio package, tracking PEP 3156."""
# flake8: noqa
import sys
# This relies on each of the submodules having an __all__ variable.
from .base_events import *
from .coroutines import *
from .events import *
from .exceptions import *
from .futures import *
from .locks import *
from .protocols import *
from .runners import *
from .queues import *
from .streams import *
from .subprocess import *
from .tasks import *
from .threads import *
from .transports import *
__all__ = (base_events.__all__ +
coroutines.__all__ +
events.__all__ +
exceptions.__all__ +
futures.__all__ +
locks.__all__ +
protocols.__all__ +
runners.__all__ +
queues.__all__ +
streams.__all__ +
subprocess.__all__ +
tasks.__all__ +
threads.__all__ +
transports.__all__)
...
So we can conclude python's __all__
has to be explicitly add up submodule's __all__
, not implicitly searching it inside the very module(in this case aiogoogle.client.py
) where name is defined.
Ahh, I see. That makes sense. Thanks for doing the research! If you wish to make a PR and follow this pattern, I'll go ahead and merge it.
Thanks a lot for the PR! I just released a new version.