11import subprocess
22from multilspy import SyncLanguageServer
33from pathlib import Path
4+
5+ import toml
46from ...entities import *
57from typing import Optional
68from ..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