Skip to content

Commit 5d2a531

Browse files
authored
Merge pull request #152 from codellm-devkit/137-feature-request-feature-parity-between-java-and-python-analysis
Python analysis parity with Java (codeanalyzer-python backend)
2 parents c77183a + 24c8957 commit 5d2a531

19 files changed

Lines changed: 3300 additions & 1108 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ RUN groupadd --gid $USER_GID $USERNAME \
3535
# Set up the Python development environment
3636
WORKDIR /python-sdk
3737
RUN python3 -m pip install --upgrade pip wheel && \
38-
pip3 install poetry==1.8.5
38+
pip3 install uv
3939

4040
# Enable color terminal for docker exec bash
4141
ENV TERM=xterm-256color

.devcontainer/devcontainer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
"ms-python.pylint",
5050
"ms-python.flake8",
5151
"ms-python.black-formatter",
52-
"zeshuaro.vscode-python-poetry",
5352
"njpwerner.autodocstring",
5453
"wholroyd.jinja",
5554
"yzhang.markdown-all-in-one",
@@ -67,5 +66,5 @@
6766
]
6867
}
6968
},
70-
"postCreateCommand": "sudo poetry config virtualenvs.create false && sudo poetry install; echo '---'; python3 --version; echo '---'; java -version; echo '---'; mvn --version; echo '--'; clang --version; echo '---';"
69+
"postCreateCommand": "uv sync --all-groups; echo '---'; python3 --version; echo '---'; java -version; echo '---'; mvn --version; echo '--'; clang --version; echo '---';"
7170
}

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
source .venv/bin/activate

.github/workflows/release.yml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Python Poetry Release
1+
name: Python uv Release
22

33
on:
44
push:
@@ -16,11 +16,6 @@ jobs:
1616
- name: Check out code
1717
uses: actions/checkout@v4
1818

19-
- name: Set up Python
20-
uses: actions/setup-python@v5
21-
with:
22-
python-version: '3.11'
23-
2419
- name: Set up GraalVM CE Java 11
2520
uses: graalvm/setup-graalvm@v1
2621
with:
@@ -32,21 +27,21 @@ jobs:
3227
- name: Install jq
3328
run: sudo apt-get update && sudo apt-get install -y jq
3429

35-
- name: Install Poetry
36-
run: |
37-
curl -sSL https://install.python-poetry.org | python3 -
38-
echo "${HOME}/.local/bin" >> $GITHUB_PATH
39-
export PATH="${HOME}/.local/bin:$PATH"
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v4
32+
with:
33+
enable-cache: true
34+
35+
- name: Set up Python
36+
run: uv python install 3.11
4037

4138
- name: Install Python package dependencies
42-
run: |
43-
poetry config virtualenvs.create false
44-
poetry install --sync --no-interaction
39+
run: uv sync --all-groups --frozen
4540

4641
- name: Run Tests
4742
id: test
4843
continue-on-error: true
49-
run: poetry run make test
44+
run: uv run make test
5045

5146
- name: Delete tag on failure
5247
if: steps.test.conclusion == 'failure'
@@ -64,7 +59,7 @@ jobs:
6459
mv codeanalyzer-*.jar ${{ github.workspace }}/cldk/analysis/java/codeanalyzer/jar/
6560
6661
- name: Build Package
67-
run: poetry build
62+
run: uv build
6863

6964
- name: Read Changelog Entry
7065
id: changelog_reader
@@ -92,4 +87,4 @@ jobs:
9287
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9388

9489
- name: Publish package distributions to PyPI
95-
run: poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
90+
run: uv publish --token ${{ secrets.PYPI_API_TOKEN }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
# Cache files
1818
.cache/
1919

20+
# CLDK / codeanalyzer-python analysis artifacts
21+
.codeanalyzer/
22+
.cldk-cache/
23+
2024
# Mobile Tools for Java (J2ME)
2125
.mtj.tmp/
2226

Makefile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,24 @@ all: help
1313
.PHONY: venv
1414
venv: ## Create a Python virtual environment
1515
$(info Creating Python 3 virtual environment...)
16-
poetry shell
16+
uv venv
1717

1818
.PHONY: install
1919
install: ## Install Python dependencies in virtual environment
2020
$(info Installing dependencies...)
21-
poetry config virtualenvs.in-project true
22-
poetry install --all-extras
21+
uv sync --all-groups
2322

2423
.PHONY: lint
2524
lint: ## Run the linter
2625
$(info Running linting...)
27-
flake8 cldk --count --select=E9,F63,F7,F82 --show-source --statistics
28-
flake8 cldk --count --max-complexity=10 --max-line-length=180 --statistics
29-
pylint cldk --max-line-length=180
26+
uv run flake8 cldk --count --select=E9,F63,F7,F82 --show-source --statistics
27+
uv run flake8 cldk --count --max-complexity=10 --max-line-length=180 --statistics
28+
uv run pylint cldk --max-line-length=180
3029

3130
.PHONY: test
3231
test: ## Run the unit tests
3332
$(info Running tests...)
34-
pytest --pspec --cov=cldk --cov-fail-under=75 --disable-warnings
33+
uv run pytest --pspec --cov=cldk --cov-fail-under=75 --disable-warnings
3534

3635
##@ Build
3736

@@ -56,4 +55,4 @@ build: ## Builds a new Python wheel
5655
mv codeanalyzer-*.jar cldk/analysis/java/codeanalyzer/jar/
5756

5857
# Build the package
59-
poetry build
58+
uv build

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,20 @@ Each language has a dedicated analysis backend implemented under `cldk.analysis.
204204

205205
#### Python
206206
- **Backend:** `cldk.analysis.python`
207-
- **Tools:** Tree-sitter
208-
- **Capabilities:** Lightweight structural parsing, method/function boundaries, control/data flow approximation
207+
- **Tools:** `codeanalyzer-python` (Jedi + CodeQL, default on), Tree-sitter for source-level parsing
208+
- **Capabilities:** Symbol table, call graph, class/method resolution, comments/docstrings
209+
210+
> **Note — analysis cache:** Caching is owned entirely by
211+
> `codeanalyzer-python`; CLDK keeps no cache of its own. Artifacts (the
212+
> backend virtualenv, CodeQL database, and `analysis_cache.json`) live under
213+
> the backend's `cache_dir`, which defaults to `<project>/.codeanalyzer` and
214+
> can be redirected with the `cache_dir` argument. **CodeQL is enabled by
215+
> default** (`use_codeql=True`), so the first analysis of a project builds a
216+
> CodeQL database and provisions the CodeQL CLI — expect a slow cold run;
217+
> subsequent runs reuse the backend's checksum-validated cache. Pass
218+
> `use_codeql=False` for Jedi-only analysis. Add the `cache_dir` location
219+
> (e.g. `.codeanalyzer/`) to your `.gitignore` — it is large and
220+
> environment-specific.
209221
210222
#### C
211223
- **Backend:** `cldk.analysis.c`

0 commit comments

Comments
 (0)