Skip to main content

Python bindings for stack graphs — name resolution for any programming language

Project description

py-stack-graphs

Python bindings for stack graphs — name resolution for any programming language.

Stack graphs resolve references to definitions across files without needing the full language toolchain. Built on tree-sitter grammars with scope rules that define how names flow through imports, scopes, and re-exports.

Install

pip install py-stack-graphs

Usage

from py_stack_graphs import StackGraphIndex

idx = StackGraphIndex()
count = idx.index_project("/path/to/project", language="python")
print(f"Indexed {count} files")

# Resolve a specific reference
defs = idx.resolve("src/app.py", line=42, column=10)
for d in defs:
    print(f"  -> {d.symbol} at {d.file}:{d.line}")

# Get all references in a file with resolutions
refs = idx.all_references("src/app.py")
for ref in refs:
    if ref.resolved_to:
        print(f"  {ref.symbol} -> {ref.resolved_to.symbol}")
    else:
        print(f"  {ref.symbol} (unresolved)")

Supported Languages

Language Feature flag Grammar
Python python (default) tree-sitter-stack-graphs-python
TypeScript typescript (default) tree-sitter-stack-graphs-typescript
JavaScript javascript (default) tree-sitter-stack-graphs-javascript

How it works

Source code
    ↓
tree-sitter (parse to CST)
    ↓
stack graph rules (scope + name binding)
    ↓
stack graph (nodes = defs/refs, edges = scope flow)
    ↓
path stitching (resolve refs → defs)
    ↓
Python API (StackGraphIndex)

Stack graphs sit between tree-sitter (structural only) and full LSP (complete type inference):

  • Tree-sitter: foo.bar() → "calls foo.bar" (unresolved string)
  • Stack graphs: foo.bar() → "calls MyModule.MyClass.bar" (resolved via imports/scopes)
  • LSP: foo.bar() → "calls MyModule.MyClass.bar, returns int" (fully typed)

Building from source

Requires Rust toolchain:

pip install maturin
maturin develop

License

MIT

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

py_stack_graphs-0.1.0.tar.gz (18.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

py_stack_graphs-0.1.0-cp313-cp313-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.13Windows x86-64

py_stack_graphs-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

py_stack_graphs-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

py_stack_graphs-0.1.0-cp312-cp312-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.12Windows x86-64

py_stack_graphs-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

py_stack_graphs-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

py_stack_graphs-0.1.0-cp311-cp311-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.11Windows x86-64

py_stack_graphs-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

py_stack_graphs-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

py_stack_graphs-0.1.0-cp310-cp310-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.10Windows x86-64

py_stack_graphs-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

py_stack_graphs-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file py_stack_graphs-0.1.0.tar.gz.

File metadata

  • Download URL: py_stack_graphs-0.1.0.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for py_stack_graphs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5f8a3ecf7e712fe59ea3078d58f67f2d9bd0441846be8f8a188f932908307bb6
MD5 4922be8059bf02a91be61c463f002a86
BLAKE2b-256 eb63815d469e6ac5826cc061ff147619ddd5eb82be26576f3efc026f8f77af48

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_stack_graphs-0.1.0.tar.gz:

Publisher: release.yml on austerecryptid/py-stack-graphs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_stack_graphs-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for py_stack_graphs-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 47f925582f656bb8b5bb3cb8825a3a9a75d7533f370f45a44dc5fae051a3346a
MD5 c577e5fbfcab479f8c590e5cda993fbd
BLAKE2b-256 1dd08c7b4c68eca9eab3ae614bdc1f862ff47a5dd06ac77d1fbe2183d5c820c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_stack_graphs-0.1.0-cp313-cp313-win_amd64.whl:

Publisher: release.yml on austerecryptid/py-stack-graphs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_stack_graphs-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for py_stack_graphs-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d6f322853708dc8625bae2e1da910ddae9f818a43cde0a42a5a91d1e2de94f8c
MD5 c6736f908f043068b2cba40cb45c8721
BLAKE2b-256 5b41af39bef091efeec48acc8622b1dcdcc4bd9f4a62379d50cb6b40ca9e02c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_stack_graphs-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: release.yml on austerecryptid/py-stack-graphs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_stack_graphs-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for py_stack_graphs-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 471197e3d095ade3be359bce52fd5cbdcee3fbf774286e459618e7a8d401b0bd
MD5 d2f605860e54c686a8af3d382a23219e
BLAKE2b-256 383f37f3b22e5c3ad2791835ce83ee81cda4a9feee689716b0518d98a1caa0f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_stack_graphs-0.1.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on austerecryptid/py-stack-graphs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_stack_graphs-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for py_stack_graphs-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7f15c40e787b8124c14f9b41c490205410fe1382d88b5e0beda9d789ef15b500
MD5 efd60ede41bfea1844af296bc3180ea4
BLAKE2b-256 13743a15c28ed3712ae4839a18d34e5243c2a81a0c69f436d62567cf3338f41f

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_stack_graphs-0.1.0-cp312-cp312-win_amd64.whl:

Publisher: release.yml on austerecryptid/py-stack-graphs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_stack_graphs-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for py_stack_graphs-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a1903df066b66e79184db92ae5e37f90e303dd070b4ce9771245a47b90675553
MD5 e55c1632b23b3669b521f5c3026acb80
BLAKE2b-256 c9637aa253665003bb02cd2129700f22417dbe22f41f9850f9c2652a54c3eb3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_stack_graphs-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: release.yml on austerecryptid/py-stack-graphs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_stack_graphs-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for py_stack_graphs-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 03f8eb539d86705f488869914ead178da05492bc196d56a8ee459e3d2899c608
MD5 f74650397f9c9377c21598605f5bf985
BLAKE2b-256 1ef161f20c515ded4d879a5b3ebbf6e23a5e7c3ac3d002697b1a8cb3f9d9a88b

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_stack_graphs-0.1.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on austerecryptid/py-stack-graphs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_stack_graphs-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for py_stack_graphs-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 80cc148e5f7709b509bbba7fd72f20cbc742b7afa06d5995ed671ffcc499e129
MD5 2dfcfec503ed5e4bb29942ea7a613c17
BLAKE2b-256 130745b9dd5d8ea00deac4a1b11633039e3a2cb7ae7343306acf4285ef6e1266

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_stack_graphs-0.1.0-cp311-cp311-win_amd64.whl:

Publisher: release.yml on austerecryptid/py-stack-graphs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_stack_graphs-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for py_stack_graphs-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 38a9d8f30d4d8099309093ebbc7171abebd366a878a5b86d022cf38ba4e824ce
MD5 661d82ee759328be913f3c3d16879efc
BLAKE2b-256 3d1bf49b4b9a1a04e1ce30553c8e37d16ff1340bdc064cdf6773b09202f02773

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_stack_graphs-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: release.yml on austerecryptid/py-stack-graphs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_stack_graphs-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for py_stack_graphs-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 803fac9a2c970a2fec5fa2d07906abc4f6304d35c0b407c637c5add6ec7c16d6
MD5 84bfc2cfd50e3fb8e9ce37f33bf19f2e
BLAKE2b-256 2e9b578aaf22a239a901d0be04a5dea99f4782cd5140b6e9fe77e85cb5d351ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_stack_graphs-0.1.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on austerecryptid/py-stack-graphs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_stack_graphs-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for py_stack_graphs-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6f650f17176cb4eb73f8525b9a5ca9a313c6bebb9b5b1a4319347014d451d01a
MD5 b20756d347b186d4d7105ef3255fdd6d
BLAKE2b-256 96b38e57cfedd81c11c1a1a89f09248e2a5bf7892bdffd3681fd23f4f208507a

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_stack_graphs-0.1.0-cp310-cp310-win_amd64.whl:

Publisher: release.yml on austerecryptid/py-stack-graphs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_stack_graphs-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for py_stack_graphs-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2e4dc471fc4f812d9797a9d8e1c49203bfc88cee057575314b791ecc696ced2a
MD5 de887a16f356006415d2413a004c0a2b
BLAKE2b-256 bd3b977114b9fc90eca56f70d34e32a5fc5dc172379b393311f30c74680a3622

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_stack_graphs-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: release.yml on austerecryptid/py-stack-graphs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_stack_graphs-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for py_stack_graphs-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 baba8ce2530cbc04af93eba6891d0bd5b756d246f185e07462fdeaa0e41e307d
MD5 ab5aa014b9084c2fa1e8b9377f8e45e6
BLAKE2b-256 b8de5c1a68012a13c0912c9dfab0654cdd2fe0e277cfafdcc7aa516c1dd8f5e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_stack_graphs-0.1.0-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on austerecryptid/py-stack-graphs

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