From 938169e1458440687efed3bc855ebb4aeaf96dfc Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Thu, 2 Jan 2025 10:39:57 +0200 Subject: [PATCH] fix error when no function or struct in code --- api/analyzers/c/analyzer.py | 25 ++++++++++++++----------- poetry.lock | 8 ++++---- pyproject.toml | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/api/analyzers/c/analyzer.py b/api/analyzers/c/analyzer.py index 149915c..09a5e26 100644 --- a/api/analyzers/c/analyzer.py +++ b/api/analyzers/c/analyzer.py @@ -369,21 +369,24 @@ def first_pass(self, path: Path, f: io.TextIOWrapper, graph:Graph) -> None: # ] # } - functions = captures['function'] - for node in functions: - self.process_function_definition(file, node, path, graph, source_code) + if 'function' in captures: + functions = captures['function'] + for node in functions: + self.process_function_definition(file, node, path, graph, source_code) # Process struct definitions query = C_LANGUAGE.query("(struct_specifier) @struct") captures = query.captures(tree.root_node) - structs = captures['struct'] - # captures: {'struct': - # [ - # - # ] - # } - for node in structs: - self.process_struct_specifier(file, node, path, graph) + + if 'struct' in captures: + structs = captures['struct'] + # captures: {'struct': + # [ + # + # ] + # } + for node in structs: + self.process_struct_specifier(file, node, path, graph) def second_pass(self, path: Path, f: io.TextIOWrapper, graph: Graph) -> None: """ diff --git a/poetry.lock b/poetry.lock index b59f114..9890b54 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1244,13 +1244,13 @@ test = ["ipykernel", "pre-commit", "pytest (<8)", "pytest-cov", "pytest-timeout" [[package]] name = "litellm" -version = "1.56.4" +version = "1.56.5" description = "Library to easily interface with LLM API providers" optional = false python-versions = "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,>=3.8" files = [ - {file = "litellm-1.56.4-py3-none-any.whl", hash = "sha256:699a8db46f7de045069a77c435e13244b5fdaf5df1c8cb5e6ad675ef7e104ccd"}, - {file = "litellm-1.56.4.tar.gz", hash = "sha256:2808ca21878d200f7676a3d11e5bf2b5e3349ae504628f279cd7297c7dbd2038"}, + {file = "litellm-1.56.5-py3-none-any.whl", hash = "sha256:4388e9456deea92689d109ac282dc3bc133acb06f543682ad1fe02a1ab063b7e"}, + {file = "litellm-1.56.5.tar.gz", hash = "sha256:a25b4d7f7f7d2339cca1165126e1abf9ceb30b02b7481037a1f45a6ab87b9ec7"}, ] [package.dependencies] @@ -2976,4 +2976,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "8dbd2a1d5d8b010c2723c9eb8b1f56080f5148b9a20c7184be43aa16a8f42c44" +content-hash = "971202a22f922ad50b8e95b2e0b183daabcfa72eda53bae9e70c032ed9650a12" diff --git a/pyproject.toml b/pyproject.toml index 5a80e1d..8e55ec4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ validators = "^0.34.0" falkordb = "^1.0.5" tree-sitter-c = "^0.23.2" tree-sitter-python = "^0.23.6" -flask = "^3.0.3" +flask = "^3.1.0" python-dotenv = "^1.0.1" [tool.poetry.group.test.dependencies]