posit-dev / posit-dev/py-shiny
`generate_imports.py` should automate `__init.py__` generation
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 135
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 21
Description
Currently, scripts/generate_imports.py helps to create explicit import lists to go in the various __init.py__ files, but they still need some manual adjustment after being generated. This process should be more automated. The same should also be used for htmltools.
Some examples of the challenges:
In shiny/reactives/_reactives.py, it has the following:
__all__ = ("Value", "Calc", "Calc_", "CalcAsync_", "Effect", "Effect_")
In shiny/reactives/__init__.py, it imports all of these, but only some of them, ("Value", "Calc", "Effect"), are listed in the __all__ in that file. We should add a way in _reactives.py to indicate which of them should be re-exported in shiny.reactives, and which are simply imported there.
Similarly, at the top level shiny/__init__.py, it imports many objects, but not all of them are explicitly re-exported.
When items are not re-exported, we need to tell flake8 and pyright that it's OK. For example, in shiny/reactive/__init__.py:
from ._reactives import ( # noqa: F401
Value,
Calc,
Calc_, # pyright: ignore[reportUnusedImport]
CalcAsync_, # pyright: ignore[reportUnusedImport]
Effect,
Effect_, # pyright: ignore[reportUnusedImport]
)
Contributor guide
No contributing guide indexed for this repository
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
Start with scripts/generate_imports.py and compare its output with shiny/reactives/_reactives.py, shiny/reactives/init.py, and shiny/init.py. Trace how public and non-public imports are currently distinguished, then inspect how the same generation should apply to htmltools. Done means generated init.py files include the correct all entries and the needed flake8 and pyright annotations without manual adjustment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100