detect_llm_api_keys

class detect_llm_api_keys.APIKeyDetector(lines: list[str])[source]

Bases: NodeVisitor

A class for detecting API keys in Python code.

classmethod check_code(python_code: str) dict[str, list[int]][source]

Check Python code for API keys.

Parameters:

python_code (str) – The Python code to check for API keys.

Returns:

results – A dictionary mapping API key providers to line numbers where API keys were found.

Return type:

dict[str, list[int]]

classmethod check_file(py_file: str) dict[str, list[int]][source]

Check a Python file for API keys.

Parameters:

py_file (str) – The Python file to check for API keys.

Returns:

results – A dictionary mapping API key providers to line numbers where API keys were found.

Return type:

dict[str, list[int]]

visit_Constant(node: Constant)[source]