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.2
    hooks:
      - id: privata

For a less strict setup that only runs when requested:

repos:
  - repo: https://github.com/basnijholt/privata
    rev: v0.1.2
    hooks:
      - id: privata-manual
pre-commit run --hook-stage manual privata-manual --all-files

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.2.tar.gz (59.1 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.2-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: privata-0.1.2.tar.gz
  • Upload date:
  • Size: 59.1 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.2.tar.gz
Algorithm Hash digest
SHA256 cb6f63381a4394d6af0867bbf85fe666d0e3ec286706fb4672613669e342c553
MD5 bf9817b5cbfaac141a7d9412f35b6f83
BLAKE2b-256 0295fc619243c3680d804d07eebf86bec7f5140071020440bf504389a70bd267

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: privata-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b4193e38da659bb1e52acbbb90908e2cbb1160087d3a9f4d00142f628d68f335
MD5 e5ba0296e99fa6cc66160f761b4c8a03
BLAKE2b-256 2cde884554f15c3fdc5c93f816b2fbac9adfc2dd00bf008b134f1f976ffe73b3

See more details on using hashes here.

Provenance

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