Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Statically populate the `known_third_party` `isort` setting.

Project description

Build Status Azure DevOps coverage


Statically populate the known_third_party isort setting.

isort when run in isolation is not the best at determining what dependencies are third party.

aspy.refactor_imports is fortunately much better at this static analysis.

Why not just use reorder-python-imports? Well, it lacks a few features provided by isort (intentionally).

What this script does is seeds the known_third_party isort configuration automatically.


pip install seed-isort-config


seed-isort-config provides a single executable by the same name. Run it inside a git repository.

To specify custom application roots (such as with the src pattern) pass a colon-separated --application-directories parameter.

Files may be excluded from the process using the --exclude flag. This argument takes a python regular expression.

For a full list of arguments, see seed-isort-config --help.

getting started

seed-isort-config looks for an existing known_third_party setting in an isort configuration file. It will modify that if it exists, otherwise it'll create a brand new .isort.cfg file.

The easiest way to get started is to just add a blank known_third_party = section to your isort configuration (or known_third_party = [] if you are using pyproject.toml).

usage with pre-commit

This works especially well when integrated with pre-commit.

-   repo:
    rev: v1.9.0
    -   id: seed-isort-config
-   repo:
    rev: v4.3.18
    -   id: isort

In this configuration, seed-isort-config will adjust the known_third_party section of the isort configuration before isort runs!

Note that seed-isort-config doesn't act like a normal pre-commit linter so file exclusion must be configured through args: [--exclude=...] instead. For example: args: [--exclude=tests/.*\.py].

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
seed_isort_config-1.9.0-py2.py3-none-any.whl (5.4 kB) Copy SHA256 hash SHA256 Wheel py2.py3
seed_isort_config-1.9.0.tar.gz (4.9 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page