Skip to main content

Reorder import statements in Python files

Project description

travis-badge codecov-badge readthedocs-badge pypi-badge

Python Fix Imports is a Python executable that can automatically reorganize the import statements of your Python script, by splitting single import statement importing several package into as many import statement as imported module (“one import, one line” principle), and sorting these import statements respecting position of group of them.

The main advantage for this method is to strictly restrict the forms of import statement and facilitate multiple code branch merges and rebase, while still allowing to specify a given order if it is the wish of the developer.

Please read the full rational online documenation for more information.

Sublime Text 3 users can use my Python Fix Imports plugin.

Example

Fix imports allows you to automatically turn:

from any_module import d, f
from other_module import z, x
from any_module import (b,
                        e)
from any_module import a, \
                       c

from a_module_that_should_be import at, after, all_others

into:

from any_module import a
from any_module import b
from any_module import c
from any_module import d
from any_module import e
from any_module import f
from other_module import x
from other_module import z

from a_module_that_should_be import after
from a_module_that_should_be import all_others
from a_module_that_should_be import at

Fiximport installation

$ pip install fiximports

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fiximports-0.1.14.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

fiximports-0.1.14-py2.py3-none-any.whl (17.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file fiximports-0.1.14.tar.gz.

File metadata

  • Download URL: fiximports-0.1.14.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for fiximports-0.1.14.tar.gz
Algorithm Hash digest
SHA256 96027442d278f851474156b8721cc71be8df42b9c0cfbf2a33a01ea7fe4de07d
MD5 cd5aa8142ea599312cc6f9d09e0aeeb3
BLAKE2b-256 e80a80a0e177b10227bd3dc6d5e3543d42025a41f0500b95e1e403244e5f8653

See more details on using hashes here.

File details

Details for the file fiximports-0.1.14-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for fiximports-0.1.14-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3072f27ce9f9def38554e4386ae1f88f6f4522c5a8ebd5af6b5aad7d23e91efd
MD5 cf8906f6ed83c9acb94496b17da9e04b
BLAKE2b-256 429eb688f6cdc980af701ca2dcf956df246e710070cb322bea9816f994ae53f7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page