@@ -61,6 +61,7 @@ def analysis(
6161 target_files : List [str ] | None = None ,
6262 analysis_backend_path : str | None = None ,
6363 analysis_json_path : str | Path = None ,
64+ cache_dir : str | Path | None = None ,
6465 use_codeql : bool = True ,
6566 ) -> JavaAnalysis | PythonAnalysis | CAnalysis :
6667 """Initialize a language-specific analysis façade.
@@ -71,8 +72,16 @@ def analysis(
7172 eager (bool): If True, forces regeneration of analysis databases.
7273 analysis_level (str): Analysis level. See AnalysisLevel.
7374 target_files (list[str] | None): Files to constrain analysis (optional).
74- analysis_backend_path (str | None): Path to the analysis backend.
75- analysis_json_path (str | Path | None): Path to persist analysis database.
75+ analysis_backend_path (str | None): Java only. Directory containing
76+ the ``codeanalyzer-*.jar`` to run. Not valid for Python — pass
77+ ``cache_dir`` instead.
78+ analysis_json_path (str | Path | None): Path to persist the analysis
79+ database / ``analysis.json``.
80+ cache_dir (str | Path | None): Python only. Writable directory where
81+ the ``codeanalyzer-python`` backend provisions its virtualenv and
82+ CodeQL database (forwarded as the backend's ``cache_dir``). When
83+ omitted, a dependency-hash-keyed location under the CLDK cache
84+ root is used. Ignored for other languages.
7685 use_codeql (bool): Python only, default True. Augments Jedi-resolved
7786 call edges with CodeQL-resolved edges; set False for a faster,
7887 Jedi-only analysis. Ignored for other languages.
@@ -81,7 +90,9 @@ def analysis(
8190 JavaAnalysis | PythonAnalysis | CAnalysis: Initialized analysis façade for the chosen language.
8291
8392 Raises:
84- CldkInitializationException: If both or neither of project_path and source_code are provided.
93+ CldkInitializationException: If both or neither of project_path and
94+ source_code are provided, or if the Java-only
95+ ``analysis_backend_path`` is passed in Python mode.
8596 NotImplementedError: If the specified language is unsupported.
8697
8798 Examples:
@@ -114,10 +125,15 @@ def analysis(
114125 elif self .language == "python" :
115126 if source_code is not None :
116127 raise CldkInitializationException ("source_code mode is not supported for Python; please pass project_path." )
128+ if analysis_backend_path is not None :
129+ raise CldkInitializationException (
130+ "analysis_backend_path is Java-only (it locates codeanalyzer-*.jar). "
131+ "For Python, use cache_dir for the backend's virtualenv/CodeQL cache."
132+ )
117133 return PythonAnalysis (
118134 project_dir = project_path ,
119135 analysis_level = analysis_level ,
120- analysis_backend_path = analysis_backend_path ,
136+ cache_dir = cache_dir ,
121137 analysis_json_path = analysis_json_path ,
122138 target_files = target_files ,
123139 eager_analysis = eager ,
0 commit comments