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

Add more types hints #1666

Merged
merged 20 commits into from
Mar 22, 2023
Merged

Add more types hints #1666

merged 20 commits into from
Mar 22, 2023

Conversation

montyly
Copy link
Member

@montyly montyly commented Feb 16, 2023

  • adding TODO on areas that require further investigation

A general issue is related to the usage of the type, as it sometimes return a list of types, which might need a bit of refactoring. Moreover ExpressionTyped has derived class that redefines type

Another source of issues that will require some refactoring is the handling of top level function in the data dependencies. The analysis was not built with top level function in mind, and needs to be improved

@montyly
Copy link
Member Author

montyly commented Feb 20, 2023

Note: this PR includes #1672, #1673, #1674

@montyly montyly requested a review from elopez as a code owner February 20, 2023 18:06
@montyly
Copy link
Member Author

montyly commented Feb 20, 2023

This PR contains several minor bug fixes in the API. They will be documented before the PR is merged

@montyly montyly mentioned this pull request Feb 25, 2023
@montyly
Copy link
Member Author

montyly commented Mar 10, 2023

In addition to the types, this fixes:

  • Remove process_from_asts/--splitted, which became deadcode
  • Add SUPPORTED_TYPES / Context_types_API for the data dependencies. This allows now to give a node to data dependencies, to better support top level function. This is a quick fix, and requires a larger refactoring of the data deps. A separate issue must be created
  • Remove most of the core.children. These ended up making the API more difficult to maintain without providing enough benefit. The relevant property were added when needed in the derived objects
  • Create ContractLevel to works with TopLevel. This replaces ChildContract
  • Remove ExpressionTyped. This is legacy code, the type property ended up colliding with properties in derived objects. The relevant type properties were added when needed
  • Detector can now use DETECTOR_INFO = List[Union[str, SupportedOutput]], to type the info object. All the detectors were updated to use this. The reason for that is that mypy is a bit lost when deduced the type, as the list is a union of str + a lot of different objects.
  • Remove visitors.expression.right_value this is legacy code

@@ -70,17 +72,20 @@ def _visit(
if ir.lvalue and not isinstance(ir.lvalue, (TemporaryVariable, ReferenceVariable)):
variables_written.add(ir.lvalue)

lvalue = ir.lvalue
lvalue: Any = ir.lvalue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking but we should type ir.lvalue so this can be Optional[...]

@montyly montyly merged commit 346d3b6 into dev Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants