Skip to main content

Python semantic data extractor for Context-Footprint (AST + pluggable resolvers)

Project description

cf-extractor

Python semantic data extractor for Context-Footprint. Outputs SemanticData JSON using Python AST plus a pluggable resolver backend. ty is the default backend; jedi remains available as a baseline resolver, and other LSP-backed backends can be plugged in for comparison.

As a dependency

This package is a dependency of cftool. When you install cftool via uv or pip, cf-extractor is installed automatically:

uv tool install cftool   # includes cf-extractor

Standalone usage

You can also install and use cf-extractor directly:

# From PyPI (when published)
pip install cf-extractor

# From Git
uv pip install "cf-extractor @ git+https://github.com/context-footprint/context-footprint#subdirectory=extractors/python"

# Development
cd extractors/python
uv sync

Run the extractor:

cf-extract /path/to/python/project
# or
uv run cf-extract /path/to/python/project
# or
python -m cf_extractor.main /path/to/project

Without arguments, uses the current directory (.). Output is written to stdout (valid JSON for cftool).

Resolver backend options:

cf-extract /path/to/python/project
cf-extract /path/to/python/project --resolver-backend jedi
cf-extract /path/to/python/project --resolver-backend ty --ty-path /path/to/ty
cf-extract /path/to/python/project --resolver-backend pyrefly --pyrefly-path /path/to/pyrefly

Optional metrics output for benchmarking:

cf-extract /path/to/python/project --metrics-out metrics.json
cf-extract-benchmark \
  --dataset small=tests/fixtures \
  --dataset medium=/path/to/project \
  --dataset large=/path/to/project \
  --report-out benchmark.md

Backend diffing:

cf-extract-diff /path/to/python/project --left jedi --right ty --report-out diff.md
cf-extract-diff /path/to/python/project --left ty --right pyrefly --report-out diff.md

Tests

uv run pytest tests/ -v

Requirements

  • Python >= 3.9
  • pydantic, ty (installed automatically)
  • jedi is only needed for baseline comparison with --resolver-backend jedi
  • pyrefly is only needed for comparison with --resolver-backend pyrefly

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

cf_extractor-0.2.0.tar.gz (43.3 kB view details)

Uploaded Source

Built Distribution

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

cf_extractor-0.2.0-py3-none-any.whl (43.0 kB view details)

Uploaded Python 3

File details

Details for the file cf_extractor-0.2.0.tar.gz.

File metadata

  • Download URL: cf_extractor-0.2.0.tar.gz
  • Upload date:
  • Size: 43.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for cf_extractor-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c3065340150d5c2472885133fa81a45bcf9f6bd18cf892dca1ace03f42703e39
MD5 fca437272a03d945da4be5741f55e2d3
BLAKE2b-256 3c38aef0d47a86c36dd646bf0a8e3b8aa168825b2c21cb5b1b0ba3ee62f918ff

See more details on using hashes here.

File details

Details for the file cf_extractor-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cf_extractor-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 43.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for cf_extractor-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d5e7c968db4fcdfe6eb4a64acfc7d44a9723f6bb1cc471c20501acb779be9e1
MD5 95fd8bb716acd37bf1a1dc64389ac471
BLAKE2b-256 80ffe3e02e9d3c6af4b25f9f411e9e58a7dfedb4bc2279fc700ffd53660b3f08

See more details on using hashes here.

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