We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature
(A clear and concise description of your feature proposal.)
Maybe __all__ should be added explicitly in stubgen.
__all__
Pitch
(Please explain why this feature should be implemented and how it would be used. Add examples, if applicable.)
Adding __all__ to type stubs explicitly can avoid some error. For example:
├── test │ └── init.py
__init__.py:
class Test: pass __all__ = []
The type stub file generated by stubgen is __init__.pyi:
class Test: ...
When using from .test import * to import test as a submodule, Test will be imported according to the type stub, while in fact Test should not be used.
from .test import *
Test
A Possible Implement
Replace output(self) in stubgen.py by following implement:
output(self)
def output(self) -> str: """Return the text for the stub.""" imports = '' if self._import_lines: imports += ''.join(self._import_lines) imports += ''.join(self.import_tracker.import_lines()) if imports and self._output: imports += '\n' imports += ''.join(self._output) """export __all__ when it's defined""" if imports and self._all_ != None: imports += '\n' if self._all_ != None: imports += '__all__ = [' for name in self._all_: imports += ''.join(('\"', name, '\", ')) imports += ']' return imports
The text was updated successfully, but these errors were encountered:
stubgen: include __all__ in output
f03f12c
Fixes python#10314
stubgen: include __all__ in output (#16356)
0ff7a29
Fixes #10314
Successfully merging a pull request may close this issue.
Feature
(A clear and concise description of your feature proposal.)
Maybe
__all__
should be added explicitly in stubgen.Pitch
(Please explain why this feature should be implemented and how it would be used. Add examples, if applicable.)
Adding
__all__
to type stubs explicitly can avoid some error. For example:├── test
│ └── init.py
__init__.py:
The type stub file generated by stubgen is
__init__.pyi:
When using
from .test import *
to import test as a submodule,Test
will be imported according to the type stub, while in factTest
should not be used.A Possible Implement
Replace
output(self)
in stubgen.py by following implement:The text was updated successfully, but these errors were encountered: