A Python module privacy checker for keeping public interfaces intentional.
Project description
Privata
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._internalare 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__.pyand__all__. - Tach
[[interfaces]]entries, whentach.tomlis 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0c1ffc00aad6caaad851a76bbc4e24b2a86224b902e732ebadb4d00348dc43e
|
|
| MD5 |
282c0d16cc91020cd0c39d57a2e91e25
|
|
| BLAKE2b-256 |
bb43b2ddca294917352a5077a630236fee36601c619cc89f59b71fcbd0bc1566
|
Provenance
The following attestation bundles were made for privata-0.1.1.tar.gz:
Publisher:
release.yml on basnijholt/privata
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
privata-0.1.1.tar.gz -
Subject digest:
a0c1ffc00aad6caaad851a76bbc4e24b2a86224b902e732ebadb4d00348dc43e - Sigstore transparency entry: 1443520289
- Sigstore integration time:
-
Permalink:
basnijholt/privata@75a7727b99725d2cc5c0a70c4f55a24f1a7b9610 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/basnijholt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@75a7727b99725d2cc5c0a70c4f55a24f1a7b9610 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fa130c1c0494fa8ea5397df2a909134ca74c2de3dfbb8e956712c309f978890
|
|
| MD5 |
42a68d2aa360fcb4a272b51046d18a56
|
|
| BLAKE2b-256 |
3513e99373d65e2278529449e9f1965dc73ad75d02e0a843860e88236362d133
|
Provenance
The following attestation bundles were made for privata-0.1.1-py3-none-any.whl:
Publisher:
release.yml on basnijholt/privata
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
privata-0.1.1-py3-none-any.whl -
Subject digest:
2fa130c1c0494fa8ea5397df2a909134ca74c2de3dfbb8e956712c309f978890 - Sigstore transparency entry: 1443520367
- Sigstore integration time:
-
Permalink:
basnijholt/privata@75a7727b99725d2cc5c0a70c4f55a24f1a7b9610 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/basnijholt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@75a7727b99725d2cc5c0a70c4f55a24f1a7b9610 -
Trigger Event:
release
-
Statement type: