Skip to main content

A Python module privacy checker for keeping public interfaces intentional.

Project description

Privata

License CI PyPI Python Versions Docs

Keep Python module interfaces intentional.

Privata scans a src/ layout Python project and reports public top-level symbols that are only used inside their own module. It also reports imports of private modules from outside their owning package subtree. Test imports do not count, so tests can still reach internals without forcing those internals to stay public.

Install

uv tool install privata

For local development:

uv sync --extra dev --group docs
uv run pre-commit install

Usage

Run Privata from a project root:

privata .

Use Privata as a pre-commit hook in another repository:

repos:
  - repo: https://github.com/basnijholt/privata
    rev: v0.1.1
    hooks:
      - id: privata

Example output:

Found 2 public symbols that could be made private:

  src/example/service.py:12: function `helper`
  src/example/service.py:21: class `InternalState`

Found 1 private module imports outside their package subtree:

  src/example/api.py:3: imports private module `example.worker._runtime`

If the project is clean:

No module privacy issues found.

What Privata Checks

  • Public top-level functions, classes, variables, and type aliases in src/.
  • Whether those symbols are imported by another production module under src/.
  • Whether private modules such as pkg._internal are imported outside their containing package subtree.
  • Console entry points in pyproject.toml.
  • Uvicorn entry points in shell scripts and Dockerfiles.
  • Symbols exported through package __init__.py and __all__.
  • Tach [[interfaces]] entries, when tach.toml is present.

Privata intentionally ignores imports from tests/. If only tests import a symbol, Privata treats that symbol as private.

Development

uv run pytest  # enforces 100% coverage
uv run pre-commit run --all-files
uv build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

privata-0.1.1.tar.gz (58.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

privata-0.1.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file privata-0.1.1.tar.gz.

File metadata

  • Download URL: privata-0.1.1.tar.gz
  • Upload date:
  • Size: 58.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for privata-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a0c1ffc00aad6caaad851a76bbc4e24b2a86224b902e732ebadb4d00348dc43e
MD5 282c0d16cc91020cd0c39d57a2e91e25
BLAKE2b-256 bb43b2ddca294917352a5077a630236fee36601c619cc89f59b71fcbd0bc1566

See more details on using hashes here.

Provenance

The following attestation bundles were made for privata-0.1.1.tar.gz:

Publisher: release.yml on basnijholt/privata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file privata-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: privata-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for privata-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2fa130c1c0494fa8ea5397df2a909134ca74c2de3dfbb8e956712c309f978890
MD5 42a68d2aa360fcb4a272b51046d18a56
BLAKE2b-256 3513e99373d65e2278529449e9f1965dc73ad75d02e0a843860e88236362d133

See more details on using hashes here.

Provenance

The following attestation bundles were made for privata-0.1.1-py3-none-any.whl:

Publisher: release.yml on basnijholt/privata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page