Skip to main content

symvision

CI PyPI version Python versions License: MIT

symvision is a dependency-free symbol-visibility linter for Python. It finds public functions and classes that no production code uses, private symbols imported across module boundaries, and private symbols unused in their defining module.

Python does not enforce public and private APIs. Over time, that can leave a project with dead public surfaces and underscore-prefixed helpers that are private in name only. symvision turns those conventions into an automated check while accounting for entry points, non-Python consumers, external repositories, and APIs being built under an active epic.

Quick start

Install the symvision command with uv:

uv tool install symvision

Or install it with pipx or pip:

pipx install symvision
# or, inside a virtual environment
python -m pip install symvision

Scan the package definitions under src/:

symvision src

symvision treats Python files under the requested directory as the definition tree. When the tree is inside a Git repository, imports from tracked Python files outside it also count as usage. Definitions and imports in test-support paths (test/, tests/, testing/, or test_*.py) do not keep production APIs alive. Functions referenced by [project.scripts], [project.gui-scripts], or [project.entry-points.*] in the nearest pyproject.toml are treated as used.

Usage

symvision [-h] [--exclude-file PATH] [--epic-symbol EPIC(SYMBOL)]
          [--exclude-decorator NAME] [-E PATH]
          DIRECTORY

The options that accept values may be repeated:

Option Meaning
DIRECTORY Recursively scan Python definitions under this directory
--exclude-file PATH Exclude a file from definition and usage analysis; paths are resolved from the current working directory
--exclude-decorator NAME Ignore top-level functions and classes decorated with this name
--epic-symbol EPIC(SYMBOL) Temporarily allow an otherwise-unused public symbol while its epic is open
-E PATH, --external-repo-path PATH Add a local checkout candidate for resolving an external-repository pragma
-h, --help Show command help

For example:

symvision \
  --exclude-file src/pkg/generated.py \
  --exclude-decorator register \
  src/pkg

Pragmas for non-Python consumers

A pragma immediately above a top-level public function or class records a real consumer that static Python import analysis cannot see. The target must genuinely reference the symbol; stale or unnecessary pragmas are errors.

Local path form

Use a Git-root-relative path for generated configuration, shell code, or another non-Python consumer:

# symvision: config/application.toml
def build_application() -> Application:
    ...

The referenced file must exist, must contain the symbol name, and must not be under src/. Test-support paths and Markdown files are rejected because tests and documentation alone are not production consumers.

External repository form

Use a Git remote URI when another repository consumes the API:

# symvision: https://github.com/example/application.git
class ApplicationPlugin:
    ...

HTTPS, SSH URLs, scp-style Git remotes such as git@github.com:owner/repo.git, and file:// URLs are supported. Equivalent HTTPS and SSH origins are matched after normalization. Only Git-tracked, non-test files in the resolved checkout count; both Python imports and symbol references in non-Python text files are recognized.

External repositories resolve in this order:

  1. Paths passed with --external-repo-path, followed by paths from SYMVISION_EXTERNAL_REPO_PATHS.
  2. The current repository's parent directory and sibling directories. A checkout named exactly for the repository is preferred over other names, and numbered workspaces such as repo_2 are considered last.
  3. A deterministic shallow clone under ~/.cache/symvision/external-repos.

SYMVISION_EXTERNAL_REPO_PATHS is an os.pathsep-separated list (: on Unix, ; on Windows). Override the fallback clone root with SYMVISION_EXTERNAL_REPO_CACHE. An existing cache entry must have a matching origin; symvision will report a mismatch instead of overwriting it.

Multiple consecutive pragmas can document multiple consumers for the same definition:

# symvision: config/plugin.toml
# symvision: git@github.com:example/application.git
class ApplicationPlugin:
    ...

Symbols tied to an epic

--epic-symbol supports public APIs that are intentionally unused while an active epic is building their consumer:

BD_COMMAND=tools/sase_bead symvision \
  --epic-symbol 'sase-123(create_report)' \
  src/pkg

The value has the form <bead-id>(<symbol-name>). The command verifies that the bead exists and is not closed, that the symbol is a public definition, and that it is still otherwise unused. A closed bead, missing symbol, private symbol, or already-used symbol makes the exclusion stale and fails the scan.

symvision invokes bd show <bead-id> by default. Set BD_COMMAND to a compatible bead-tracker executable when the project uses a wrapper or another command. Remove the option once the epic's production consumer lands.

Exit codes

Code Meaning
0 The scan completed without a symbol-visibility violation, or found no Python definitions to check
1 A visibility rule, pragma, epic-symbol validation, external-repository resolution, or directory check failed
2 Command-line usage error, such as a missing required argument or an unknown option

Diagnostics are written to stdout or stderr depending on their category; integrations should use the exit code as the stable success signal.

Continuous integration

Run the same command locally and in CI. A small Justfile recipe is enough:

symvision:
    uvx --from symvision symvision src/your_package

Pin symvision to the version range appropriate for your project when reproducibility is important.

Development

The repository uses uv for environments and dependency installation, and just as its task runner. From a clone:

just install
just check

just check verifies formatting, runs Ruff and strict mypy, dogfoods both symvision and toobig, and executes the pytest suite with a 94% branch-coverage gate. The package supports Python 3.11 through 3.14 and has no runtime dependencies. Set SYMVISION_PYTHON to select the Python interpreter used by the Justfile, for example SYMVISION_PYTHON=3.14 just test.

Releases

Commits and pull-request titles follow Conventional Commits. On every push to master, release-please updates or opens a release pull request containing the next version and changelog. Merging that pull request creates the GitHub release, builds and smoke-tests the wheel in a fresh environment, and publishes symvision to PyPI using trusted publishing (GitHub Actions OIDC), without a long-lived PyPI token.

License

symvision is available under the MIT License.

Metadata

Release files for symvision 0.1.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 symvision 0.1.0
File Size Uploaded Provenance Actions
symvision-0.1.0.tar.gz 25.8 kB With provenance Details for symvision-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for symvision 0.1.0
File Interpreter ABI Platform Actions
symvision-0.1.0-py3-none-any.whl Python 3 none any Details for symvision-0.1.0-py3-none-any.whl

Total release size: 45.9 kB

Release files / symvision-0.1.0.tar.gz

Download URL symvision-0.1.0.tar.gz
Size 25.8 kB
Tags Source
SHA-256 checksum
How to use checksums
775502bc0ad04d90f8f093e9660e602a1557d6dd0c15b1526757a3949619cef7
BLAKE2b-256 checksum
How to use checksums
4c15aeb9496b4b5a617d1ac977ed8c41a0e816c2a920b9b2d55185448495514a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 12, 2026.

Transparency log

Release files / symvision-0.1.0-py3-none-any.whl

Download URL symvision-0.1.0-py3-none-any.whl
Size 20.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0347bfa05cdf88708c99ac990484a90e9fa37235290db4452435875de5327cdc
BLAKE2b-256 checksum
How to use checksums
6e91552e773854ac2a7951ed560e0593b1892719f6724465218ecd37985496fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 12, 2026.

Transparency log

Security for symvision 0.1.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for symvision-0.1.0.tar.gz

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 Jul 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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