Skip to content
This repository was archived by the owner on Oct 10, 2020. It is now read-only.

Module import (re-)organization [v2]#221

Merged
rhatdan merged 3 commits intoprojectatomic:masterfrom
clebergnu:imports_v2
Nov 20, 2015
Merged

Module import (re-)organization [v2]#221
rhatdan merged 3 commits intoprojectatomic:masterfrom
clebergnu:imports_v2

Conversation

@clebergnu
Copy link
Contributor

This PR adds a pattern to the module imports used throughout the code, as suggested by PEPs 008 and 328. PEPs aside, the goal is to make it easier to tell the internal and external dependencies of each module.

Also move the urrlib3 warnings handling to the util module.


Change from v1 (PR #212):

  • Rebased to latest master

As per PEP8[1], there are basically three distinct groups of modules:

 1) standard library imports
 2) related third party imports
 3) local application/library specific imports

With that classification, we can give a general and consistent order
to the module imports.

The use of relative imports (the "dot" notation) for local modules
is indeed a matter of taste, but backed by PEP-0328[1] and already
used on Atomic/__init__.py.

[1] - https://www.python.org/dev/peps/pep-0008/#imports
[2] - https://www.python.org/dev/peps/pep-0328/

Signed-off-by: Cleber Rosa <crosa@redhat.com>
The same code is used in two different places so far. IMHO it
makes sense to have it as an utility function in a single location.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
One would think a user of this function would have initially
imported the requests library, but, in case that wasn't done,
let's import it just as it's done with the urllib3 module.

Also, check if the urllib3 module was already imported. If so,
skip the import statement.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
@clebergnu
Copy link
Contributor Author

Hi, I noticed that the last PRs merged also had similar check results (failures). Is there anything I can do here?

@rhatdan
Copy link
Member

rhatdan commented Nov 20, 2015

Can we get your check into the make pylint calls. so we can easily see the failure.

@rhatdan
Copy link
Member

rhatdan commented Nov 20, 2015

LGTM

rhatdan added a commit that referenced this pull request Nov 20, 2015
Module import (re-)organization [v2]
@rhatdan rhatdan merged commit 4c344f3 into projectatomic:master Nov 20, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants