Skip to content

PEP 844: public and private builtins - #5079

Open
warsaw wants to merge 15 commits into
python:mainfrom
warsaw:pep844
Open

PEP 844: public and private builtins#5079
warsaw wants to merge 15 commits into
python:mainfrom
warsaw:pep844

Conversation

@warsaw

@warsaw warsaw commented Aug 6, 2026

Copy link
Copy Markdown
Member

Initial draft of a PEP to go along side 842 and 843 (hence the claim on 844)

@warsaw warsaw self-assigned this Aug 6, 2026
@warsaw
warsaw requested a review from a team as a code owner August 6, 2026 03:43
@read-the-docs-community

read-the-docs-community Bot commented Aug 6, 2026

Copy link
Copy Markdown

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was quick 😅

Comment thread peps/pep-0844.rst Outdated
Comment thread peps/pep-0844.rst
Comment thread peps/pep-0844.rst Outdated
Comment thread peps/pep-0844.rst Outdated
Comment thread peps/pep-0844.rst Outdated
Comment thread peps/pep-0844.rst Outdated
Comment thread peps/pep-0844.rst Outdated
Comment thread peps/pep-0844.rst Outdated
Comment thread peps/pep-0844.rst Outdated
Comment thread peps/pep-0844.rst
Acknowledgements
================

Thanks to Peter Bierma and Neil Girdhar, whose :pep:`842` and PEP 843 prompted this proposal, and to

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if PEP 843 PR is not merged yet, it would be better to use a link:

Suggested change
Thanks to Peter Bierma and Neil Girdhar, whose :pep:`842` and PEP 843 prompted this proposal, and to
Thanks to Peter Bierma and Neil Girdhar, whose :pep:`842` and :pep:`843` prompted this proposal, and to

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't apply this one until 843 is actually published, otherwise the build fails. I have a TODO to clean these up.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't know that it emits an error. So it makes sense to not add a link yet!

@brianschubert brianschubert added the new-pep A new draft PEP submitted for initial review label Aug 6, 2026
warsaw and others added 13 commits August 6, 2026 11:40
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I caught a few grammatical issues, but otherwise this looks good. It'd be good to get this up soon so people can share thoughts on it in contrast to the new 842 revision.

Comment thread peps/pep-0844.rst
Motivation
==========

The :attr:`module global variable <module.__all__>` ``__all__`` is the mechanism Python currently

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks weird in the output because "module global variable" is rendered as code. I suggest doing this:

Suggested change
The :attr:`module global variable <module.__all__>` ``__all__`` is the mechanism Python currently
The module global variable :attr:`~module.__all__` is the mechanism Python currently

Comment thread peps/pep-0844.rst

:pep:`842` gives two reasons why ``__all__`` is inadequate. The first is that ``__all__`` drifts
out of sync with the module. That is true, and it is precisely the problem ``atpublic`` and this
PEP solves. However a *new list of string literals in the same distant part of the file* does not

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The subject here is plural, so it should be "solve" instead of "solves".
  2. "However" needs a trailing comma.
Suggested change
PEP solves. However a *new list of string literals in the same distant part of the file* does not
PEP solve. However, a *new list of string literals in the same distant part of the file* does not

Comment thread peps/pep-0844.rst

``Widget`` is named once to import it, and twice more to export it. That's a big violation of DRY!
Hand-maintaining ``__all__`` would name it only twice, so for re-exports specifically, ``public()``
is not merely unhelpful, it is a step backwards.

@ZeroIntensity ZeroIntensity Aug 7, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comma splice:

Suggested change
is not merely unhelpful, it is a step backwards.
is not merely unhelpful; it is a step backwards.

or:

Suggested change
is not merely unhelpful, it is a step backwards.
is not merely unhelpful, but rather it is a step backwards.

Comment thread peps/pep-0844.rst

The conclusion is that the data and type alias use cases, which are the places a decorator
genuinely cannot be utilized, do not require new syntax at all. They require a function call that
tools can learn to read, alleviating the need for a dedicated, new ``export`` keyword.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Alleviating" feels awkward here; you alleviate a problem, not a solution. Maybe "removing" instead?

Suggested change
tools can learn to read, alleviating the need for a dedicated, new ``export`` keyword.
tools can learn to read, removing the need for a dedicated, new ``export`` keyword.

Comment thread peps/pep-0844.rst
gained over the decade of ``atpublic``'s existence that requiring a third-party dependency (or an
import at the top of every module) to spell something this fundamental is friction that discourages
its use. It is also awkward in exactly the places where it matters most: the standard library
itself, and small single file modules.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a hyphen:

Suggested change
itself, and small single file modules.
itself, and small single-file modules.

Comment thread peps/pep-0844.rst
tools can learn to read, alleviating the need for a dedicated, new ``export`` keyword.


.. _pep-844-urgency:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This label is unused.

Comment thread peps/pep-0844.rst
Comment on lines +228 to +229
module-level objects may be decorated. Decorating a method inside a class body is not supported,
since ``__all__`` documents module contents, not class contents.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very nitpicky, but what happens if you decorate a method? Is it an error, or does it append the name to __all__?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-pep A new draft PEP submitted for initial review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants