Skip to content

PEP 843: Export Statement for DRY Re-exports - #5078

Open
NeilGirdhar wants to merge 1 commit into
python:mainfrom
NeilGirdhar:main
Open

PEP 843: Export Statement for DRY Re-exports#5078
NeilGirdhar wants to merge 1 commit into
python:mainfrom
NeilGirdhar:main

Conversation

@NeilGirdhar

@NeilGirdhar NeilGirdhar commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Basic requirements (all PEP Types)

  • Read and followed PEP 1 & PEP 12
  • File created from the latest PEP template
  • PEP has next available number, & set in filename (pep-NNNN.rst), PR title (PEP 123: <Title of PEP>) and PEP header
    • Tip: find the next available number with pepotron — run uvx pepotron next (or pipx install pepotron then pep next)
  • Title clearly, accurately and concisely describes the content in 79 characters or less
  • Core dev/PEP editor listed as Author or Sponsor, and formally confirmed their approval
  • Author, Status (Draft), Type and Created headers filled out correctly
  • PEP-Delegate, Topic, Requires and Replaces headers completed if appropriate
  • Required sections included
    • Abstract (first section)
    • Copyright (last section; exact wording from template required)
  • Code is well-formatted (PEP 7/PEP 8) and is in code blocks, with the right lexer names if non-Python
  • PEP builds with no warnings, pre-commit checks pass and content displays as intended in the rendered HTML
  • Authors/sponsor added to .github/CODEOWNERS for the PEP

Standards Track requirements

  • PEP topic discussed in a suitable venue with general agreement that a PEP is appropriate
  • Suggested sections included (unless not applicable)
    • Motivation
    • Specification
    • Rationale
    • Backwards Compatibility
    • Security Implications
    • How to Teach This
    • Reference Implementation
    • Rejected Ideas
    • Open Issues
    • Acknowledgements
    • Footnotes
    • Change History
  • Python-Version set to valid (pre-beta) future Python version, if relevant
  • Any project stated in the PEP as supporting/endorsing/benefiting from the PEP formally confirmed such
  • Right before or after initial merging, PEP discussion thread created and linked to in Discussions-To and Post-History

@read-the-docs-community

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

Copy link
Copy Markdown

Documentation build overview

📚 pep-previews | 🛠️ Build #33936046 | 📁 Comparing 14dda0d against latest (0475dc3)

  🔍 Preview build  

4 files changed
+ pep-0843/index.html
± index.html
± numerical/index.html
± pep-0000/index.html

Comment thread peps/pep-0843.rst Outdated
* Restrict runtime attribute access to non-exported names, or change
``__getattr__`` semantics. See `Why no runtime enforcement`_.
* Mark a freshly written ``def``, ``class``, or assignment as exported at
its definition site, the way :pep:`829`'s ``atpublic`` package does with

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.

PEP 829 and atpublic are really orthogonal. The latter is a package that has decades long use in the real world. The connection is that with the next version (likely atpublic 8.0.0 with an alpha already released), you'll be able to pip install atpublic[install] to get the public() and private() decorators automatically installed into builtins at interpreter startup time.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the correction, I'll remove mention of PEP 829!

Comment thread peps/pep-0843.rst
Comment thread peps/pep-0843.rst Outdated
PEP: 843
Title: Export Statement for DRY Re-exports
Author: Neil Girdhar <mistersheik@gmail.com>
Discussions-To: https://discuss.python.org/t/108353

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.

Using the 842 thread is fine for the post-history, but you're going to want your own thread for this PEP. Mark this as "Pending" for now; you'll create the thread after merging.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That makes perfect sense, thank you!

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.

Yes, discussion should be in another topic than 842, as that one is long enough already!

As there's no sponsor for this one yet, it should be in the Ideas category.

@ZeroIntensity Relatedly, as you're working on a new revision, you may want to lock the old thread (by flagging and asking mods) until you post the new topic. This is something Brett has done to manage his long PEP discussions.

Comment thread peps/pep-0843.rst Outdated
Comment on lines +52 to +53
``__all__`` and triggers an ``ExportWarning`` on access to anything left
out.

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.

You should probably clarify that ExportWarning is specific to 842.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree: the paragraph structure was confusing. I completely separated the commonalities from the PEP 842-specific points for clarity.

Comment thread peps/pep-0843.rst Outdated
Comment on lines +58 to +59
wildcard equivalent to `Wildcard form`_ and no lazy equivalent to `Lazy
exports`_. This PEP takes only that one slice, deliberately leaving out

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.

PEP 842 allows lazy imports, as it is in the grammar (though I haven't tested the implementation for it). I clarified that in my draft.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for clarifying; I've corrected my exposition.

Comment thread .github/CODEOWNERS Outdated
peps/pep-0838.rst @AlexWaygood
peps/pep-0840.rst @jeremyhylton @gvanrossum
peps/pep-0842.rst @ZeroIntensity
peps/pep-0843.rst @NeilGirdhar

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.

Our (GitHub's?) rule is that you need to be a member of the python organization on GitHub to be listed as a code owner. The core dev sponsor is listed here instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, of course! Removed, thanks!

Comment thread peps/pep-0843.rst
@@ -0,0 +1,623 @@
PEP: 843

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.

For the record, you typically need a core dev sponsor before assigning a number. I'm open to sponsoring, but I want to see what happens with the new 842 revision first.

@NeilGirdhar NeilGirdhar Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Awesome!! No rush on my end. Happy to wait and see how the new PEP 842 revision goes before asking anyone to commit. Thanks for taking the time to look over my PEP so carefully.

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.

Yes, we can keep this open as a courtesy for a bit, but PEPs from non-core devs do need a sponsor.

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.

We normally only assign numbers when there's a sponsor. There's quite a bit of uncertainty whether this will get one, and some time until we'll know the answer.

Do we want to assign 843 already to this? Or use the usual 9999 placeholder for now?

Comment thread peps/pep-0843.rst
@@ -0,0 +1,623 @@
PEP: 843

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.

Yes, we can keep this open as a courtesy for a bit, but PEPs from non-core devs do need a sponsor.

Comment thread peps/pep-0843.rst Outdated
in sync by hand every time the public layout changes.

The second is the reflexive-alias idiom, ``from x import y as y``. Type
checkers (like mypy even in strict mode) treat it as a signal that the

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.

Why "even"? It's a documented part of the type system.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was trying to emphasize the universality of the rule, but it didn't come across.

Comment thread peps/pep-0843.rst Outdated
==========

This section is grounded in existing, widely-used libraries rather than
a hypothetical ``spam`` module.

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.

Strange wording

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this was a weak start. Grounded in affirmative statements instead.

Comment thread peps/pep-0843.rst Outdated
file: the list of imports (an implementation detail of how the
flattening is wired up) and the declaration of the public API (a promise
to users). The two live in separate statements at different places in
the file, and a reviewer must check them against each other by eye.

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.

Or rely on a linter that warns when they're out of sync.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. I softened the wording. But often linters do the wrong thing and wipe out the import rather than adding to __all__, so linters aren't a perfect fix.

Comment thread peps/pep-0843.rst Outdated
``atpublic`` works around this with a function-call form,
``public(some_imported_name)``, but that reintroduces the double-write
this PEP removes: the name is written once in the import and again as an
argument to ``public()``. A statement-level ``export`` keyword avoids

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.

It also doesn't work well with aliases

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you!!

@hugovk hugovk changed the title Add PEP 843: Export Statement for DRY Re-exports PEP 843: Export Statement for DRY Re-exports Aug 6, 2026
@hugovk

hugovk commented Aug 6, 2026

Copy link
Copy Markdown
Member

Please add anthe new PEP checklist to the top post, and start checking things off:

https://github.com/python/peps/blob/main/.github/PULL_REQUEST_TEMPLATE/Add%20a%20new%20PEP.md

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants