Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mypy: Fix mypy CI #2044

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
- 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
Loading