11PEP: 843
22Title: Export Statement for DRY Re-exports
33Author: Neil Girdhar <mistersheik@gmail.com>
4+ Sponsor: Peter Bierma <peter@python.org>
45Discussions-To: Pending
56Status: Draft
67Type: Standards Track
@@ -42,7 +43,7 @@ statement. Nothing is left to sync by hand, and no alias needs decoding.
4243
4344
4445Relationship to PEP 842
45- ========================
46+ =======================
4647
4748Both PEPs start from the same discomfort with ``__all__ ``, and agree on
4849the same core mechanism for re-exports: a statement of the shape ``from
@@ -105,7 +106,7 @@ see a bare ``import x`` as unused and remove it.
105106
106107
107108``__all__ `` conflates two concerns
108- -------------------------------------
109+ ----------------------------------
109110
110111Hand-maintained ``__all__ `` also mixes two distinct concerns in one
111112file: the list of imports (an implementation detail of how the
@@ -119,7 +120,7 @@ autofixers routinely delete it rather than surface the omission.
119120
120121
121122Underscores solve a different problem
122- --------------------------------------
123+ -------------------------------------
123124
124125A natural response is: "just prefix internal names with an underscore."
125126But the privacy this PEP cares about lives at the package level, not the
@@ -205,7 +206,7 @@ export is the use.
205206
206207
207208Wildcard form
208- -----------------
209+ -------------
209210
210211This proposal also includes a wildcard form, ``from <module> export * ``.
211212It binds every name that ``from <module> import * `` would bind, using the
@@ -241,7 +242,7 @@ machinery already computes to execute a wildcard import.
241242
242243
243244Lazy exports
244- -----------------
245+ ------------
245246
246247:pep: `810 ` adds a ``lazy `` soft keyword that defers a ``from ... import ``
247248statement until the imported name is first used: ``lazy from <module>
@@ -341,7 +342,7 @@ exactly the shape a hub module (`How to Teach This`_) already takes.
341342
342343
343344Interaction with ``__all__ ``
344- -----------------------------
345+ ----------------------------
345346
346347A module may freely mix ``from ... export ... `` statements with a
347348manually maintained ``__all__ ``, or with ``__all__ += `` /
@@ -369,7 +370,7 @@ attribute-access hiding is a `non-goal <Non-goals_>`_ of this PEP.
369370
370371
371372Semantic implementation
372- ------------------------
373+ -----------------------
373374
374375Each ``from <module> export <name> as <alias> `` statement is equivalent
375376to:
@@ -402,7 +403,7 @@ Rationale
402403=========
403404
404405Why a keyword and not a decorator
405- -----------------------------------
406+ ---------------------------------
406407
407408A ``@public ``-style decorator, as in the third-party ``atpublic ``
408409package, works neatly for individually defined functions and classes,
@@ -421,7 +422,7 @@ both problems, because it's part of the import statement itself; it
421422adds nothing beyond the import that would exist anyway.
422423
423424Why only re-exports
424- -----------------------------
425+ -------------------
425426
426427This PEP deliberately omits a way to mark a fresh ``def ``, ``class ``, or
427428assignment as exported where it's defined. Some smaller libraries and
@@ -453,7 +454,7 @@ propose a definition-site marker if real-world evidence for that gap
453454emerges; this PEP doesn't need to solve it to solve the re-export problem.
454455
455456Why no runtime enforcement
456- -----------------------------
457+ --------------------------
457458
458459The author finds runtime access restriction appealing on its own merits,
459460and excludes it here purely on scope grounds. :pep: `842 ` proposes exactly
@@ -479,7 +480,7 @@ with the syntax that produces that ``__all__`` in the first place.
479480
480481
481482Backwards Compatibility
482- ========================
483+ =======================
483484
484485``export `` is a soft keyword, following the same approach as ``match ``,
485486``case ``, and ``type ``. Python treats it specially only in the one
@@ -504,13 +505,13 @@ minimum supported version catches up:
504505
505506
506507 Security Implications
507- =======================
508+ =====================
508509
509510This PEP has no known security implications.
510511
511512
512513How to Teach This
513- ====================
514+ =================
514515
515516Documentation should teach ``from <module> export <name> `` as part of a
516517named layout, the **hub-and-internals ** pattern, not as an isolated
@@ -564,18 +565,18 @@ plugins.
564565
565566
566567Reference Implementation
567- ===========================
568+ ========================
568569
569570No reference implementation exists yet. A prototype could be built as a
570571source-to-source transform (similar to early prototypes of ``match ``
571572statements) before committing to grammar changes in CPython.
572573
573574
574575Rejected Ideas
575- ================
576+ ==============
576577
577578Alternative surface syntax
578- -------------------------------
579+ --------------------------
579580
580581This PEP considered two other spellings for the re-export statement:
581582
@@ -594,10 +595,10 @@ This PEP considered two other spellings for the re-export statement:
594595
595596
596597Open Issues
597- =============
598+ ===========
598599
599600Should ``export * `` require the source module to define ``__all__ ``?
600- ---------------------------------------------------------------------
601+ --------------------------------------------------------------------
601602
602603The two-tier layout that motivates the wildcard form (see
603604`Specification `_) depends on the internal module having deliberately
@@ -619,7 +620,7 @@ error if it doesn't?
619620
620621
621622Acknowledgements
622- ===================
623+ ================
623624
624625This PEP grew out of discussion on :pep: `842 `, particularly
625626contributions from Peter Bierma, Alex Grönholm, Guido van Rossum, Barry
@@ -640,7 +641,7 @@ Change History
640641
641642
642643Copyright
643- ===========
644+ =========
644645
645646This document is placed in the public domain or under the
646647CC0-1.0-Universal license, whichever is more permissive.
0 commit comments