You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Crosshair needs the type hints to be reachable, we can avoid a subprocess call by just defensively checking if all the nodes have their type hints reachable
Using get_type_hints directly on an AST node may not accurately reflect whether annotations are actually resolvable at runtime and could produce false positives. Consider applying this check on real function objects or providing the correct global/local namespace context.
The tests for type_hints_reachable only assert negative outcomes. Add a positive test case where an object with valid annotations returns True to ensure correct behavior.
code7="""import pandas as pdfrom typing import get_type_hints"""asserttype_hints_reachable(code7) isFalsecode="""import numpy as npdef foo(x, y): return x + y"""asserttype_hints_reachable(code) isFalse
Update tests to pass actual function or class objects (e.g. by ast.parse+exec) instead of raw strings so type_hints_reachable can operate on real objects.
-assert type_hints_reachable(code7) is False+namespace = {}+exec(code7, namespace)+assert type_hints_reachable(namespace.get("foo", object())) is False
Suggestion importance[1-10]: 6
__
Why: Converting raw code strings into real function objects makes type_hints_reachable tests valid and improves reliability without altering core logic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Crosshair needs the type hints to be reachable, we can avoid a subprocess call by just defensively checking if all the nodes have their type hints reachable
PR Type
Enhancement
Description
Added type_hints_reachable helper function
Guarded concolic test generation with check
Added tests for type_hints_reachable behavior
Changes walkthrough 📝
static_analysis.py
Add type_hints_reachable functioncodeflash/code_utils/static_analysis.py
concolic_testing.py
Guard concolic tests with reachable hintscodeflash/verification/concolic_testing.py
test_static_analysis.py
Test type_hints_reachable behaviortests/test_static_analysis.py