Skip to content

Commit 5eb6c7e

Browse files
committed
remove changeset
1 parent d9d6ddb commit 5eb6c7e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

api/analyzers/python/analyzer.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import subprocess
22
from multilspy import SyncLanguageServer
33
from pathlib import Path
4+
5+
import toml
46
from ...entities import *
57
from typing import Optional
68
from ..analyzer import AbstractAnalyzer
@@ -22,10 +24,16 @@ def add_dependencies(self, path: Path, files: list[Path]):
2224
if Path(f"{path}/pyproject.toml").is_file():
2325
subprocess.run([f"{path}/venv/bin/pip", "install", "poetry"])
2426
subprocess.run([f"{path}/venv/bin/poetry", "install"])
25-
files.extend(Path(f"{path}/venv").rglob("*.py"))
27+
with open(f"{path}/pyproject.toml", 'r') as file:
28+
pyproject_data = toml.load(file)
29+
for requirement in pyproject_data.get("tool").get("poetry").get("dependencies"):
30+
files.extend(Path(f"{path}/venv/{requirement}").rglob("*.py"))
2631
elif Path(f"{path}/requirements.txt").is_file():
2732
subprocess.run([f"{path}/venv/bin/pip", "install", "-r", "requirements.txt"])
28-
files.extend(Path(f"{path}/venv").rglob("*.py"))
33+
with open(f"{path}/requirements.txt", 'r') as file:
34+
requirements = [line.strip().split("==") for line in file if line.strip()]
35+
for requirement in requirements:
36+
files.extend(Path(f"{path}/venv/{requirement}").rglob("*.py"))
2937

3038
def get_entity_label(self, node: Node) -> str:
3139
if node.type == 'class_definition':

0 commit comments

Comments
 (0)