Skip to content

Can this be used to just check for compatibility breaks with the __init__.py's __all__ exports? #230

Closed Answered by pawamoy
matthewdeanmartin asked this question in Q&A
Discussion options

You must be logged in to vote

In Python, the convention is that any object that does not start with an underscore _ is considered public. That comprises modules, functions, classes, methods and any attributes. If you want to mark an object as "private" (or "protected", I never remember which one uses name mangling with two leading underscores __), you must prefix it with _.

Griffe also actually supports __all__ attributes. If you define one in a module (any module, not just __init__.py), then Griffe knows that only the names within __all__ are to be considered public, even if other objects not in __all__ do not start with _. If you don't define __all__, then Griffe falls back on whether objects in the module start with _

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@matthewdeanmartin
Comment options

@matthewdeanmartin
Comment options

@pawamoy
Comment options

Answer selected by matthewdeanmartin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants