Stubgen generates invalid stubs for code with import chain
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Encountered many issues while trying to make stubs for TensorFlow (lost cause, I guess, but I had to try). One of the issues is reproduced by the following toy example.
m1.py:
x = 123
m2.py:
from m1 import x
__all__ = []
m3.py:
from m2 import x
__all__ = ['x']
Generated stubs:
m1.pyi
x: int
m2.pyi
m3.pyi
from m2 import x as x
Probably the most 'right' thing to do would be to have m3.pyi say:
from m1 import x as x
But this doesn't seem easy with current stubgen architecture.
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
Reproduce the issue with the m1.py, m2.py, and m3.py toy modules, then trace stubgen's handling of imports and all across the chain. Compare the generated m2.pyi and m3.pyi with the expected re-export from m1; done means the generated stubs preserve the valid exported symbol without producing an invalid import.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100