You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modules and variables imported into the stub are not considered exported from the stub unless the import uses the import ... as ... form or the equivalent from ... import ... as ... form. (UPDATE: To clarify, the intention here is that only names imported using the form X as X will be exported, i.e. the name before and after as must be the same.)
however pdoc does not recognize this and does not include the name in the docs, when it is intended to be public.
Steps to reproduce the behavior:
create a private and public module with the code above
This feels more like a hack than anything else, but given that it's in PEP 484 I'd be happy to merge a PR that adds support for it. Fwiw, a strict reading of the spec seems to imply this only applies to stub files of I'm not mistaken...
As a workaround, I'd recommend to just declare __all__.
tell me about it, that's python typing for you lol
a strict reading of the spec seems to imply this only applies to stub files of I'm not mistaken...
yeah i don't know why but for some reason most of the documentation and discussions around python typing seems to imply that you'd only ever use types in stubs and not actual source code. but the two main type checkers support this explicit re-export "syntax" outside of stubs (mypy and pyright) so i think it's safe to assume this behavior is intended to work in regular source code too
As a workaround, I'd recommend to just declare __all__.
thanks. though i'm not really a fan of __all__ since it would mean i have to add everything else in my module to it, and i prefer declaring whether something is public/private on its definition rather than in a separate section of the module. so the workaround i went with was to just import it and assign it to another variable:
# foo/public_module.pyfrom_private_moduleimportfooas_foofoo=_foo"""the downside is that i have to move the docstring here tho"""
Problem Description
in python typing, an import alias with the same name is considered an explicit re-export:
see https://peps.python.org/pep-0484/#stub-files:
however pdoc does not recognize this and does not include the name in the docs, when it is intended to be public.
Steps to reproduce the behavior:
pdoc foo
System Information
The text was updated successfully, but these errors were encountered: