angr / angr-management

The official angr GUI.
BSD 2-Clause "Simplified" License
856 stars 108 forks source link

Automatically add a bunch of types #1226

Closed twizmwazin closed 3 months ago

twizmwazin commented 3 months ago

This branch uses the autotype project to add a lot of type annotations to angr management. The goal here is to improve type coverage, and to avoid spending lots of time annotating the "obvious" stuff, but still ensuring that mypy has enough information to usefully report errors. This approach used with this tool is fairly conservative, and while it will have some errors that will need to be manually corrected, overall it should be an improvement.

xxr0ss commented 3 months ago

Hi, I think None returns for class constructor __init__ are the "obvious" stuff that should be manually corrected

twizmwazin commented 3 months ago

What do you mean? In python __init__ always return None. See here

xxr0ss commented 3 months ago

Oh sorry for the ambiguous words XD

I mean maybe we don't need a -> None annotation for __init__, while autotype seems to add such annotation for every __init__

twizmwazin commented 3 months ago

I made that choice intentionally, autotype only adds what you tell it to. The goal is to type annotate everything in the end and run it through a static type checker in CI (mypy). While perhaps it could be inferred, I’ve seen enough errors in magic methods not returning the correct type that I think it’s justified.

xxr0ss commented 3 months ago

Understood, thanks for your explanation!