smart import for Python
Clone or download

README.rst

Smart import for Python

Latest version released on PyPi Supported Python versions Test coverage in develop

Automatically discovers & imports entities, used in current module.

No magic or monkey patching. Only standard Python functionality.

Before After
import math
from my_project import calc
# 100500 other imports

def my_code(argument, function=calc):
    return math.log(function(argument))
import smart_imports
smart_imports.all()
# no any other imports

def my_code(argument, function=calc):
    return math.log(function(argument))

Short summary

  • Get source code of module, from which smart_imports has called;
  • Parse it, find all not initialized variables;
  • Search imports, suitable for found variables;
  • Import them.

Process only modules, from which smart_imports called explicitly.

See also