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

Usage

Run Privata from a project root:

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 --extra dev pytest
uv run --extra dev ruff check .
uv run --extra dev ruff format --check .
uv run --extra dev mypy src tests
uv run --extra dev ty check
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.0.tar.gz (49.2 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.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: privata-0.1.0.tar.gz
  • Upload date:
  • Size: 49.2 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.0.tar.gz
Algorithm Hash digest
SHA256 a170b3816a0ed883bf9f2383efa6e9e853276ddbe96775b7f559efce787ad361
MD5 ed76ca7050de8645b8eb543ac2171768
BLAKE2b-256 50121b52ed3c574cf4afdc298f9de435763eb772ba0b9fc54885c531a53422c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for privata-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: privata-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ffcac7bd63d00526f4d374eae95313116d4a575bf85c7a9e27296ee06ac4d8d
MD5 76be9ba5b7f3428a51c531e66bc78f7d
BLAKE2b-256 589363c4f910150cfe0725f10c8f3625d1859c02fffcb75d9dc0c00dc3387bcc

See more details on using hashes here.

Provenance

The following attestation bundles were made for privata-0.1.0-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