Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: PyCQA/isort
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5.8.0
Choose a base ref
...
head repository: PyCQA/isort
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5.9.0
Choose a head ref

Commits on Mar 21, 2021

  1. Copy the full SHA
    faa8293 View commit details
  2. Update documentation

    timothycrosley committed Mar 21, 2021
    Copy the full SHA
    9665722 View commit details

Commits on Mar 22, 2021

  1. Fix bug regarding multiline docstrings

    If a multiline docstring has its closing quotes at the end of a line
    instead of on a separate line, isort fails to properly add imports using
    the `add_imports` config option; instead, it adds the desired imports
    into the middle of the docstring as illustrated below. While PEP 257
    (and other guides) advises that closing quotes appear on their own line,
    `isort` should not fail here.
    
    This change adds a check for closing docstrings at the end of a line in
    addition to the existing line start check for all comment indicators. A
    new section of the `test_add_imports` test explicitly tests multiline
    imports and this failure scenario specifically.
    
    ---
    
    A working example:
    
    ```python
    """My module.
    
    Provides example functionality.
    """
    
    print("hello, world")
    ```
    
    Running `isort --add-import "from __future__ import annotations"`
    produces the following as expected:
    
    ```python
    """My module.
    
    Provides example functionality.
    """
    
    from __future__ import annotations
    
    print("hello, world")
    ```
    
    ---
    
    The failure behavior described:
    
    ```python
    """My module.
    
    Provides example functionality."""
    
    print("hello, world")
    ```
    
    Running `isort --add-import "from __future__ import annotations"` as
    above produces the following result:
    
    ```python
    """My module.
    
    from __future__ import annotations
    
    Provides example functionality."""
    
    print("hello, world")
    ```
    
    Subsequent executions add more import lines into the docstring. This
    behavior occurs even if the file already has the desired imports.
    jonafato committed Mar 22, 2021
    Copy the full SHA
    2ccb497 View commit details

Commits on Mar 23, 2021

  1. Merge pull request #1695 from jonafato/fix-multiline-docstring-ending…

    …-on-line-add_import
    
    Fix bug regarding multiline docstrings
    timothycrosley authored Mar 23, 2021
    Copy the full SHA
    f5e0447 View commit details
  2. Copy the full SHA
    5d3aa87 View commit details
  3. Add - Jon Banafato (@jonafato)

     to contributors list
    timothycrosley committed Mar 23, 2021
    Copy the full SHA
    a07bdf3 View commit details

Commits on Mar 24, 2021

  1. Copy the full SHA
    dbd5a9e View commit details

Commits on Mar 25, 2021

  1. master -> main

    timothycrosley committed Mar 25, 2021
    Copy the full SHA
    bf715a4 View commit details
  2. develop -> main

    timothycrosley committed Mar 25, 2021
    Copy the full SHA
    f01a8e0 View commit details

Commits on Mar 31, 2021

  1. Copy the full SHA
    ead8c7c View commit details

Commits on Apr 1, 2021

  1. Merge pull request #1698 from legau/gitignorerelativefix

    Fix --gitignore flag not working on relative subdir files
    timothycrosley authored Apr 1, 2021
    Copy the full SHA
    48fe239 View commit details

Commits on Apr 2, 2021

  1. Copy the full SHA
    3896dae View commit details
  2. Copy the full SHA
    27606a9 View commit details
  3. Bump dependencies

    timothycrosley committed Apr 2, 2021
    Copy the full SHA
    8a9dd4c View commit details
  4. Copy the full SHA
    07cf921 View commit details

Commits on Apr 3, 2021

  1. Cruft update

    timothycrosley committed Apr 3, 2021
    Copy the full SHA
    92a23f4 View commit details
  2. Update deps

    timothycrosley committed Apr 3, 2021
    Copy the full SHA
    33e3623 View commit details
  3. Cruft update

    timothycrosley committed Apr 3, 2021
    Copy the full SHA
    f074239 View commit details

Commits on Apr 7, 2021

  1. Faster gitignore

    legau committed Apr 7, 2021
    Copy the full SHA
    927cf7e View commit details

Commits on Apr 12, 2021

  1. tests ok

    legau committed Apr 12, 2021
    Copy the full SHA
    4f32c44 View commit details

Commits on Apr 17, 2021

  1. Copy the full SHA
    9647353 View commit details
  2. Copy the full SHA
    5592f42 View commit details
  3. Small typo fix a vs an

    timothycrosley committed Apr 17, 2021
    Copy the full SHA
    fab05f2 View commit details
  4. Copy the full SHA
    008d0a6 View commit details
  5. Copy the full SHA
    a5ce76f View commit details
  6. Copy the full SHA
    bedc207 View commit details
  7. Copy the full SHA
    3dff805 View commit details
  8. Merge pull request #1706 from PyCQA/issue/1705/stream/skip-failure

    Issue/1705/stream/skip failure
    timothycrosley authored Apr 17, 2021
    Copy the full SHA
    99faae8 View commit details

Commits on Apr 20, 2021

  1. Copy the full SHA
    98b6019 View commit details
  2. Copy the full SHA
    098f714 View commit details

Commits on Apr 21, 2021

  1. Merge pull request #1710 from RuRo/fix-userwarnings

    Fix UserWarnings
    timothycrosley authored Apr 21, 2021
    Copy the full SHA
    be1e2d4 View commit details
  2. Add - ruro (@ruro)

    - Léni (@legau)
    to contributors list
    timothycrosley committed Apr 21, 2021
    Copy the full SHA
    d059d60 View commit details
  3. Copy the full SHA
    bde7e70 View commit details
  4. windows test

    legau committed Apr 21, 2021
    Copy the full SHA
    8701c58 View commit details

Commits on Apr 22, 2021

  1. Copy the full SHA
    90ab857 View commit details
  2. fix typo in stream API docs

    vapier committed Apr 22, 2021
    Copy the full SHA
    123c97e View commit details

Commits on Apr 23, 2021

  1. Merge pull request #1712 from vapier/main

    fix typo in stream API docs
    timothycrosley authored Apr 23, 2021
    Copy the full SHA
    768a319 View commit details
  2. Copy the full SHA
    c617ddc View commit details
  3. Copy the full SHA
    af97f07 View commit details

Commits on Apr 27, 2021

  1. Copy the full SHA
    2cd28e9 View commit details
  2. Copy the full SHA
    78aac6e View commit details
  3. Correct linting issue

    anirudnits committed Apr 27, 2021
    Copy the full SHA
    03ac140 View commit details

Commits on Apr 28, 2021

  1. Merge pull request #1716 from anirudnits/issue/1675/docs

    Issue/1675/docs
    timothycrosley authored Apr 28, 2021
    Copy the full SHA
    5e29571 View commit details

Commits on Apr 29, 2021

  1. Copy the full SHA
    337ca6b View commit details
  2. Add test for issue#1714

    anirudnits committed Apr 29, 2021
    Copy the full SHA
    2ca4261 View commit details

Commits on Apr 30, 2021

  1. Merge pull request #1717 from anirudnits/issue/1714

    Issue/1714 multiline tab bug
    timothycrosley authored Apr 30, 2021
    Copy the full SHA
    2402dae View commit details

Commits on May 1, 2021

  1. Copy the full SHA
    60d8e2e View commit details

Commits on May 2, 2021

  1. Copy the full SHA
    6efb3ac View commit details
  2. fix: Indirect import

    kenoss committed May 2, 2021
    Copy the full SHA
    8c46082 View commit details
  3. Copy the full SHA
    c4e2c02 View commit details
Showing with 2,184 additions and 768 deletions.
  1. +1 −0 .coveragerc
  2. +16 −15 .cruft.json
  3. +1 −1 .github/workflows/test.yml
  4. +19 −0 CHANGELOG.md
  5. +11 −11 README.md
  6. +9 −0 docs/configuration/action_comments.md
  7. +8 −4 docs/configuration/black_compatibility.md
  8. +1 −1 docs/configuration/config_files.md
  9. +2 −2 docs/configuration/custom_sections_and_ordering.md
  10. +1 −1 docs/configuration/multi_line_output_modes.md
  11. +99 −9 docs/configuration/options.md
  12. +1 −1 docs/configuration/pre-commit.md
  13. +17 −0 docs/configuration/profiles.md
  14. +11 −0 docs/contributing/4.-acknowledgements.md
  15. +8 −8 docs/major_releases/introducing_isort_5.md
  16. +1 −1 docs/quick_start/3.-api.md
  17. +5 −5 docs/upgrade_guides/5.0.0.md
  18. +6 −0 example_isort_sorting_plugin/example_isort_sorting_plugin.py
  19. +22 −0 example_isort_sorting_plugin/poetry.lock
  20. +19 −0 example_isort_sorting_plugin/pyproject.toml
  21. +3 −2 example_shared_isort_profile/poetry.lock
  22. +19 −0 isort/__init__.py
  23. +1 −1 isort/_future/__init__.py
  24. +1 −1 isort/_vendored/toml/encoder.py
  25. +1 −1 isort/_version.py
  26. +94 −39 isort/api.py
  27. +25 −6 isort/core.py
  28. +3 −3 isort/deprecated/finders.py
  29. +15 −3 isort/exceptions.py
  30. +1 −4 isort/files.py
  31. +16 −10 isort/format.py
  32. +0 −1 isort/hooks.py
  33. +1 −1 isort/identify.py
  34. +5 −5 isort/io.py
  35. +7 −3 isort/literal.py
  36. +41 −18 isort/main.py
  37. +27 −19 isort/output.py
  38. +21 −5 isort/parse.py
  39. +11 −0 isort/profiles.py
  40. +4 −4 isort/pylama_isort.py
  41. +104 −18 isort/settings.py
  42. +2 −2 isort/setuptools_commands.py
  43. +14 −2 isort/sorting.py
  44. +2 −3 isort/wrap.py
  45. +115 −62 isort/wrap_modes.py
  46. +613 −390 poetry.lock
  47. +33 −8 pyproject.toml
  48. +2 −2 scripts/clean.sh
  49. +3 −3 scripts/lint.sh
  50. +0 −14 setup.cfg
  51. +29 −0 tests/benchmark/test_api.py
  52. +2 −2 tests/integration/test_projects_using_isort.py
  53. +1 −0 tests/integration/test_setting_combinations.py
  54. +1 −1 tests/unit/profiles/test_black.py
  55. +1 −1 tests/unit/test_api.py
  56. +8 −8 tests/unit/test_deprecated_finders.py
  57. +34 −11 tests/unit/test_exceptions.py
  58. +15 −3 tests/unit/test_format.py
  59. +149 −15 tests/unit/test_isort.py
  60. +164 −34 tests/unit/test_main.py
  61. +180 −1 tests/unit/test_regressions.py
  62. +2 −2 tests/unit/test_settings.py
  63. +140 −1 tests/unit/test_ticketed_features.py
  64. +16 −0 tests/unit/utils.py
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[run]
branch = True
omit =
isort/_future/*
isort/_vendored/*
31 changes: 16 additions & 15 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"template": "https://github.com/timothycrosley/cookiecutter-python/",
"commit": "9be01014cde7ec06bd52415655d52ca30a9e9bcc",
"context": {
"cookiecutter": {
"full_name": "Timothy Crosley",
"email": "timothy.crosley@gmail.com",
"github_username": "pycqa",
"project_name": "isort",
"description": "A Python utility / library to sort Python imports.",
"version": "4.3.21",
"_template": "https://github.com/timothycrosley/cookiecutter-python/"
}
},
"directory": ""
}
"template": "https://github.com/timothycrosley/cookiecutter-python/",
"commit": "4f2a3601ad12239bf6cbeedba8ecf297690ab07f",
"context": {
"cookiecutter": {
"full_name": "Timothy Crosley",
"email": "timothy.crosley@gmail.com",
"github_username": "pycqa",
"project_name": "isort",
"description": "A Python utility / library to sort Python imports.",
"version": "4.3.21",
"_template": "https://github.com/timothycrosley/cookiecutter-python/"
}
},
"directory": "",
"checkout": null
}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -61,4 +61,4 @@ jobs:
poetry run coverage xml
- name: Report Coverage
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8'
uses: codecov/codecov-action@v1.0.6
uses: codecov/codecov-action@v1
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,25 @@ Changelog
NOTE: isort follows the [semver](https://semver.org/) versioning standard.
Find out more about isort's release policy [here](https://pycqa.github.io/isort/docs/major_releases/release_policy/).

### 5.9.0 June 21st 2021
- Improved CLI startup time.
- Implemented #1697: Provisional support for PEP 582: skip `__pypackages__` directories by default.
- Implemented #1705: More intuitive handling of isort:skip_file comments on streams.
- Implemented #1737: Support for using action comments to avoid adding imports to individual files.
- Implemented #1750: Ability to customize output format lines.
- Implemented #1732: Support for custom sort functions.
- Implemented #1722: Improved behavior for running isort in atomic mode over Cython source files.
- Fixed (https://github.com/PyCQA/isort/pull/1695): added imports being added to doc string in some cases.
- Fixed (https://github.com/PyCQA/isort/pull/1714): in rare cases line continuation combined with tabs can output invalid code.
- Fixed (https://github.com/PyCQA/isort/pull/1726): isort ignores reverse_sort when force_sort_within_sections is true.
- Fixed #1741: comments in hanging indent modes can lead to invalid code.
- Fixed #1744: repeat noqa comments dropped when * import and non * imports exist from the same package.
- Fixed #1721: repeat noqa comments on separate from lines with force-single-line set, sometimes get dropped.

#### Goal Zero (Tickets related to aspirational goal of achieving 0 regressions for remaining 5.0.0 lifespan):
- Implemented #1394: 100% branch coverage (in addition to line coverage) enforced.
- Implemented #1751: Strict typing enforcement (turned on mypy strict mode).

### 5.8.0 March 20th 2021
- Fixed #1631: as import comments can in some cases be duplicated.
- Fixed #1667: extra newline added with float-to-top, after skip, in some cases.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[![isort - isort your imports, so you don't have to.](https://raw.githubusercontent.com/pycqa/isort/develop/art/logo_large.png)](https://pycqa.github.io/isort/)
[![isort - isort your imports, so you don't have to.](https://raw.githubusercontent.com/pycqa/isort/main/art/logo_large.png)](https://pycqa.github.io/isort/)

------------------------------------------------------------------------

[![PyPI version](https://badge.fury.io/py/isort.svg)](https://badge.fury.io/py/isort)
[![Test Status](https://github.com/pycqa/isort/workflows/Test/badge.svg?branch=develop)](https://github.com/pycqa/isort/actions?query=workflow%3ATest)
[![Lint Status](https://github.com/pycqa/isort/workflows/Lint/badge.svg?branch=develop)](https://github.com/pycqa/isort/actions?query=workflow%3ALint)
[![Code coverage Status](https://codecov.io/gh/pycqa/isort/branch/develop/graph/badge.svg)](https://codecov.io/gh/pycqa/isort)
[![Code coverage Status](https://codecov.io/gh/pycqa/isort/branch/main/graph/badge.svg)](https://codecov.io/gh/pycqa/isort)
[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://pypi.org/project/isort/)
[![Join the chat at https://gitter.im/timothycrosley/isort](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/timothycrosley/isort?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Downloads](https://pepy.tech/badge/isort)](https://pepy.tech/project/isort)
@@ -26,11 +26,11 @@ editors](https://github.com/pycqa/isort/wiki/isort-Plugins) to
quickly sort all your imports. It requires Python 3.6+ to run but
supports formatting Python 2 code too.

- [Try isort now from your browser!](https://pycqa.github.io/isort/docs/quick_start/0.-try/)
- [Using black? See the isort and black compatiblity guide.](https://pycqa.github.io/isort/docs/configuration/black_compatibility/)
- [isort has official support for pre-commit!](https://pycqa.github.io/isort/docs/configuration/pre-commit/)
- [Try isort now from your browser!](https://pycqa.github.io/isort/docs/quick_start/0.-try.html)
- [Using black? See the isort and black compatibility guide.](https://pycqa.github.io/isort/docs/configuration/black_compatibility.html)
- [isort has official support for pre-commit!](https://pycqa.github.io/isort/docs/configuration/pre-commit.html)

![Example Usage](https://raw.github.com/pycqa/isort/develop/example.gif)
![Example Usage](https://raw.github.com/pycqa/isort/main/example.gif)

Before isort:

@@ -168,7 +168,7 @@ notified.

You will notice above the \"multi\_line\_output\" setting. This setting
defines how from imports wrap when they extend past the line\_length
limit and has [12 possible settings](https://pycqa.github.io/isort/docs/configuration/multi_line_output_modes/).
limit and has [12 possible settings](https://pycqa.github.io/isort/docs/configuration/multi_line_output_modes.html).

## Indentation

@@ -221,7 +221,7 @@ the `-e` option into the command line utility.
isort provides configuration options to change almost every aspect of how
imports are organized, ordered, or grouped together in sections.

[Click here](https://pycqa.github.io/isort/docs/configuration/custom_sections_and_ordering/) for an overview of all these options.
[Click here](https://pycqa.github.io/isort/docs/configuration/custom_sections_and_ordering.html) for an overview of all these options.

## Skip processing of imports (outside of configuration)

@@ -258,7 +258,7 @@ import a

isort can be ran or configured to add / remove imports automatically.

[See a complete guide here.](https://pycqa.github.io/isort/docs/configuration/add_or_remove_imports/)
[See a complete guide here.](https://pycqa.github.io/isort/docs/configuration/add_or_remove_imports.html)

## Using isort to verify code

@@ -289,14 +289,14 @@ project.
isort provides a hook function that can be integrated into your Git
pre-commit script to check Python code before committing.

[More info here.](https://pycqa.github.io/isort/docs/configuration/git_hook/)
[More info here.](https://pycqa.github.io/isort/docs/configuration/git_hook.html)

## Setuptools integration

Upon installation, isort enables a `setuptools` command that checks
Python files declared by your project.

[More info here.](https://pycqa.github.io/isort/docs/configuration/setuptools_integration/)
[More info here.](https://pycqa.github.io/isort/docs/configuration/setuptools_integration.html)

## Spread the word

9 changes: 9 additions & 0 deletions docs/configuration/action_comments.md
Original file line number Diff line number Diff line change
@@ -106,3 +106,12 @@ import a

!!! tip
isort split is exactly the same as placing an `# isort: on` immediately below an `# isort: off`


## isort: dont-add-imports

Tells isort to not automatically add imports to this file, even if --add-imports is set.

## isort: dont-add-import: [IMPORT_LINE]

Tells isort to not automatically add a particular import, even if --add-imports says to add it.
12 changes: 8 additions & 4 deletions docs/configuration/black_compatibility.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
![isort loves black](https://raw.githubusercontent.com/pycqa/isort/develop/art/isort_loves_black.png)
![isort loves black](https://raw.githubusercontent.com/pycqa/isort/main/art/isort_loves_black.png)

Compatibility with black
========

Compatibility with black is very important to the isort project and comes baked in starting with version 5.
All that's required to use isort alongside black is to set the isort profile to "black".

!!! tip
Beyond the profile, it is common to set [skip_gitignore](https://pycqa.github.io/isort/docs/configuration/options.html#skip-gitignore) (which is not enabled by default for isort as it requires git to be installed) and [line_length](https://pycqa.github.io/isort/docs/configuration/options.html#line-length) as it is common to deviate from black's default of 88.


## Using a config file (such as .isort.cfg)

For projects that officially use both isort and black, we recommend setting the black profile in a config file at the root of your project's repository.
This way independent to how users call isort (pre-commit, CLI, or editor integration) the black profile will automatically be applied.
That way it's independent of how users call isort (pre-commit, CLI, or editor integration) the black profile will automatically be applied.

For instance, your _pyproject.toml_ file would look something like

@@ -19,7 +23,7 @@ profile = "black"
multi_line_output = 3
```

Read More about supported [config files](https://pycqa.github.io/isort/docs/configuration/config_files/).
Read More about supported [config files](https://pycqa.github.io/isort/docs/configuration/config_files.html).

## CLI

@@ -47,7 +51,7 @@ after_success:

```

See [built-in profiles](https://pycqa.github.io/isort/docs/configuration/profiles/) for more profiles.
See [built-in profiles](https://pycqa.github.io/isort/docs/configuration/profiles.html) for more profiles.

## Integration with pre-commit

2 changes: 1 addition & 1 deletion docs/configuration/config_files.md
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ src_paths=isort,test

## Custom config files

Optionally, you can also create a config file with a custom name, or directly point isort to a config file that falls lower in the priority order, by using [--settings-file](https://pycqa.github.io/isort/docs/configuration/options/#settings-path).
Optionally, you can also create a config file with a custom name, or directly point isort to a config file that falls lower in the priority order, by using [--settings-file](https://pycqa.github.io/isort/docs/configuration/options.html#settings-path).
This can be useful, for instance, if you want to have one configuration for `.py` files and another for `.pyx` - while keeping the config files at the root of your repository.

!!! tip
4 changes: 2 additions & 2 deletions docs/configuration/custom_sections_and_ordering.md
Original file line number Diff line number Diff line change
@@ -115,15 +115,15 @@ import b
from a import a # This will always appear below because it is a from import.
```

However, if you prefer to keep strict alphabetical sorting you can set [force sort within sections](https://pycqa.github.io/isort/docs/configuration/options/#force-sort-within-sections) to true. Resulting in:
However, if you prefer to keep strict alphabetical sorting you can set [force sort within sections](https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections) to true. Resulting in:


```python
from a import a # This will now appear at top because a appears in the alphabet before b
import b
```

You can even tell isort to always place from imports on top, instead of the default of placing them on bottom, using [from first](https://pycqa.github.io/isort/docs/configuration/options/#from-first).
You can even tell isort to always place from imports on top, instead of the default of placing them on bottom, using [from first](https://pycqa.github.io/isort/docs/configuration/options.html#from-first).

```python
from b import b # If from first is set to True, all from imports will be placed before non-from imports.
2 changes: 1 addition & 1 deletion docs/configuration/multi_line_output_modes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Multi Line Output Modes

This [config option](https://pycqa.github.io/isort/docs/configuration/options/#multi-line-output) defines how from imports wrap when they extend past the line\_length
This [config option](https://pycqa.github.io/isort/docs/configuration/options.html#multi-line-output) defines how from imports wrap when they extend past the line\_length
limit and has 12 possible settings:

## 0 - Grid
Loading