Sorting Python imports manually is quite cumbersome so we should use the isort tool to handle that process
and get consistent imports ordering across all swh modules.
As an example, D3972 adds a new pre-commit hook in swh-web to call isort when committing with a configuration
compatible with black formatter.
That task is here to define the isort configuration that will be used in all modules. Proposed one is the following:
[tool.isort] multi_line_output = 3 include_trailing_comma = true force_grid_wrap = 0 use_parentheses = true ensure_newline_before_comments = true line_length = 88 force_sort_within_sections = true
Basically it corresponds to the recommended settings when using black plus the addition of force_sort_within_sections = true
(which sorts from x import y before import z instead of grouping from imports together at the bottom)
More options are available here.