{"id":3492,"library":"flake8-isort","title":"flake8-isort","description":"flake8-isort is a flake8 plugin that integrates the isort library to check the order of imports in Python files. It leverages isort's sorting logic and configuration (e.g., via .isort.cfg or pyproject.toml) to report import style violations as flake8 errors. Regularly maintained, its current version is 7.0.0, released in October 2025.","status":"active","version":"7.0.0","language":"en","source_language":"en","source_url":"https://github.com/gforcada/flake8-isort","tags":["flake8","isort","linter","code quality","imports","pep8","python"],"install":[{"cmd":"pip install flake8-isort flake8 isort","lang":"bash","label":"Install with pip"},{"cmd":"conda install -c conda-forge flake8-isort","lang":"bash","label":"Install with Conda"}],"dependencies":[{"reason":"Peer dependency, flake8-isort is a plugin for flake8.","package":"flake8"},{"reason":"Peer dependency, flake8-isort uses isort's core logic for import sorting.","package":"isort"},{"reason":"Required Python version.","package":"python","optional":false}],"imports":[],"quickstart":{"code":"# 1. Install dependencies (if not already installed)\n# pip install flake8-isort flake8 isort\n\n# 2. Create an example Python file (e.g., `my_module.py`)\n# This file has unsorted imports\n# print(\"Content of my_module.py:\")\n# print(\"\"\"\n# import os\n# import sys\n# from datetime import datetime\n# from collections import defaultdict\n# \"\"\")\n\n# 3. Create an isort configuration file (e.g., .isort.cfg or pyproject.toml)\n# Example .isort.cfg:\n# [isort]\n# profile = black\n# known_third_party = datetime,collections\n# \n# Or in pyproject.toml:\n# [tool.isort]\n# profile = \"black\"\n# known_third_party = [\"datetime\", \"collections\"]\n\n# 4. Run flake8 (flake8-isort will automatically integrate)\n# For demonstration, let's create a dummy file and config\nimport os\n\n# Create a dummy Python file\nwith open('temp_module.py', 'w') as f:\n    f.write('import os\\nfrom sys import argv\\nimport collections\\n\\ndef func(): pass\\n')\n\n# Create a dummy isort config file\nwith open('.isort.cfg', 'w') as f:\n    f.write('[isort]\\nprofile = black\\n')\n\n# To run flake8 with flake8-isort, you'd typically execute from your shell:\n# flake8 temp_module.py\n# The output would show I001 (isort found an import in the wrong position)\n\n# Clean up dummy files\nos.remove('temp_module.py')\nos.remove('.isort.cfg')","lang":"python","description":"To use flake8-isort, first install it along with flake8 and isort. Then, create an `isort` configuration file (e.g., `.isort.cfg` or within `pyproject.toml`) to define your preferred import sorting style. Finally, run `flake8` as you normally would; `flake8-isort` will automatically detect and report import order issues based on your `isort` configuration."},"warnings":[{"fix":"Upgrade Python to 3.10+ and install `isort` 7.0.0+. Refer to the `CHANGES.rst` for detailed compatibility matrix.","message":"Version 7.0.0 dropped support for Python 3.9 and requires `isort` 7.0.0. Ensure your Python and `isort` versions are compatible before upgrading.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Ensure `flake8` is at version 6.0.0+ and `isort` is at version 5.0.0+ (or 7.0.0+ for `flake8-isort` 7.0.0).","message":"Version 6.0.0 dropped support for `isort` 4.x and added support for `flake8` 6.0.0. Mismatched `flake8` or `isort` versions can lead to `FailedToLoadPlugin` errors.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Create a configuration file for `isort` in your project root or specify its location using `isort --settings-file`.","message":"`flake8-isort` requires an `isort` configuration file (e.g., `.isort.cfg` or a `[tool.isort]` section in `pyproject.toml`) to function correctly. Without it, it will report an `I002` error (\"no configuration found\").","severity":"gotcha","affected_versions":"All"},{"fix":"Choose one plugin based on your preference (e.g., `flake8-isort` if you also use `isort` to fix imports).","message":"Do not use `flake8-isort` simultaneously with `flake8-import-order`. These plugins offer similar functionalities for checking import order and can cause conflicts or redundant checks. `flake8-isort` defers all logic to `isort`.","severity":"gotcha","affected_versions":"All"},{"fix":"Add 'I' to your `flake8` `select` configuration or remove the `select` option to run all checks.","message":"If using `flake8`'s `select` option (to only run specific checks), ensure the 'I' error code category is included (e.g., `--select=E,W,F,I`) to see `flake8-isort`'s reported issues (I001-I005).","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}