Page MenuHomeSoftware Heritage

core/lister: Make the tasks take an explicit lister_args argument
ClosedPublic

Authored by ardumont on Jul 17 2018, 2:09 PM.

Details

Summary

Avoid eating *all* arbitrary arguments and passing them along to the
new_lister method.

Diff Detail

Repository
rDLS Listers
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

swh/lister/gitlab/tasks.py
37

carnage!

Remove spurious print statement

ardumont added inline comments.
swh/lister/gitlab/tasks.py
37

spurious print statement removed!

Please don't use mutable values (e.g. {}) as default argument, as they can get mutated and that gives surprising results.

Could you make lister_args a keyword-only argument (i.e. def run_task(self, *, lister_args=None):, and then be explicit about the argument name in the call sites? That way there's no chance the lister_args argument could be mistaken for something else.

In D392#7459, @olasd wrote:

Please don't use mutable values (e.g. {}) as default argument, as they can get mutated and that gives surprising results.

(FTAOD, it's not a problem in this specific instance, but it's a pattern we should generally avoid)

ardumont marked an inline comment as done.

Update according to latest points

This revision is now accepted and ready to land.Jul 17 2018, 4:05 PM
This revision was automatically updated to reflect the committed changes.