Should __init__.py imports be treated as exports with --no-implicit-reexport behaviour?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
I'm uncertain whether --no-implicit-reexport has a "correct" behaviour when it comes to __init.py__ files.
If I have this __init__.py file:
from .mysub import MyName
My intent is to export MyName from the module. Currently this does not work however, and I need to do either:
from .mysub import MyName as MyName
or
from .mysub import MyName
__all__ = ['MyName']
Both of which are redundant.
I saw this issue on stub-generation that seems to imply that imports in an init (or otherwise unused imports) should be considered exports.
Shouldn't --no-implicit-reexport treat init files as doing exports for the module without the code having to use the redundant ...as... or __all__ form?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no repository files or tests. Start by locating the implementation and tests for --no-implicit-reexport, then review the linked stub-generation issue and the init.py examples; done means establishing and implementing a decided rule for whether such imports are exports without redundant syntax.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100