Page MenuHomeSoftware Heritage

Reorder imports in the "standard" order
ClosedPublic

Authored by olasd on Sep 18 2018, 3:17 PM.

Details

Summary

Depends on D413

Test Plan

formatting fix

Diff Detail

Repository
rDLDPY PyPI loader
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

What's the standard import order?

So far, i've tried to keep the following order everywhere:

import <something>
...
<space>
from <something> import <fn>
...
<space>
import swh.<something>
import .<something>
...
<space>

from swh.<something> import <fn>
...
<space>
<space>
<code starts here>

In this diff, for example, i saw one inconsistency (client.py$12).

In D414#8039, @ardumont wrote:

What's the standard import order?

The import order that I try to use, and is consistent with what PEP8 advises to use is:

  • imports from the Python standard library
  • imports from third party modules
  • (if there's a lot of them) imports from the currently used "primary" third-party module (mostly used in Django context)
  • imports from other Software Heritage modules
  • imports from the current module

In each of these blocks, imports are sorted by module name, irrespective of whether we import the whole module or a single name, so that we can minimize diff conflicts.

This revision is now accepted and ready to land.Sep 18 2018, 6:27 PM
This revision was automatically updated to reflect the committed changes.