Make Action.job always be a valid job
Currently the .job
attribute is initialized to None in Action.__init__
and is set to a Job during the Pipeline.add_action. However, this
causes issues for type checking because you would need to check for
None every time the .job
attribute is accessed.
Instead require that Action.__init__ is called with a valid Job as the first argument. This requires a lot of changes everywhere in the code and unit tests but it is a more correct approach and will enable strict type checking in the future.
I also checked the code with mypy
.
While most of the code is not typed filtering by a specific error is still useful. For example, the [call-arg]
error will be raised when the Action.__init__ is called without job.
I've uploaded the mypy results before and after fixes:
An example error before fixed.
lava_dispatcher/actions/deploy/musca.py:102: error: Missing positional argument "job" in call to "UnmountMuscaMassStorageDevice" [call-arg]
After fixes there are no [call-arg]
errors: https://gitlab.com/lava/lava/-/snippets/3687313/raw/main/After%20fixes