Coder Social home page Coder Social logo

Comments (2)

mhils avatar mhils commented on June 7, 2024 1

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__.

from pdoc.

DetachHead avatar DetachHead commented on June 7, 2024

This feels more like a hack than anything else

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.py
from _private_module import foo as _foo

foo = _foo
"""the downside is that i have to move the docstring here tho"""

from pdoc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.