Skip to main content

Statically populate the `known_third_party` `isort` setting.

Project description

Build Status Coverage Status

seed-isort-config

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.

install

pip install seed-isort-config

usage

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: https://github.com/asottile/seed-isort-config
    rev: v1.8.0
    hooks:
    -   id: seed-isort-config
-   repo: https://github.com/pre-commit/mirrors-isort
    rev: v4.3.4
    hooks:
    -   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.

Source Distribution

seed_isort_config-1.8.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

seed_isort_config-1.8.0-py2.py3-none-any.whl (5.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file seed_isort_config-1.8.0.tar.gz.

File metadata

  • Download URL: seed_isort_config-1.8.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for seed_isort_config-1.8.0.tar.gz
Algorithm Hash digest
SHA256 d1dfd72aa529a5d394c4dde960376ba69cb5f86d9c0194979c68cc81d200083b
MD5 55d535250b88d9f345f74fe7201b3caf
BLAKE2b-256 b6cf3112e61c5747861f33d2f8ddb391e2606307b556d8cfddc8a03849e80602

See more details on using hashes here.

Provenance

File details

Details for the file seed_isort_config-1.8.0-py2.py3-none-any.whl.

File metadata

  • Download URL: seed_isort_config-1.8.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for seed_isort_config-1.8.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 822a04634fab2cfa082a77c51c8af7768258a29e6b56e3daa3f357d81fa2d98d
MD5 0adef0e5ffe286229edc0b9a14e9de34
BLAKE2b-256 967848712a4e6522ff82e658b4d37f118c40a1ca838aaeff4ed81f27fcecd63c

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page