mal-lang / mal-toolbox

Apache License 2.0
4 stars 2 forks source link

Type hint the code #44

Closed nkakouros closed 3 months ago

nkakouros commented 3 months ago

The code has a mix of type hints being used and not being used. I propose that type hints are used everywhere to help document the code and discover bugs. Integrating mypy or another type checker should help. For example, the following function:

https://github.com/mal-lang/mal-toolbox/blob/9acd22f77028df556f00abbadf9b39bc516e5848/maltoolbox/language/specification.py#L55

expects a lang_dict but the code that uses it passes a LanguageGraph object (which is the proper thing to do):

https://github.com/mal-lang/mal-toolbox/blob/9acd22f77028df556f00abbadf9b39bc516e5848/maltoolbox/attackgraph/attackgraph.py#L143-L146

Using a type checker should have warned about this.

nkakouros commented 3 months ago

A realistic way to do this is to require every new PR to also annotate the code that it touches.

mrkickling commented 3 months ago

I will create a branch for it and try to implement type hinting in all of the function params and class variables where possible