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: 4.3.20
Choose a base ref
...
head repository: PyCQA/isort
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4.3.21
Choose a head ref

Commits on Feb 16, 2019

  1. Make isort run with Python 3 only

    As isort is primarily used as a command-line tool, it is in a good
    position to move to Python 3 only. Other command-line-only tools have
    begun moving to Python 3. For example: black, mypy, pylint, and Sphinx.
    It will continue to support formatting Python 2 code, so users can still
    format their Python 2 projects.
    
    Allows for many code cleanups. By removing these workarounds, the
    project will be easier to maintain and reduce testing resources.
    
    Python 2 is scheduled to be EOL on January 1, 2020. The Python community
    is moving on.
    
    https://www.python.org/dev/peps/pep-0373/
    
    For reasons to drop Python 2 support, see:
    
    https://python3statement.org/
    
    For an overview of projects that have dropped Python 2 support entirely,
    see:
    
    https://hugovk.github.io/drop-python/2.7/
    
    Fixes #808
    jdufresne committed Feb 16, 2019
    Copy the full SHA
    3c54c0e View commit details

Commits on Feb 25, 2019

  1. Copy the full SHA
    c06aea7 View commit details
  2. Update settings.py

    Remove unused import
    timothycrosley authored Feb 25, 2019
    Copy the full SHA
    1059c2a View commit details
  3. Merge pull request #782 from jdufresne/py3

    Make isort run with Python 3 only
    timothycrosley authored Feb 25, 2019
    Copy the full SHA
    7845cc5 View commit details
  4. add mypy to CI

    mkurnikov committed Feb 25, 2019
    Copy the full SHA
    7a98fd0 View commit details
  5. update flake8 to 3.7.6

    mkurnikov committed Feb 25, 2019
    Copy the full SHA
    fd1b690 View commit details
  6. Copy the full SHA
    76ea9dc View commit details
  7. Copy the full SHA
    d083dfc View commit details
  8. Copy the full SHA
    f6c57c1 View commit details
  9. add type hints to isort/

    mkurnikov committed Feb 25, 2019
    Copy the full SHA
    52c86da View commit details
  10. lint

    mkurnikov committed Feb 25, 2019
    Copy the full SHA
    31af7aa View commit details
  11. Merge pull request #832 from mkurnikov/add-mypy

    Add typechecking with mypy to Travis
    timothycrosley authored Feb 25, 2019
    Copy the full SHA
    5c37d34 View commit details
  12. Merge pull request #833 from mkurnikov/update-flake8-to-3.7.6

    Update flake8 to 3.7.6
    timothycrosley authored Feb 25, 2019
    Copy the full SHA
    37d2544 View commit details
  13. Copy the full SHA
    e246c91 View commit details
  14. Merge pull request #836 from mkurnikov/add-type-annotations

    Add type annotations to source code
    timothycrosley authored Feb 25, 2019
    Copy the full SHA
    519efdc View commit details
  15. Copy the full SHA
    47a5e29 View commit details
  16. Remove merge artifact

    timothycrosley committed Feb 25, 2019
    Copy the full SHA
    554435b View commit details
  17. Update changelog

    timothycrosley committed Feb 25, 2019
    Copy the full SHA
    5b6fe52 View commit details
  18. Fix finder issue

    timothycrosley committed Feb 25, 2019
    1
    Copy the full SHA
    3ffe08f View commit details
  19. Copy the full SHA
    820b732 View commit details
  20. fix FinderManager __init__

    mkurnikov committed Feb 25, 2019
    Copy the full SHA
    b14d607 View commit details
  21. Copy the full SHA
    108713b View commit details
  22. Copy the full SHA
    b23bcda View commit details
  23. Copy the full SHA
    1b09c2a View commit details
  24. Copy the full SHA
    7537d07 View commit details
  25. move WrapModes to enum.Enum

    mkurnikov committed Feb 25, 2019
    Copy the full SHA
    8876a54 View commit details
  26. Merge pull request #838 from richardlthomas/fix-issue-826

    Made the LICENSE file executable for OpenSUSE packaging compatibility
    timothycrosley authored Feb 25, 2019
    Copy the full SHA
    a700748 View commit details
  27. Merge pull request #841 from mkurnikov/move-to-enums-for-wrap-modes

    Make WrapModes a Enum subclass
    timothycrosley authored Feb 25, 2019
    Copy the full SHA
    8b8deaf View commit details
  28. Copy the full SHA
    da544de View commit details
  29. Merge pull request #840 from viourr/black_comma_support

    Keep trailing comma even for a single from import. Issue 831
    timothycrosley authored Feb 25, 2019
    Copy the full SHA
    7b129bd View commit details
  30. Added NOQA to lines to be skipped - expect behavior is now that all i…

    …sort:skip and NOQA imports will be moved to bottom, unsorted
    richardlthomas committed Feb 25, 2019
    Copy the full SHA
    a4a2239 View commit details
  31. Modifying test

    richardlthomas committed Feb 25, 2019
    Copy the full SHA
    2d0f149 View commit details
  32. Merge pull request #843 from richardlthomas/fix-issue-826

    Added NOQA to lines to be skipped
    timothycrosley authored Feb 25, 2019
    Copy the full SHA
    dfb347b View commit details

Commits on Feb 26, 2019

  1. Copy the full SHA
    a7dd526 View commit details
  2. Merge pull request #845 from richardlthomas/fix-issue-828

    Changed distribution function to upload via Twine per issue #828
    timothycrosley authored Feb 26, 2019
    Copy the full SHA
    45dc590 View commit details
  3. Copy the full SHA
    da50aed View commit details
  4. Merge pull request #846 from nicolelodeon/patch-1

    Update ACKNOWLEDGEMENTS.md
    timothycrosley authored Feb 26, 2019
    Copy the full SHA
    f0badf1 View commit details
  5. Copy the full SHA
    1ba36cb View commit details
  6. Copy the full SHA
    3825fab View commit details
  7. Copy the full SHA
    9338202 View commit details
  8. Copy the full SHA
    115c1a8 View commit details

Commits on Feb 27, 2019

  1. Copy the full SHA
    6099642 View commit details

Commits on Feb 28, 2019

  1. Add LRU cache to RequirementsFinder._get_names

    This caches the result of the function for future invocations with the same
    input, which can massively speed up future invocations if they have the same
    input as previous calls.
    
    In the case of this function this happens a lot, and each invocation is quite
    expensive as the requirements file is parsed every time.
    
    This gives a quite significant performance boost. I've tried running `isort`
    with and without this patch on two different applications on Python 3.7.2 and
    one one application the run time drops from 12.67 seconds to 1.3 seconds and
    on the other it drops from 28.29 seconds to 2.1 seconds.
    
    This optimisation is similiar to the one which was done for the 4.3.x branch
    here: #856.
    Tenzer committed Feb 28, 2019
    Copy the full SHA
    6e8389b View commit details
  2. Switch RequiementsFinder._get_names back return an iterator

    This is in order to satisfy mypy as the return type should be the same as the
    super class.
    Tenzer committed Feb 28, 2019
    Copy the full SHA
    1e761b4 View commit details
  3. Copy the full SHA
    7efb0a8 View commit details
  4. allow named multi_line_import arguments

    Dan W Anderson committed Feb 28, 2019
    Copy the full SHA
    252ecbf View commit details
  5. from setting.cfg too

    Dan W Anderson committed Feb 28, 2019
    Copy the full SHA
    67dd219 View commit details
  6. maybe

    Dan W Anderson committed Feb 28, 2019
    Copy the full SHA
    086f792 View commit details

Commits on Mar 1, 2019

  1. Fix test_inconsistent_behavior_in_python_2_and_3_issue_479

    This also failed for me with "future" being installed.
    
    Not sure if it makes sense to keep it in the first place, since isort
    appears to require py34 now.
    
    Ref: #479 (comment)
    blueyed committed Mar 1, 2019
    Copy the full SHA
    c95d180 View commit details
  2. Fix no_lines_before with empty section

    This fixes "no_lines_before" to also be respected from previous empty
    sections.
    blueyed committed Mar 1, 2019
    Copy the full SHA
    93a0458 View commit details
Showing with 1,748 additions and 706 deletions.
  1. +12 −0 .coveragerc
  2. +7 −6 .env
  3. +5 −1 .gitignore
  4. +6 −0 .pre-commit-hooks.yaml
  5. +39 −11 .travis.yml
  6. +2 −1 ACKNOWLEDGEMENTS.md
  7. +73 −3 CHANGELOG.md
  8. 0 LICENSE
  9. +9 −6 README.rst
  10. +22 −3 appveyor.yml
  11. +10 −0 codecov.yml
  12. +2 −5 isort/__init__.py
  13. +0 −2 isort/__main__.py
  14. +207 −0 isort/compat.py
  15. +118 −89 isort/finders.py
  16. +56 −0 isort/format.py
  17. +4 −3 isort/hooks.py
  18. +290 −299 isort/isort.py
  19. +48 −29 isort/main.py
  20. +9 −5 isort/natural.py
  21. +0 −129 isort/pie_slice.py
  22. +4 −3 isort/pylama_isort.py
  23. +118 −46 isort/settings.py
  24. +15 −5 isort/utils.py
  25. +3 −0 mypy-requirements.txt
  26. +5 −1 requirements.txt
  27. +28 −0 scripts/before_install.sh
  28. +20 −4 setup.cfg
  29. +7 −13 setup.py
  30. +616 −37 test_isort.py
  31. +13 −5 tox.ini
12 changes: 12 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[run]
include =
isort/*
test_*.py
.tox/*/lib/python*/site-packages/isort/*
.tox\*\Lib\site-packages\isort\*
branch = 1

[paths]
source = isort/
.tox/*/lib/python*/site-packages/isort/
.tox\*\Lib\site-packages\isort\
13 changes: 7 additions & 6 deletions .env
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ fi
export PROJECT_NAME=$OPEN_PROJECT_NAME
export PROJECT_DIR="$PWD"

if [ ! -d "venv" ]; then
if [ ! -d ".venv" ]; then
if ! hash pyvenv 2>/dev/null; then
function pyvenv()
{
@@ -31,13 +31,13 @@ if [ ! -d "venv" ]; then
fi

echo "Making venv for $PROJECT_NAME"
pyvenv venv
. venv/bin/activate
pyvenv .venv
. .venv/bin/activate
python setup.py install
pip install -r requirements.txt
fi

. venv/bin/activate
. .venv/bin/activate

# Let's make sure this is a hubflow enabled repo
yes | git hf init >/dev/null 2>/dev/null
@@ -57,8 +57,9 @@ function _distribute()
{
(root
rm -rf build dist __pycache__ isort.egg-info
python setup.py sdist upload
python setup.py bdist_wheel upload)
python setup.py sdist
python setup.py bdist_wheel
twine upload --repository-url https://test.pypi.org/legacy/ dist/*)
}


6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -60,10 +60,14 @@ atlassian-ide-plugin.xml
*.swp
*.kate-swp
.ropeproject/
.vscode

# pip
pip-selfcheck.json

# Python3 Venv Files
venv/
.venv/
pyvenv.cfg

# mypy
.mypy_cache
6 changes: 6 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- id: isort
name: isort
entry: isort
require_serial: true
language: python
types: [python]
50 changes: 39 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,54 @@
dist: xenial
sudo: false
language: python
cache: pip
env:
- global:
- PYTEST_ADDOPTS=-vv
python: 3.7
matrix:
include:
- env: TOXENV=isort-check
- env: TOXENV=lint
- python: 2.7
env: TOXENV=py27
- python: 3.4
env: TOXENV=py34
- env: TOXENV=mypy
- python: 3.5
env: TOXENV=py35
env: TOXENV=py35-coverage
- python: 3.6
env: TOXENV=py36
env: TOXENV=py36-coverage
- python: 3.7
env: TOXENV=py37
- python: pypy2.7-6.0
env: TOXENV=pypy
env: TOXENV=py37-coverage
- python: pypy3.5-6.0
env: TOXENV=pypy3
- os: osx
language: generic
env: TOXENV=py36

before_install:
- "./scripts/before_install.sh"
install:
- pip install tox
- pip install tox
script:
- tox
after_success:
- |
# Report coverage for TOXENV=*-coverage.
if [[ "${TOXENV%-coverage}" != "$TOXENV" ]]; then
set -e
# Add last TOXENV to $PATH.
PATH="$PWD/.tox/${TOXENV##*,}/bin:$PATH"
coverage xml
coverage report -m
bash <(curl -s https://codecov.io/bash) -Z -X gcov -X coveragepy -X search -X xcode -X gcovout -X fix -f coverage.xml -n $TOXENV
set +e
fi
deploy:
provider: pypi
user: timothycrosley
distributions: sdist bdist_wheel
skip_existing: true
on:
tags: false
branch: master
condition: "$TOXENV = py37"
password:
secure: SSFcjBL3dhWvSbo21icmnHQFV7mXfv/eDzxrefHUDMk37MWrvtNKchH8zz7wjAsf2PH1VYL1zkEFwnzuzHgs2aFCK7HDUwAaDSIcvPmJg9Oty+o2WQw16m7UnUac9MIZGmBHQaZuUTw0VJpm3GuPSXtdFJwFq3Tk3TIyUipEwg8=
3 changes: 2 additions & 1 deletion ACKNOWLEDGEMENTS.md
Original file line number Diff line number Diff line change
@@ -78,7 +78,8 @@ Code Contributors
- John Chadwick (@jchv)
- Jon Dufresne (@jdufresne)
- Brian F. Baron (@briabar)

- Madison Caldwell (@madirey)
- Matt Yule-Bennett (@mattbennett)

Documenters
===================
76 changes: 73 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,79 @@
Changelog
=========
### 4.3.9 - Feburary 25, 2019 - hot fix release

### 5.0.0 UNRELEASED
**Breaking changes:**
- isort now requires Python 3.5+ to run but continues to support formatting
Python 2 code.
- isort deprecates official support for Python 3.4, removing modules only in this release from known_standard_library:
- user
Internal:
- isort now utilizes mypy and typing to filter out typing related issues before deployment

Planned:
- profile support for common project types (black, django, google, etc)

### 4.3.21 - June 25, 2019 - hot fix release
- Fixed issue #957 - Long aliases and use_parentheses generates invalid syntax

### 4.3.20 - May 14, 2019 - hot fix release
- Fixed issue #948 - Pipe redirection broken on Python2.7

### 4.3.19 - May 12, 2019 - hot fix release
- Fixed issue #942 - correctly handle pyi (Python Template Files) to match `black` output

### 4.3.18 - May 1, 2019 - hot fix release
- Fixed an issue with parsing files that contain unicode characters in Python 2
- Fixed issue #924 - Pulling in pip internals causes depreciation warning
- Fixed issue #938 - Providing a way to filter explicitly passed in files via configuration settings (`--filter-files`)
- Improved interoperability with toml configuration files

### 4.3.17 - April 7, 2019 - hot fix release
- Fixed issue #905 & #919: Import section headers behaving strangely

### 4.3.16 - March 23, 2019 - hot fix release
- Fixed issue #909 - skip and skip-glob are not enforced when using settings-path.
- Fixed issue #907 - appdirs optional requirement does not correctly specify version
- Fixed issue #902 - Too broad warning about missing toml package
- Fixed issue #778 - remove `user` from known standard library as it's no longer in any supported Python version.

### 4.3.15 - March 10, 2019 - hot fix release
- Fixed a regression with handling streaming input from pipes (Issue #895)
- Fixed handling of \x0c whitespace character (Issue #811)
- Improved CLI documentation

### 4.3.14 - March 9, 2019 - hot fix release
- Fixed a regression with */directory/*.py style patterns

### 4.3.13 - March 8, 2019 - hot fix release
- Fixed the inability to accurately determine import section when a mix of conda and virtual environments are used.
- Fixed some output being printed even when --quiet mode is enabled.
- Fixed issue #890 interoperability with PyCharm by allowing case sensitive non type grouped sorting.
- Fixed issue #889 under some circumstances isort will incorrectly add a new line at the beginning of a file.
- Fixed issue #885 many files not being skipped according to set skip settings.
- Fixed issue #842 streaming encoding improvements.

### 4.3.12 - March 6, 2019 - hot fix release
- Fix error caused when virtual environment not detected

### 4.3.11 - March 6, 2019 - hot fix release
- Fixed issue #876: confused by symlinks pointing to virtualenv gives FIRSTPARTY not THIRDPARTY
- Fixed issue #873: current version skips every file on travis
- Additional caching to reduce performance regression introduced in 4.3.5

### 4.3.10 - March 2, 2019 - hot fix release
- Fixed Windows incompatibilities (Issue #835)
- Fixed relative import sorting bug (Issue #417)
- Fixed "no_lines_before" to also be respected from previous empty sections.
- Fixed slow-down introduced by finders mechanism by adding a LRU cache (issue #848)
- Fixed issue #842 default encoding not-set in Python2
- Restored Windows automated testing
- Added Mac automated testing

### 4.3.9 - February 25, 2019 - hot fix release
- Fixed a bug that led to an incompatibility with black: #831

### 4.3.8 - Feburary 25, 2019 - hot fix release
### 4.3.8 - February 25, 2019 - hot fix release
- Fixed a bug that led to the recursive option not always been available from the command line.

### 4.3.7 - February 25, 2019 - hot fix release
@@ -34,7 +104,7 @@ New:

Fixes:
- Improved black compatibility.
- Isort will no detect files in the CWD as first-party.
- Isort will now detect files in the CWD as first-party.
- Fixed several cases where '-ns' or 'not_skip' was being incorrectly ignored.
- Fixed sorting of relative path imports ('.', '..', '...', etc).
- Fixed bugs caused by a failure to maintain order when loading iterables from config files.
Empty file modified LICENSE
100755 → 100644
Empty file.
15 changes: 9 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
@@ -11,10 +11,9 @@
:target: https://travis-ci.org/timothycrosley/isort
:alt: Build Status


.. image:: https://coveralls.io/repos/timothycrosley/isort/badge.svg?branch=release%2F2.6.0&service=github
:target: https://coveralls.io/github/timothycrosley/isort?branch=release%2F2.6.0
:alt: Coverage
.. image:: https://codecov.io/gh/timothycrosley/isort/branch/develop/graph/badge.svg
:target: https://codecov.io/gh/timothycrosley/isort
:alt: Code coverage Status

.. image:: https://img.shields.io/github/license/mashape/apistatus.svg
:target: https://pypi.org/project/hug/
@@ -24,12 +23,15 @@
:alt: Join the chat at https://gitter.im/timothycrosley/isort
:target: https://gitter.im/timothycrosley/isort?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge

.. image:: https://pepy.tech/badge/isort
:alt: Downloads
:target: https://pepy.tech/project/isort

isort your python imports for you so you don't have to.

isort is a Python utility / library to sort imports alphabetically, and automatically separated into sections.
It provides a command line utility, Python library and `plugins for various editors <https://github.com/timothycrosley/isort/wiki/isort-Plugins>`_ to quickly sort all your imports.
It currently cleanly supports Python 2.7 and 3.4+ without any dependencies.
It requires Python 3.5+ to run but supports formatting Python 2 code too.

.. image:: https://raw.github.com/timothycrosley/isort/develop/example.gif
:alt: Example Usage
@@ -329,7 +331,7 @@ past the line_length limit and has 6 possible settings:
In Mode 5 isort leaves a single extra space to maintain consistency of output when a comma is added at the end.
Mode 6 is the same - except that no extra space is maintained leading to the possibility of lines one character longer.
You can enforce a trailing comma by using this in conjunction with `-tc` or `trailing_comma: True`.
You can enforce a trailing comma by using this in conjunction with ``-tc`` or ``include_trailing_comma: True``.
.. code-block:: python
@@ -355,6 +357,7 @@ own line:
...
Note: to change the how constant indents appear - simply change the indent property with the following accepted formats:
* Number of spaces you would like. For example: 4 would cause standard 4 space indentation.
* Tab
* A verbatim string with quotes around it.
25 changes: 22 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
init:
- "SET PATH=C:\\Python27\\Scripts;%PATH%"
- "SET PATH=C:\\Python37\\Scripts;%PATH%"
- "SET PYTEST_ADDOPTS=-vv"
- "ECHO PATH=%PATH%"
- python --version

build: off

environment:
matrix:
- TOXENV: "isort-check"
- TOXENV: "lint"
- TOXENV: "mypy"
- TOXENV: "py35-coverage"
- TOXENV: "py36-coverage"
- TOXENV: "py37-coverage"

install:
- pip install tox

test_script:
- tox -e isort-check,py27,py34,py35,py36,py37
- tox

on_success:
# Add tox environment to PATH.
- "SET PATH=%CD%\\.tox\\%TOXENV%\\scripts;%PATH%"
- IF NOT "x%TOXENV:-coverage=%"=="x%TOXENV%" (
pip install codecov &&
coverage xml &&
coverage report -m &&
codecov --required -X gcov pycov search -f coverage.xml -n %TOXENV%-windows
)
10 changes: 10 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
coverage:
status:
project: yes
patch: yes
changes: yes

comment:
layout: "header, diff"
behavior: default
require_changes: no
7 changes: 2 additions & 5 deletions isort/__init__.py
Original file line number Diff line number Diff line change
@@ -19,10 +19,7 @@
OTHER DEALINGS IN THE SOFTWARE.
"""

from __future__ import absolute_import, division, print_function, unicode_literals

from . import settings # noqa: F401
from .isort import SortImports # noqa: F401
from .compat import SortImports # noqa: F401

__version__ = "4.3.9"
__version__ = "4.3.19"
2 changes: 0 additions & 2 deletions isort/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import

from isort.main import main

main()
Loading