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 container is removed and its modules stay indexed with no parent.
  • Namespace portions with the same name in several roots become one namespace package.
  • Two regular packages with the same name in different roots are both kept, and a warning names the roots, because Python would import whichever comes first on its path.

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.4.1

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.4.1
File Size Uploaded Provenance Actions
deproc_python-0.4.1.tar.gz 43.5 kB With provenance Details for deproc_python-0.4.1.tar.gz

Built distribution (wheel)

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

Total release size: 72.1 kB

Release files / deproc_python-0.4.1.tar.gz

Download URL deproc_python-0.4.1.tar.gz
Size 43.5 kB
Tags Source
SHA-256 checksum
How to use checksums
19d20c61d520753a0cb269b587997dfa385e3f3284105a8b512926e9f28249aa
BLAKE2b-256 checksum
How to use checksums
dd38db0cdd4b18893f09a55fd07b4b00a51f2bcc58d4e7d609131e746b39f396
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 Nov 26, 2026.

Transparency log

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

Download URL deproc_python-0.4.1-py3-none-any.whl
Size 28.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23edc0d313fed42b946fa639748322ccdebb5a53595093bb4eed7f039b418fd1
BLAKE2b-256 checksum
How to use checksums
c2aa0783d456944bac9919454f1bb5688c5627456feba92acfb5b43fd6e7357e
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 Nov 26, 2026.

Transparency log

Security for deproc-python 0.4.1

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.4.1.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 Nov 26, 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