Skip to main content

@exports

The DRY alternative to __all__

GitHub License PyPI Version Python Versions
Typing basedpyright mypy pyrefly ruff ruff


Installation

To install the exports package, you can use python-exports on PyPI:

pip install python-exports

Usage

>>> from exports import export

Now you can use it to add to __all__ as

  • function decorator

    >>> @export
    ... def spam():
    ...     ...
    
  • class decorator:

    >>> @export
    ... class Ham:
    ...     ...
    
  • by name:

    >>> from functools import reduce as fold
    >>> export('fold')
    

Behaviour

If the module has no __all__, it is created. Otherwise, __all__ is converted to a list, and the export is appended.

Caveats

Exporting a function or class directly relies on the __name__ attribute, so consider the following example:

>>> def eggs():
...     ...
>>> fake_eggs = eggs

If we want to export fake_eggs, then this will not work:

>>> export(fake_eggs)  # BAD: this will add `'eggs'` to `__all__`

In such cases, use the name instead:

>>> export('fake_eggs')  # GOOD

You'll be safe if you either

  • decorate a function or a class directly with @export,
  • pass the name string when using plain export('...') calls.

Metadata

Release files for python-exports 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-exports 1.3.0
File Size Uploaded
python_exports-1.3.0.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-exports 1.3.0
File Interpreter ABI Platform
python_exports-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.9 kB

Release files / python_exports-1.3.0.tar.gz

Download URL python_exports-1.3.0.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
124303d1f643b4e2c3bcbf5e1140f00da85b52c60bd11ce57f0104ae1dd0cad2
BLAKE2b-256 checksum
How to use checksums
4d13e0c77bb1d951e59af8a455c7280642c7e48a93febafb56b17f0931ef4176
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 10, 2026.

Transparency log

Release files / python_exports-1.3.0-py3-none-any.whl

Download URL python_exports-1.3.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd1baafa2ced944a0df3baa79b78cb3e416f8dd9a10c329516de156d80ff3dc8
BLAKE2b-256 checksum
How to use checksums
1a534f96521f0402fce3a8a3642a3d4868c7320bfd9a2741dfbaf4c2b8cce641
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 10, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page