Skip to main content

deproc-python

Python language plugin for deproc.

Parses .py and .pyi files with tree-sitter into the deproc entity model, links them into a package hierarchy, and resolves names across modules.

Features

  • Modules, classes, functions and methods, constants, type aliases, imports and import aliases as deproc entities
  • Regular packages (__init__.py) and implicit namespace packages, including a namespace package contributed by several roots
  • Python's regular-package precedence across roots: a regular package wins over a same-named namespace portion from another root
  • Name resolution through imports, relative imports and wildcard imports
  • Class MRO (C3 linearization) and inherited members
  • Entity serialization to flat records and back

Install

python -m pip install deproc-python

deproc-python supports Python 3.12 and newer and installs deproc-core with it.

Usage

from deproc.core.context import Context
from deproc.core.discovery import find_source_files
from deproc.plugins.python import (
    PythonLinker,
    PythonResolver,
    PythonSourceParser,
    PythonSymbolCache,
)

ctx = Context(base_path="/path/to/project")
ctx.set_language("python", [".py", ".pyi"], aliases=["py"])
ctx.set_parser("python", PythonSourceParser())
ctx.set_linker("python", PythonLinker())
ctx.set_resolver("python", PythonResolver())
ctx.set_symbol_cache(PythonSymbolCache())

files = find_source_files(ctx)
parser = ctx.get_parser("python")
modules = [parser.parse_file(path, ctx) for path in files]
ctx.get_linker("python").link_files(modules, ctx)

result = ctx.get_resolver("python").resolve("acme_billing.invoice", "TaxRate", ctx)
print(result.status)  # resolved
for entity_id in result.resolved_ids:
    print(ctx.entity_registry.get(entity_id).fqn)  # acme_billing.tax.TaxRate

result.status is a ResolutionStatus (RESOLVED, UNRESOLVED, AMBIGUOUS, or INACCESSIBLE) from deproc.core.interfaces.resolver. The result also carries unresolved_ids, ambiguous_ids, inaccessible_ids, reason and candidates.

PythonResolver also provides resolve_class_mro(class_id, ctx) and get_inherited_members(class_id, ctx).

Several roots

When several roots contribute the same package name, deproc follows Python's import rule:

  • A regular package (__init__.py) in one root wins over a same-named namespace portion in another root, in any root order. The shadowed portion and its modules are removed.
  • Namespace portions with the same name in several roots become one namespace package.
  • When regular packages with the same name are in several per-root registries, the first registry's copy wins and the others are removed, as on sys.path. A shared registry has no root order, so it keeps all of them. A warning names the roots in both cases.

PythonLinker.link_files() applies this rule automatically when roots share one registry; PythonLinker(apply_package_precedence=False) turns it off. deproc.plugins.python.utils.packages provides apply_regular_package_precedence() for separate per-root registries, apply_regular_package_precedence_to_registry() for one shared registry, and find_regular_package_conflicts(). Pass root_labels to either precedence function to name roots in the warning.

Package layout

deproc-python/
├── deproc/plugins/python/
│   ├── parser/         PythonSourceParser (tree-sitter AST → entities)
│   ├── linker/         PythonLinker (modules → package hierarchy)
│   ├── resolver/       PythonResolver (names, MRO, inherited members)
│   ├── symbol_cache/   PythonSymbolCache (per-module cache)
│   └── utils/          imports, exports, MRO, package precedence, serialization
└── tests/

Dependencies

  • deproc-core (entity model, Context, EntityRegistry)
  • deproc-utils-tree-sitter (AST walking utilities)
  • tree-sitter (>=0.25.2,<0.26) and tree-sitter-python (Python grammar)

Metadata

Release files for deproc-python 0.5.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 deproc-python 0.5.0
File Size Uploaded Provenance Actions
deproc_python-0.5.0.tar.gz 45.4 kB With provenance Details for deproc_python-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for deproc-python 0.5.0
File Interpreter ABI Platform Actions
deproc_python-0.5.0-py3-none-any.whl Python 3 none any Details for deproc_python-0.5.0-py3-none-any.whl

Total release size: 74.4 kB

Release files / deproc_python-0.5.0.tar.gz

Download URL deproc_python-0.5.0.tar.gz
Size 45.4 kB
Tags Source
SHA-256 checksum
How to use checksums
acedac76a6e9ee9a9472707e07fbbb0dda3b746ba12ee818a4ab0d2cb8df7f9c
BLAKE2b-256 checksum
How to use checksums
c5247c7c952d159bd4eb40308be0f905e06b3f8e114649af7386196d04ab04a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

Release files / deproc_python-0.5.0-py3-none-any.whl

Download URL deproc_python-0.5.0-py3-none-any.whl
Size 29.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2064e83d4a51edf1ea2c1ff67b499a4c658ebdab82efd238fe79d55d918fa2d
BLAKE2b-256 checksum
How to use checksums
b5daa954ace195aca6572e437faccd006f81bf6c855f601eae58f9022f6f8b98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

Security for deproc-python 0.5.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 deproc_python-0.5.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 Dec 1, 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.

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