Skip to content

Commit

Permalink
mypy: Fix mypy CI
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
  • Loading branch information
arthurscchan committed Feb 3, 2025
1 parent 24a4da0 commit adb4e29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
- name: Install Dependencies
run: |
pip install mypy types-PyYAML
- name: Install FI as modules
run: |
cd src && pip install .

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 2: pipCommand not pinned by hash
Click Remediation section below to solve this issue
- name: mypy
run: |
cd src && mypy --ignore-missing-imports -m main
14 changes: 9 additions & 5 deletions src/fuzz_introspector/frontends/frontend_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ def __init__(self, root: Node, tree_sitter_lang: Language,

def function_source_code_as_text(self) -> str:
"""Returns the source code the function."""
return self.root.text.decode()
if self.root and self.root.text:
return self.root.text.decode()

return ''

def _extract_pointer_array_from_type(
self, param_name: Node) -> tuple[int, int, Node]:
Expand Down Expand Up @@ -364,9 +367,9 @@ def _traverse_node_instr_count(node: Node) -> int:
def _process_invoke(self, expr: Node,
project) -> list[tuple[str, int, int]]:
"""Internal helper for processing the function invocation statement."""
# logger.debug('Handling invoke statmenet: %s', expr.text.decode())
# logger.debug('Current namespace: %s', self.namespace_or_class)
logger.debug('Processing invoke: %s', expr.text.decode())
logger.debug('Processing invoke: %s',
expr.text.decode() if expr.text else '')
callsites = []
target_name: str = ''

Expand Down Expand Up @@ -480,7 +483,8 @@ def _process_field_expr_return_type(self, field_expr: Node,
def _process_callsites(self, stmt: Node,
project) -> list[tuple[str, int, int]]:
"""Process and store the callsites of the function."""
logger.debug('Processing callsite: %s', stmt.text.decode())
logger.debug('Processing callsite: %s',
stmt.text.decode() if stmt.text else '')
callsites = []

# Call statement
Expand Down Expand Up @@ -536,7 +540,7 @@ def _process_callsites(self, stmt: Node,
except AttributeError:
var_name = None

if not var_name:
if not var_name or not var_name.text:
logger.debug('Could not extract necessary attributes')
return []

Expand Down

0 comments on commit adb4e29

Please sign in to comment.