A Python script for adding missing import statements in your Python code. The script utilizes ruff and ripgrep to identify missing imports and organizes them based on various criteria, including the number of errors, the total number of imports, and the length of the import line.
Usage:
from ruffrgimportfixer import fix_imports
fix_imports('some_pythonfile.py')
# or from the commandline ('some_pythonfile.py' as the only arg)
# or a simple bat file:
python -c "from ruffrgimportfixer import fix_imports;fix_imports(r'''%*''')"
Dependencies:
- ruff (https://github.com/astral-sh/ruff)
- ripgrep (https://github.com/BurntSushi/ripgrep)
# Both must be in sys.path