{"id":647,"library":"isort","title":"isort","description":"isort is a Python utility and library designed to sort imports alphabetically, automatically separating them into sections by type. It provides a command-line utility, a Python library, and plugins for various editors to streamline import organization. Currently at version 8.0.1, isort maintains an active development pace with frequent major and minor releases, ensuring ongoing feature enhancements and bug fixes.","status":"active","version":"8.0.1","language":"python","source_language":"en","source_url":"https://github.com/PyCQA/isort","tags":["code formatter","linter","imports","development tool","static analysis","pre-commit"],"install":[{"cmd":"pip install isort","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The `isort` module is imported directly for programmatic access to functions like `isort.code()` or `isort.file()`.","symbol":"isort","correct":"import isort"}],"quickstart":{"code":"import isort\n\nunsorted_code = '''import os\nimport sys\nfrom third_party import lib\nfrom . import local_module'''\n\nsorted_code = isort.code(unsorted_code)\nprint(sorted_code)\n\n# Example of checking if code is sorted correctly\nis_sorted = isort.check_code(sorted_code)\nprint(f\"Is the code sorted correctly? {is_sorted}\")","lang":"python","description":"Demonstrates programmatic use of `isort` to sort a string of Python code and check if it's correctly sorted. The `isort.code()` function takes a string of code and returns the sorted version, while `isort.check_code()` verifies compliance."},"warnings":[{"fix":"Ensure your project's Python interpreter meets the minimum requirement for your `isort` version or pin `isort` to an older version compatible with your environment.","message":"Major versions of `isort` regularly drop support for older Python versions. Version 7.0.0 dropped support for Python 3.9, and version 6.0.0 dropped Python 3.8. Current versions (8.x) require Python >= 3.10.0.","severity":"breaking","affected_versions":"6.0.0, 7.0.0, 8.x"},{"fix":"Review your `isort` configuration and any custom scripts for usage of `setuptools` plugin or legacy finder flags. Update integrations to use `isort`'s official programmatic API or standard configuration methods. Refactor any code depending on `pkg_resources` for dependency discovery.","message":"isort v8.0.0 removed the `setuptools` plugin and deprecated old finders flags and legacy finder logic. Version 6.1.0 also dropped the use of the non-standard `pkg_resources` API. Integrations relying on these components will break.","severity":"breaking","affected_versions":"6.1.0, 8.0.0+"},{"fix":"Always configure `isort` with the `black` profile when using it alongside `Black`. This can be done via `isort --profile black` on the command line, or by adding `profile = \"black\"` under `[tool.isort]` in your `pyproject.toml` or `[isort]` in `.isort.cfg`.","message":"`isort` can conflict with other code formatters, notably `Black`, if not configured correctly. Both tools format imports but with different default styles.","severity":"gotcha","affected_versions":"All versions when used with `Black`"},{"fix":"Consolidate your configuration into a single, preferred file format like `pyproject.toml` (using `[tool.isort]`) or `.isort.cfg` (using `[settings]` or `[isort]`). Use `isort --verbose` to confirm which configuration file is being used for a given path.","message":"`isort` supports multiple configuration file formats (`pyproject.toml`, `.isort.cfg`, `setup.cfg`, `tox.ini`, `.editorconfig`), which can lead to confusion regarding precedence and correct syntax. For `pyproject.toml`, settings must be under `[tool.isort]`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be mindful when using `--atomic` in CI/CD environments, especially in projects with diverse Python version targets. It's often safer to rely on your test suite or linter to catch syntax errors after `isort` runs without `--atomic`.","message":"The `--atomic` flag, which prevents `isort` from applying changes that introduce syntax errors, is disabled by default. Using it can prevent `isort` from running against code written using a different Python version than the one `isort` is run with.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to `isort` 8.0.0 or newer if your project relies heavily on `__future__` imports and you encounter unexpected formatting behavior. Otherwise, carefully review `isort`'s output on such files.","message":"Prior to version 8.0.0, `isort` had an edge case where it could incorrectly handle `__future__` imports. While fixed in 8.0.0, older versions might exhibit subtle issues.","severity":"gotcha","affected_versions":"< 8.0.0"}],"env_vars":null,"last_verified":"2026-05-12T17:13:55.583Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Run `isort .` (or `isort <path/to/file.py>`) from your terminal to automatically sort and fix the imports. If using pre-commit, ensure `isort` is configured correctly.","cause":"The import statements in the file do not adhere to isort's configured sorting and formatting rules.","error":"Imports are incorrectly sorted."},{"fix":"Configure isort to use the 'black' profile. Add `profile = black` under the `[tool.isort]` section in your `pyproject.toml` or in a `.isort.cfg` file. Alternatively, run `isort . --profile black`.","cause":"isort's default sorting behavior is incompatible with black's formatting style, causing them to continuously undo each other's changes, especially when used together in pre-commit hooks.","error":"isort conflicts with black"},{"fix":"Install isort using pip: `pip install isort`. Ensure you install it in the correct Python environment (e.g., your project's virtual environment).","cause":"The 'isort' package is not installed in the Python environment currently being used by your terminal, editor, or automation tool (like a pre-commit hook).","error":"ModuleNotFoundError: No module named 'isort'"},{"fix":"Define the missing section in your isort configuration (e.g., in `pyproject.toml` or `.isort.cfg`) by adding it to the `sections` setting, and/or explicitly tell isort which modules belong to which section using `known_first_party`, `known_third_party`, `known_local_folder`, etc.","cause":"isort encountered an import statement for a module that it couldn't categorize into one of the defined sections (e.g., STDLIB, THIRDPARTY, FIRSTPARTY, LOCALFOLDER) in your configuration.","error":"Found <module> import while parsing, but <section> was not included in the `sections` setting of your config."},{"fix":"Ensure the path provided for `settings_path` (or the location where you expect isort to find its config) is correct and the file/directory actually exists. Use `isort --show-config` to debug how isort is discovering its configuration.","cause":"isort cannot find the configuration file or directory specified by the `settings_path` argument or implied by its discovery mechanism.","error":"isort was told to use the settings_path: <path> as the base directory or file that represents the starting point of config file discovery, but it does not exist."}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":"8.0.1","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.2,"mem_mb":8.1,"disk_size":"18.5M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.21,"mem_mb":8.1,"disk_size":"18.5M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":0.13,"mem_mb":8.1,"disk_size":"19M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.13,"mem_mb":8.1,"disk_size":"19M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.28,"mem_mb":8.9,"disk_size":"20.5M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.32,"mem_mb":8.9,"disk_size":"20.5M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.7,"import_time_s":0.26,"mem_mb":8.9,"disk_size":"21M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.24,"mem_mb":8.9,"disk_size":"21M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.25,"mem_mb":8.7,"disk_size":"12.3M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.27,"mem_mb":8.7,"disk_size":"12.3M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":0.29,"mem_mb":8.7,"disk_size":"13M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.26,"mem_mb":8.7,"disk_size":"13M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.23,"mem_mb":9,"disk_size":"12.1M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.25,"mem_mb":9,"disk_size":"12.0M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.6,"import_time_s":0.23,"mem_mb":9,"disk_size":"13M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.23,"mem_mb":9,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.17,"mem_mb":7.8,"disk_size":"18.4M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.19,"mem_mb":7.8,"disk_size":"18.4M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":2.1,"import_time_s":0.16,"mem_mb":7.8,"disk_size":"19M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.14,"mem_mb":7.8,"disk_size":"19M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}