Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-flake8-isort for
openSUSE:Factory checked in at 2023-01-03 15:05:07
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-flake8-isort (Old)
and /work/SRC/openSUSE:Factory/.python-flake8-isort.new.1563 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-flake8-isort"
Tue Jan 3 15:05:07 2023 rev:5 rq:1046243 version:6.0.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-flake8-isort/python-flake8-isort.changes
2022-10-12 18:27:35.814073609 +0200
+++
/work/SRC/openSUSE:Factory/.python-flake8-isort.new.1563/python-flake8-isort.changes
2023-01-03 15:05:22.546513508 +0100
@@ -1,0 +2,19 @@
+Mon Jan 2 16:41:48 UTC 2023 - Dirk Müller <[email protected]>
+
+- update to 6.0.0:
+ * Drop isort 4.x support.
+ * Add support for flake8 6.0.0.
+ * Add `--isort-no-skip-gitignore` option to allow temporarily overriding
+ the set
+ value of isort's `skip_gitignore` option with `False`. This can cause
+ flake8-isort to run significantly faster at the cost of making flake8-isort's
+ behavior differ slightly from the behavior of `isort --check`. [gschaffner]
+ * Fix broken `add_options` method [casperdcl]
+ * Improve the config option is added and read back. [gforcada]
+ * Bump plugin version. [gforcada]
+ * Update dependencies. [gforcada]
+ * Revamp GitHub actions. [gforcada]
+ * Drop python 3.6, and add python 3.10. [gforcada]
+ * Use linters and formatters to keep code sane and beautiful. [gforcada]
+
+-------------------------------------------------------------------
Old:
----
flake8-isort-4.2.0.tar.gz
New:
----
flake8-isort-6.0.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-flake8-isort.spec ++++++
--- /var/tmp/diff_new_pack.wAi1eX/_old 2023-01-03 15:05:23.034516356 +0100
+++ /var/tmp/diff_new_pack.wAi1eX/_new 2023-01-03 15:05:23.042516403 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-flake8-isort
#
-# Copyright (c) 2022 SUSE LLC
+# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -19,14 +19,14 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%global skip_python2 1
Name: python-flake8-isort
-Version: 4.2.0
+Version: 6.0.0
Release: 0
Summary: Plugin integrating isort in flake8
License: GPL-2.0-only
Group: Development/Languages/Python
URL: https://github.com/gforcada/flake8-isort
Source:
https://files.pythonhosted.org/packages/source/f/flake8-isort/flake8-isort-%{version}.tar.gz
-BuildRequires: %{python_module flake8 >= 3.2.1}
+BuildRequires: %{python_module flake8}
BuildRequires: %{python_module isort >= 4.3.5}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
@@ -34,7 +34,7 @@
BuildRequires: %{python_module toml}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
-Requires: python-flake8 >= 3.2.1
+Requires: python-flake8
Requires: python-isort >= 4.3.5
Requires: python-testfixtures
BuildArch: noarch
@@ -54,7 +54,7 @@
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
-%pytest
+%pytest ./run_tests.py
%files %{python_files}
%doc README.rst CHANGES.rst
++++++ flake8-isort-4.2.0.tar.gz -> flake8-isort-6.0.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-isort-4.2.0/CHANGES.rst
new/flake8-isort-6.0.0/CHANGES.rst
--- old/flake8-isort-4.2.0/CHANGES.rst 2022-08-04 18:53:07.000000000 +0200
+++ new/flake8-isort-6.0.0/CHANGES.rst 2022-12-22 23:55:46.000000000 +0100
@@ -3,6 +3,48 @@
Changelog
=========
+6.0.0 (2022-12-22)
+------------------
+
+- Drop isort 4.x support.
+ [gforcada]
+
+- Add support for flake8 6.0.0.
+ [gforcada]
+
+- Add `--isort-no-skip-gitignore` option to allow temporarily overriding the
set
+ value of isort's `skip_gitignore` option with `False`. This can cause
+ flake8-isort to run significantly faster at the cost of making flake8-isort's
+ behavior differ slightly from the behavior of `isort --check`. [gschaffner]
+
+5.0.3 (2022-11-20)
+------------------
+
+- Fix broken `add_options` method, again. [casperdcl]
+
+5.0.2 (2022-11-19)
+------------------
+
+- Fix broken `add_options` method [casperdcl]
+
+5.0.1 (2022-11-18)
+------------------
+
+- Improve the config option is added and read back. [gforcada]
+
+- Bump plugin version. [gforcada]
+
+5.0.0 (2022-10-08)
+------------------
+
+- Update dependencies. [gforcada]
+
+- Revamp GitHub actions. [gforcada]
+
+- Drop python 3.6, and add python 3.10. [gforcada]
+
+- Use linters and formatters to keep code sane and beautiful. [gforcada]
+
4.2.0 (2022-08-04)
------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-isort-4.2.0/LICENSE.rst
new/flake8-isort-6.0.0/LICENSE.rst
--- old/flake8-isort-4.2.0/LICENSE.rst 2022-08-04 18:53:07.000000000 +0200
+++ new/flake8-isort-6.0.0/LICENSE.rst 1970-01-01 01:00:00.000000000 +0100
@@ -1,17 +0,0 @@
-.. -*- coding: utf-8 -*-
-
-flake8-isort Copyright 2015, Gil Forcada
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License version 2
-as published by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-MA 02111-1307 USA.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-isort-4.2.0/MANIFEST.in
new/flake8-isort-6.0.0/MANIFEST.in
--- old/flake8-isort-4.2.0/MANIFEST.in 2022-08-04 18:53:07.000000000 +0200
+++ new/flake8-isort-6.0.0/MANIFEST.in 1970-01-01 01:00:00.000000000 +0100
@@ -1,3 +0,0 @@
-include MANIFEST.in LICENSE *.rst *.py *.cfg *.ini
-exclude .installed.cfg .coveragerc *.pyc
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-isort-4.2.0/PKG-INFO
new/flake8-isort-6.0.0/PKG-INFO
--- old/flake8-isort-4.2.0/PKG-INFO 2022-08-04 18:53:07.775674800 +0200
+++ new/flake8-isort-6.0.0/PKG-INFO 2022-12-22 23:55:46.000000000 +0100
@@ -1,12 +1,12 @@
Metadata-Version: 2.1
Name: flake8-isort
-Version: 4.2.0
+Version: 6.0.0
Summary: flake8 plugin that integrates isort .
Home-page: https://github.com/gforcada/flake8-isort
Author: Gil Forcada
Author-email: [email protected]
License: GPL version 2
-Keywords: pep8 flake8 isort imports
+Keywords: pep8 flake8 python isort imports
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
@@ -17,25 +17,26 @@
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
-Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
+Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Quality Assurance
+Requires-Python: >=3.7
Provides-Extra: test
License-File: LICENSE
-License-File: LICENSE.rst
+
.. -*- coding: utf-8 -*-
-.. image::
https://github.com/gforcada/flake8-isort/actions/workflows/tests.yml/badge.svg?branch=master
- :target:
https://github.com/gforcada/flake8-isort/actions/workflows/tests.yml
+.. image::
https://github.com/gforcada/flake8-isort/actions/workflows/testing.yml/badge.svg?branch=master
+ :target:
https://github.com/gforcada/flake8-isort/actions/workflows/testing.yml
-.. image::
https://coveralls.io/repos/gforcada/flake8-isort/badge.svg?branch=master&service=github
+.. image::
https://coveralls.io/repos/gforcada/flake8-isort/badge.svg?branch=master
:target: https://coveralls.io/github/gforcada/flake8-isort?branch=master
Flake8 meet isort
@@ -61,6 +62,8 @@
-------------
If using the `select` `option from flake8`_ be sure to enable the `I` category
as well, see below for the specific error codes reported by `flake8-isort`.
+See ``flake8 --help`` for available flake8-isort options.
+
Error codes
-----------
+------------+-----------------------------------------------------------+
@@ -79,7 +82,7 @@
Requirements
------------
-- Python 2.7, 3.5, 3.6, pypy or pypy3
+- Python 3.7, 3.8, 3.9, 3.10, 3.11 and pypy3
- flake8
- isort
@@ -104,6 +107,48 @@
Changelog
=========
+6.0.0 (2022-12-22)
+------------------
+
+- Drop isort 4.x support.
+ [gforcada]
+
+- Add support for flake8 6.0.0.
+ [gforcada]
+
+- Add `--isort-no-skip-gitignore` option to allow temporarily overriding the
set
+ value of isort's `skip_gitignore` option with `False`. This can cause
+ flake8-isort to run significantly faster at the cost of making flake8-isort's
+ behavior differ slightly from the behavior of `isort --check`. [gschaffner]
+
+5.0.3 (2022-11-20)
+------------------
+
+- Fix broken `add_options` method, again. [casperdcl]
+
+5.0.2 (2022-11-19)
+------------------
+
+- Fix broken `add_options` method [casperdcl]
+
+5.0.1 (2022-11-18)
+------------------
+
+- Improve the config option is added and read back. [gforcada]
+
+- Bump plugin version. [gforcada]
+
+5.0.0 (2022-10-08)
+------------------
+
+- Update dependencies. [gforcada]
+
+- Revamp GitHub actions. [gforcada]
+
+- Drop python 3.6, and add python 3.10. [gforcada]
+
+- Use linters and formatters to keep code sane and beautiful. [gforcada]
+
4.2.0 (2022-08-04)
------------------
@@ -386,3 +431,4 @@
[gforcada]
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-isort-4.2.0/README.rst
new/flake8-isort-6.0.0/README.rst
--- old/flake8-isort-4.2.0/README.rst 2022-08-04 18:53:07.000000000 +0200
+++ new/flake8-isort-6.0.0/README.rst 2022-12-22 23:55:46.000000000 +0100
@@ -1,9 +1,9 @@
.. -*- coding: utf-8 -*-
-.. image::
https://github.com/gforcada/flake8-isort/actions/workflows/tests.yml/badge.svg?branch=master
- :target:
https://github.com/gforcada/flake8-isort/actions/workflows/tests.yml
+.. image::
https://github.com/gforcada/flake8-isort/actions/workflows/testing.yml/badge.svg?branch=master
+ :target:
https://github.com/gforcada/flake8-isort/actions/workflows/testing.yml
-.. image::
https://coveralls.io/repos/gforcada/flake8-isort/badge.svg?branch=master&service=github
+.. image::
https://coveralls.io/repos/gforcada/flake8-isort/badge.svg?branch=master
:target: https://coveralls.io/github/gforcada/flake8-isort?branch=master
Flake8 meet isort
@@ -29,6 +29,8 @@
-------------
If using the `select` `option from flake8`_ be sure to enable the `I` category
as well, see below for the specific error codes reported by `flake8-isort`.
+See ``flake8 --help`` for available flake8-isort options.
+
Error codes
-----------
+------------+-----------------------------------------------------------+
@@ -47,7 +49,7 @@
Requirements
------------
-- Python 2.7, 3.5, 3.6, pypy or pypy3
+- Python 3.7, 3.8, 3.9, 3.10, 3.11 and pypy3
- flake8
- isort
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-isort-4.2.0/flake8_isort.egg-info/PKG-INFO
new/flake8-isort-6.0.0/flake8_isort.egg-info/PKG-INFO
--- old/flake8-isort-4.2.0/flake8_isort.egg-info/PKG-INFO 2022-08-04
18:53:07.000000000 +0200
+++ new/flake8-isort-6.0.0/flake8_isort.egg-info/PKG-INFO 2022-12-22
23:55:46.000000000 +0100
@@ -1,12 +1,12 @@
Metadata-Version: 2.1
Name: flake8-isort
-Version: 4.2.0
+Version: 6.0.0
Summary: flake8 plugin that integrates isort .
Home-page: https://github.com/gforcada/flake8-isort
Author: Gil Forcada
Author-email: [email protected]
License: GPL version 2
-Keywords: pep8 flake8 isort imports
+Keywords: pep8 flake8 python isort imports
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
@@ -17,25 +17,26 @@
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
-Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
+Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Quality Assurance
+Requires-Python: >=3.7
Provides-Extra: test
License-File: LICENSE
-License-File: LICENSE.rst
+
.. -*- coding: utf-8 -*-
-.. image::
https://github.com/gforcada/flake8-isort/actions/workflows/tests.yml/badge.svg?branch=master
- :target:
https://github.com/gforcada/flake8-isort/actions/workflows/tests.yml
+.. image::
https://github.com/gforcada/flake8-isort/actions/workflows/testing.yml/badge.svg?branch=master
+ :target:
https://github.com/gforcada/flake8-isort/actions/workflows/testing.yml
-.. image::
https://coveralls.io/repos/gforcada/flake8-isort/badge.svg?branch=master&service=github
+.. image::
https://coveralls.io/repos/gforcada/flake8-isort/badge.svg?branch=master
:target: https://coveralls.io/github/gforcada/flake8-isort?branch=master
Flake8 meet isort
@@ -61,6 +62,8 @@
-------------
If using the `select` `option from flake8`_ be sure to enable the `I` category
as well, see below for the specific error codes reported by `flake8-isort`.
+See ``flake8 --help`` for available flake8-isort options.
+
Error codes
-----------
+------------+-----------------------------------------------------------+
@@ -79,7 +82,7 @@
Requirements
------------
-- Python 2.7, 3.5, 3.6, pypy or pypy3
+- Python 3.7, 3.8, 3.9, 3.10, 3.11 and pypy3
- flake8
- isort
@@ -104,6 +107,48 @@
Changelog
=========
+6.0.0 (2022-12-22)
+------------------
+
+- Drop isort 4.x support.
+ [gforcada]
+
+- Add support for flake8 6.0.0.
+ [gforcada]
+
+- Add `--isort-no-skip-gitignore` option to allow temporarily overriding the
set
+ value of isort's `skip_gitignore` option with `False`. This can cause
+ flake8-isort to run significantly faster at the cost of making flake8-isort's
+ behavior differ slightly from the behavior of `isort --check`. [gschaffner]
+
+5.0.3 (2022-11-20)
+------------------
+
+- Fix broken `add_options` method, again. [casperdcl]
+
+5.0.2 (2022-11-19)
+------------------
+
+- Fix broken `add_options` method [casperdcl]
+
+5.0.1 (2022-11-18)
+------------------
+
+- Improve the config option is added and read back. [gforcada]
+
+- Bump plugin version. [gforcada]
+
+5.0.0 (2022-10-08)
+------------------
+
+- Update dependencies. [gforcada]
+
+- Revamp GitHub actions. [gforcada]
+
+- Drop python 3.6, and add python 3.10. [gforcada]
+
+- Use linters and formatters to keep code sane and beautiful. [gforcada]
+
4.2.0 (2022-08-04)
------------------
@@ -386,3 +431,4 @@
[gforcada]
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-isort-4.2.0/flake8_isort.egg-info/SOURCES.txt
new/flake8-isort-6.0.0/flake8_isort.egg-info/SOURCES.txt
--- old/flake8-isort-4.2.0/flake8_isort.egg-info/SOURCES.txt 2022-08-04
18:53:07.000000000 +0200
+++ new/flake8-isort-6.0.0/flake8_isort.egg-info/SOURCES.txt 2022-12-22
23:55:46.000000000 +0100
@@ -1,12 +1,12 @@
CHANGES.rst
LICENSE
-LICENSE.rst
-MANIFEST.in
README.rst
flake8_isort.py
+requirements-lint.txt
+requirements.txt
+run_tests.py
setup.cfg
setup.py
-test_flake8_isort.py
flake8_isort.egg-info/PKG-INFO
flake8_isort.egg-info/SOURCES.txt
flake8_isort.egg-info/dependency_links.txt
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/flake8-isort-4.2.0/flake8_isort.egg-info/requires.txt
new/flake8-isort-6.0.0/flake8_isort.egg-info/requires.txt
--- old/flake8-isort-4.2.0/flake8_isort.egg-info/requires.txt 2022-08-04
18:53:07.000000000 +0200
+++ new/flake8-isort-6.0.0/flake8_isort.egg-info/requires.txt 2022-12-22
23:55:46.000000000 +0100
@@ -1,5 +1,5 @@
-flake8<6,>=3.2.1
-isort<6,>=4.3.5
+flake8
+isort<6,>=5.0.0
[test]
-pytest-cov
+pytest
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-isort-4.2.0/flake8_isort.py
new/flake8-isort-6.0.0/flake8_isort.py
--- old/flake8-isort-4.2.0/flake8_isort.py 2022-08-04 18:53:07.000000000
+0200
+++ new/flake8-isort-6.0.0/flake8_isort.py 2022-12-22 23:55:46.000000000
+0100
@@ -1,38 +1,31 @@
-# -*- coding: utf-8 -*-
-
+import warnings
from contextlib import redirect_stdout
-from difflib import Differ
from difflib import unified_diff
from io import StringIO
from pathlib import Path
import isort
-import warnings
+from pkg_resources import DistributionNotFound, get_distribution
-__version__ = '4.2.0'
+def _version():
+ try:
+ return get_distribution('flake8_isort').version
+ except DistributionNotFound:
+ return 'dev' # for local development if package is not installed yet
-class Flake8IsortBase(object):
+class Flake8IsortBase:
name = 'flake8_isort'
- version = __version__
- isort_unsorted = (
- 'I001 isort found an import in the wrong position'
- )
- no_config_msg = (
- 'I002 no configuration found (.isort.cfg or [isort] in configs)'
- )
- isort_blank_req = (
- 'I003 isort expected 1 blank line in imports, found 0'
- )
- isort_blank_unexp = (
- 'I004 isort found an unexpected blank line in imports'
- )
- isort_add_unexp = (
- 'I005 isort found an unexpected missing import'
- )
+ version = _version()
+ isort_unsorted = 'I001 isort found an import in the wrong position'
+ no_config_msg = 'I002 no configuration found (.isort.cfg or [isort] in
configs)'
+ isort_blank_req = 'I003 isort expected 1 blank line in imports, found 0'
+ isort_blank_unexp = 'I004 isort found an unexpected blank line in imports'
+ isort_add_unexp = 'I005 isort found an unexpected missing import'
show_traceback = False
+ no_skip_gitignore = False
stdin_display_name = None
search_current = True
@@ -40,144 +33,31 @@
self.filename = filename
self.lines = lines
- @classmethod
- def add_options(cls, parser):
- parser.add_option(
+ @staticmethod
+ def add_options(option_manager):
+ option_manager.add_option(
'--isort-show-traceback',
action='store_true',
parse_from_config=True,
- help='Show full traceback with diff from isort'
+ help='Show full traceback with diff from isort',
+ )
+ option_manager.add_option(
+ '--isort-no-skip-gitignore',
+ action='store_true',
+ parse_from_config=True,
+ help=(
+ "Temporarily override the set value of isort's
`skip_gitignore` option "
+ 'with `False`. This can cause flake8-isort to run
significantly faster '
+ "at the cost of making flake8-isort's behavior differ slightly
from "
+ 'the behavior of `isort --check`.'
+ ),
)
@classmethod
- def parse_options(cls, options):
+ def parse_options(cls, option_manager, options, args):
cls.stdin_display_name = options.stdin_display_name
cls.show_traceback = options.isort_show_traceback
-
-
-class Flake8Isort4(Flake8IsortBase):
- """class for isort <5"""
-
- def run(self):
- if self.filename is not self.stdin_display_name:
- file_path = self.filename
- else:
- file_path = None
- buffer = StringIO()
- with redirect_stdout(buffer):
- sort_result = isort.SortImports(
- file_path=file_path,
- file_contents=''.join(self.lines),
- check=True,
- show_diff=True,
- )
- traceback = self._format_isort_output(buffer)
-
- for line_num, message in self.sortimports_linenum_msg(sort_result):
- if self.show_traceback:
- message += traceback
- yield line_num, 0, message, type(self)
-
- def sortimports_linenum_msg(self, sort_result):
- """Parses isort.SortImports for line number changes and message
-
- Uses a diff.Differ comparison of SortImport `in_lines`:`out_lines` to
- yield the line numbers of import lines that have been moved or blank
- lines added.
-
- Args:
- sort_imports (isort.SortImports): The isorts results object.
-
- Yields:
- tuple: A tuple of the specific isort line number and message.
- """
- if sort_result.skipped:
- return
-
- self._fixup_sortimports_wrapped(sort_result)
- self._fixup_sortimports_eof(sort_result)
-
- differ = Differ()
- diff = differ.compare(sort_result.in_lines, sort_result.out_lines)
-
- line_num = 0
- additions = {
- '+ {}'.format(add_import) for add_import in sort_result.add_imports
- }
- for line in diff:
- if line.startswith(' ', 0, 2):
- line_num += 1 # Ignore unchanged lines but increment line_num.
- elif line.startswith('- ', 0, 2):
- line_num += 1
- if line.strip() == '-':
- yield line_num, self.isort_blank_unexp
- else:
- yield line_num, self.isort_unsorted
- elif line.strip() == '+':
- # Include newline additions but do not increment line_num.
- yield line_num + 1, self.isort_blank_req
- elif line.strip() in additions:
- yield line_num + 1, self.isort_add_unexp
-
- def _format_isort_output(self, isort_buffer):
- filtering_out = ('+++', '---', '@@', 'ERROR:')
-
- valid_lines = ['']
- valid_lines += [
- line
- for line in isort_buffer.getvalue().splitlines()
- if line.strip().split(' ', 1)[0] not in filtering_out
- ]
-
- # Normalizing newlines:
- if len(valid_lines) > 1:
- valid_lines.insert(1, '')
- valid_lines.append('')
-
- return '\n'.join(valid_lines)
-
- @staticmethod
- def _fixup_sortimports_eof(sort_imports):
- """Ensure single end-of-file newline in `isort.SortImports.in_lines`
-
- isort fixes EOF blank lines but this change should be suppressed as
- Flake8 will also flag them.
-
- Args:
- sort_imports (isort.SortImports): The isorts results object.
-
- Returns:
- isort.SortImports: The modified isort results object.
- """
- to_remove = {''} | set(sort_imports.add_imports)
- for line in reversed(sort_imports.in_lines):
- if line.strip() in to_remove:
- # If single empty line in in_lines, do nothing.
- if len(sort_imports.in_lines) > 1:
- sort_imports.in_lines.pop()
- else:
- sort_imports.in_lines.append('')
- break
-
- @staticmethod
- def _fixup_sortimports_wrapped(sort_imports):
- """Split-up wrapped imports newlines in `SortImports.out_lines`
-
- isort combines wrapped lines into a single list entry string in
- `out_lines` whereas `in_lines` are separate strings so for diff
- comparison these need to be comparable.
-
- Args:
- sort_imports (isort.SortImports): The isorts results object.
-
- Returns:
- isort.SortImports: The modified isort results object.
- """
- for idx, line in enumerate(sort_imports.out_lines):
- if '\n' in line:
- for new_idx, new_line in enumerate(
- sort_imports.out_lines.pop(idx).splitlines()):
- sort_imports.out_lines.insert(idx + new_idx, new_line)
+ cls.no_skip_gitignore = options.isort_no_skip_gitignore
class Flake8Isort5(Flake8IsortBase):
@@ -186,12 +66,16 @@
def run(self):
if self.filename is not self.stdin_display_name:
file_path = Path(self.filename)
- isort_config = isort.settings.Config(
- settings_path=file_path.parent)
+ settings_path = file_path.parent
else:
file_path = None
+ settings_path = Path.cwd()
+ if self.no_skip_gitignore:
isort_config = isort.settings.Config(
- settings_path=Path.cwd())
+ settings_path=settings_path, skip_gitignore=False
+ )
+ else:
+ isort_config = isort.settings.Config(settings_path=settings_path)
input_string = ''.join(self.lines)
traceback = ''
isort_changed = False
@@ -204,19 +88,23 @@
input_stream=input_stream,
output_stream=output_stream,
config=isort_config,
- file_path=file_path)
+ file_path=file_path,
+ )
except isort.exceptions.FileSkipped:
pass
except isort.exceptions.ISortError as e:
warnings.warn(e)
if isort_changed:
outlines = output_stream.getvalue()
- diff_delta = "".join(unified_diff(
- input_string.splitlines(keepends=True),
- outlines.splitlines(keepends=True),
- fromfile="{}:before".format(self.filename),
- tofile="{}:after".format(self.filename)))
- traceback = (isort_stdout.getvalue() + "\n" + diff_delta)
+ diff_delta = ''.join(
+ unified_diff(
+ input_string.splitlines(keepends=True),
+ outlines.splitlines(keepends=True),
+ fromfile=f'{self.filename}:before',
+ tofile=f'{self.filename}:after',
+ )
+ )
+ traceback = f'{isort_stdout.getvalue()}\n{diff_delta}'
for line_num, message in self.isort_linenum_msg(diff_delta):
if self.show_traceback:
message += traceback
@@ -265,4 +153,4 @@
yield line_num, self.isort_add_unexp
-Flake8Isort = Flake8Isort5 if hasattr(isort, 'api') else Flake8Isort4
+Flake8Isort = Flake8Isort5
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-isort-4.2.0/requirements-lint.txt
new/flake8-isort-6.0.0/requirements-lint.txt
--- old/flake8-isort-4.2.0/requirements-lint.txt 1970-01-01
01:00:00.000000000 +0100
+++ new/flake8-isort-6.0.0/requirements-lint.txt 2022-12-22
23:55:46.000000000 +0100
@@ -0,0 +1,152 @@
+#
+# This file is autogenerated by pip-compile with python 3.7
+# To update, run:
+#
+# pip-compile requirements-lint.in
+#
+attrs==22.1.0
+ # via
+ # flake8-bugbear
+ # pytest
+bandit==1.7.4
+ # via -r requirements-lint.in
+black==22.10.0
+ # via -r requirements-lint.in
+certifi==2022.12.7
+ # via requests
+charset-normalizer==2.1.1
+ # via requests
+click==8.1.3
+ # via black
+codespell==2.2.2
+ # via -r requirements-lint.in
+coverage[toml]==6.5.0
+ # via
+ # coveralls
+ # pytest-cov
+coveralls==3.3.1
+ # via -r requirements-lint.in
+docopt==0.6.2
+ # via coveralls
+exceptiongroup==1.0.0
+ # via pytest
+flake8==5.0.4
+ # via
+ # flake8-bugbear
+ # flake8-comprehensions
+ # flake8-debugger
+ # flake8-deprecated
+ # flake8-isort
+ # flake8-pep3101
+ # flake8-print
+ # flake8-quotes
+flake8-blind-except==0.2.1
+ # via -r requirements-lint.in
+flake8-bugbear==22.10.27
+ # via -r requirements-lint.in
+flake8-comprehensions==3.10.0
+ # via -r requirements-lint.in
+flake8-debugger==4.1.2
+ # via -r requirements-lint.in
+flake8-deprecated==2.0.1
+ # via -r requirements-lint.in
+flake8-isort==5.0.0
+ # via -r requirements-lint.in
+flake8-pep3101==2.0.0
+ # via -r requirements-lint.in
+flake8-print==5.0.0
+ # via -r requirements-lint.in
+flake8-quotes==3.3.1
+ # via -r requirements-lint.in
+flake8-todo==0.7
+ # via -r requirements-lint.in
+gitdb==4.0.9
+ # via gitpython
+gitpython==3.1.29
+ # via bandit
+idna==3.4
+ # via requests
+importlib-metadata==4.2.0 ; python_version < "3.8"
+ # via
+ # -r requirements-lint.in
+ # click
+ # flake8
+ # flake8-comprehensions
+ # pluggy
+ # pytest
+ # stevedore
+iniconfig==1.1.1
+ # via pytest
+isort==5.10.1
+ # via
+ # -r requirements-lint.in
+ # flake8-isort
+mccabe==0.7.0
+ # via flake8
+mypy==0.982
+ # via -r requirements-lint.in
+mypy-extensions==0.4.3
+ # via
+ # black
+ # mypy
+packaging==21.3
+ # via pytest
+pathspec==0.10.1
+ # via black
+pbr==5.11.0
+ # via stevedore
+platformdirs==2.5.2
+ # via black
+pluggy==1.0.0
+ # via pytest
+pycodestyle==2.9.1
+ # via
+ # flake8
+ # flake8-debugger
+ # flake8-print
+ # flake8-todo
+pyflakes==2.5.0
+ # via flake8
+pyparsing==3.0.9
+ # via packaging
+pytest==7.2.0
+ # via
+ # -r requirements-lint.in
+ # pytest-cov
+pytest-cov==4.0.0
+ # via -r requirements-lint.in
+pyupgrade==3.1.0
+ # via -r requirements-lint.in
+pyyaml==6.0
+ # via bandit
+requests==2.28.1
+ # via coveralls
+smmap==5.0.0
+ # via gitdb
+stevedore==3.5.2
+ # via bandit
+tokenize-rt==5.0.0
+ # via pyupgrade
+tomli==2.0.1
+ # via
+ # black
+ # coverage
+ # mypy
+ # pytest
+typed-ast==1.5.4 ; python_version < "3.8"
+ # via
+ # -r requirements-lint.in
+ # black
+ # mypy
+typing-extensions==4.4.0
+ # via
+ # black
+ # gitpython
+ # importlib-metadata
+ # mypy
+urllib3==1.26.12
+ # via requests
+zipp==3.10.0 ; python_version < "3.8"
+ # via
+ # -r requirements-lint.in
+ # importlib-metadata
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-isort-4.2.0/requirements.txt
new/flake8-isort-6.0.0/requirements.txt
--- old/flake8-isort-4.2.0/requirements.txt 1970-01-01 01:00:00.000000000
+0100
+++ new/flake8-isort-6.0.0/requirements.txt 2022-12-22 23:55:46.000000000
+0100
@@ -0,0 +1,66 @@
+#
+# This file is autogenerated by pip-compile with python 3.7
+# To update, run:
+#
+# pip-compile requirements.in
+#
+attrs==22.1.0
+ # via pytest
+certifi==2022.12.7
+ # via requests
+charset-normalizer==2.1.1
+ # via requests
+coverage[toml]==6.5.0
+ # via
+ # coveralls
+ # pytest-cov
+coveralls==3.3.1
+ # via -r requirements.in
+docopt==0.6.2
+ # via coveralls
+exceptiongroup==1.0.0
+ # via pytest
+flake8==5.0.4
+ # via -r requirements.in
+idna==3.4
+ # via requests
+importlib-metadata==4.2.0 ; python_version < "3.8"
+ # via
+ # -r requirements.in
+ # flake8
+ # pluggy
+ # pytest
+iniconfig==1.1.1
+ # via pytest
+isort==5.10.1
+ # via -r requirements.in
+mccabe==0.7.0
+ # via flake8
+packaging==21.3
+ # via pytest
+pluggy==1.0.0
+ # via pytest
+pycodestyle==2.9.1
+ # via flake8
+pyflakes==2.5.0
+ # via flake8
+pyparsing==3.0.9
+ # via packaging
+pytest==7.2.0
+ # via
+ # -r requirements.in
+ # pytest-cov
+pytest-cov==4.0.0
+ # via -r requirements.in
+requests==2.28.1
+ # via coveralls
+tomli==2.0.1
+ # via
+ # coverage
+ # pytest
+typing-extensions==4.4.0
+ # via importlib-metadata
+urllib3==1.26.12
+ # via requests
+zipp==3.8.1
+ # via importlib-metadata
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-isort-4.2.0/run_tests.py
new/flake8-isort-6.0.0/run_tests.py
--- old/flake8-isort-4.2.0/run_tests.py 1970-01-01 01:00:00.000000000 +0100
+++ new/flake8-isort-6.0.0/run_tests.py 2022-12-22 23:55:46.000000000 +0100
@@ -0,0 +1,267 @@
+"""unit tests for flake8-isort"""
+
+import collections
+import os
+import textwrap
+import pytest
+
+from flake8_isort import Flake8Isort
+
+
+def write_python_file(tmpdir, content):
+ source = textwrap.dedent(content)
+ file_path = os.path.join(str(tmpdir), 'test.py')
+ with open(file_path, 'w') as python_file:
+ python_file.write(source)
+ return (file_path, source)
+
+
+def write_isort_cfg(tmpdir, content):
+ write_config_file(tmpdir, '.isort.cfg', 'settings', content)
+
+
+def write_setup_cfg(tmpdir, content):
+ write_config_file(tmpdir, 'setup.cfg', 'isort', content)
+
+
+def write_tox_ini(tmpdir, content):
+ write_config_file(tmpdir, 'tox.ini', 'isort', content)
+
+
+def write_pyproject_toml(tmpdir, content):
+ write_config_file(tmpdir, 'pyproject.toml', 'tool.isort', content)
+
+
+def write_config_file(tmpdir, filename, header, content):
+ source = f'[{header}]\n{textwrap.dedent(content)}'
+ file_path = os.path.join(str(tmpdir), filename)
+ with open(file_path, 'w') as config_file:
+ config_file.write(source)
+
+
+def check_isort(return_values, references):
+ """Sort the return by (line, errortype) and compare it to the reference"""
+ assert len(return_values) == len(references)
+ for return_value, reference in zip(
+ sorted(return_values, key=lambda x: (x[0], x[2])), references
+ ):
+ assert return_value[:2] == reference[:2]
+ assert return_value[2].startswith(reference[2])
+
+
+testcases = [
+ {
+ 'name': 'sorted_correctly_default',
+ 'code': """
+ import os
+ from sys import path
+ """,
+ 'reference': [],
+ },
+ {
+ 'name': 'sorted_correctly_alpha',
+ 'config': """
+ force_single_line=True
+ force_alphabetical_sort=True
+ """,
+ 'code': """
+ from sys import path
+
+ import os
+ """,
+ 'reference': [],
+ },
+ {
+ 'name': 'eof_blank_lines',
+ 'code': """
+ import os
+ from sys import path
+
+
+
+ """,
+ 'reference': [],
+ },
+ {
+ 'name': 'imports_requires_blank_line',
+ 'code': """
+ from __future__ import division
+ import threading
+ from sys import pid
+ """,
+ 'reference': [(3, 0, 'I003 ')],
+ },
+ {
+ 'name': 'isortcfg_skip_file',
+ 'config': 'skip=test.py',
+ 'code': 'skipped_file',
+ 'reference': [],
+ },
+ {'name': 'file_skipped_with_comment', 'code': '# isort:skip_file',
'reference': []},
+ {
+ 'name': 'imports_unexpected_blank_line',
+ 'code': """
+ from __future__ import division
+
+ import threading
+
+ from sys import pid
+ """,
+ 'reference': [(5, 0, 'I004 ')],
+ },
+ {
+ 'name': 'sorted_incorrectly_multiple',
+ 'code': """
+ from __future__ import division
+ import os
+ from sys import pid
+ import threading
+
+ import isort
+
+
+
+ def func(): ...
+ """,
+ 'reference': [(3, 0, 'I003 '), (5, 0, 'I001 '), (10, 0, 'I004 ')],
+ },
+ {
+ 'name': 'sorted_incorrectly',
+ 'config': 'force_single_line=True',
+ 'code': """
+ from sys import pid
+ import threading
+ """,
+ 'reference': [(3, 0, 'I001 ')],
+ },
+ {'name': 'empty_file', 'code': '\n\n', 'reference': []},
+ {
+ 'name': 'wrapped_imports',
+ 'config': 'wrap_length=65',
+ 'code': """
+ from deluge.common import (fdate, fpcnt, fpeer, fsize, fspeed,
+ ftime, get_path_size, is_infohash,
+ is_ip, is_magnet, is_url)
+ """,
+ 'reference': [],
+ },
+ {
+ 'name': 'force_single_line_imports',
+ 'config': """
+ force_alphabetical_sort=True
+ force_single_line=True
+ """,
+ 'code': """
+ from plone.app.testing import applyProfile
+ from plone.app.testing import FunctionalTesting
+ """,
+ 'reference': [],
+ },
+ {
+ 'name': 'missing_add_imports',
+ 'config': 'add_imports=from __future__ import unicode_literals',
+ 'code': 'import os\n',
+ 'reference': [(1, 0, 'I003'), (1, 0, 'I005')],
+ },
+]
+
+
[email protected]('mode', ['file', 'code_string'])
[email protected]('testcase', testcases, ids=[t['name'] for t in
testcases])
+def test_flake8_isort(tmpdir, testcase, mode):
+ """Test the code examples in files and directly from string"""
+ with tmpdir.as_cwd():
+ if 'config' in testcase:
+ write_isort_cfg(tmpdir, testcase['config'])
+ if mode == 'file':
+ (file_path, lines) = write_python_file(tmpdir, testcase['code'])
+ checker = Flake8Isort(None, file_path, lines)
+ elif mode == 'code_string':
+ source = textwrap.dedent(testcase['code'])
+ checker = Flake8Isort(None, None, source)
+ return_values = list(checker.run())
+ check_isort(return_values, testcase['reference'])
+
+
+def test_isortcfg_found(tmpdir):
+ source = """
+ from sys import pid
+ import threading
+ """
+ (file_path, lines) = write_python_file(tmpdir, source)
+ write_isort_cfg(tmpdir, 'force_single_line=True')
+ checker = Flake8Isort(None, file_path, lines)
+ checker.config_file = True
+ ret = list(checker.run())
+ check_isort(ret, [(3, 0, 'I001 ')])
+
+
+def test_isortcfg_not_found(tmpdir):
+ (file_path, lines) = write_python_file(tmpdir, 'from sys import pid, path')
+ checker = Flake8Isort(None, file_path, lines)
+ checker.search_current = False
+ checker.config_file = True
+ ret = list(checker.run())
+ check_isort(ret, [(1, 0, 'I001 ')])
+
+
+def test_isort_formatted_output(tmpdir):
+ source = """
+ from __future__ import division
+ import os
+ from sys import pid
+ """
+ options = collections.namedtuple(
+ 'Options',
+ [
+ 'no_isort_config',
+ 'isort_show_traceback',
+ 'stdin_display_name',
+ 'isort_no_skip_gitignore',
+ ],
+ )
+
+ (file_path, lines) = write_python_file(tmpdir, source)
+
+ diff = ' from __future__ import division\n+\n import os'
+
+ checker = Flake8Isort(None, file_path, lines)
+ checker.parse_options(None, options(None, True, 'stdin', None), None)
+ ret = list(checker.run())
+ assert len(ret) == 1
+ assert ret[0][0] == 3
+ assert ret[0][1] == 0
+ assert diff in ret[0][2]
+
+
[email protected](
+ 'method_to_write_config',
+ [write_isort_cfg, write_setup_cfg, write_tox_ini, write_pyproject_toml],
+)
+def test_if_config_file_is_used(tmpdir, method_to_write_config):
+ source = """
+ import os
+ from sys import path
+ """
+ (file_path, lines) = write_python_file(
+ tmpdir,
+ source,
+ )
+ method_to_write_config(tmpdir, 'lines_between_types=1')
+
+ checker = Flake8Isort(None, file_path, lines)
+ ret = list(checker.run())
+ check_isort(ret, [(3, 0, 'I003 ')])
+
+
+def test_flake8(tmpdir):
+ from flake8.main import cli
+ import sys
+
+ (file_path, lines) = write_python_file(tmpdir, 'from sys import pid, path')
+
+ sys.argv = sys.argv[:2]
+ try:
+ assert isinstance(cli.main(), int)
+ except SystemExit:
+ pass
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-isort-4.2.0/setup.cfg
new/flake8-isort-6.0.0/setup.cfg
--- old/flake8-isort-4.2.0/setup.cfg 2022-08-04 18:53:07.776674700 +0200
+++ new/flake8-isort-6.0.0/setup.cfg 2022-12-22 23:55:46.000000000 +0100
@@ -1,15 +1,12 @@
-[bdist_wheel]
-universal = 0
-
[zest.releaser]
create-wheel = yes
-python-file-with-version = flake8_isort.py
+
+[check-manifest]
+ignore =
+ .installed.cfg
[isort]
-force_alphabetical_sort = True
-force_single_line = True
-lines_after_imports = 2
-line_length = 200
+profile = black
[egg_info]
tag_build =
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-isort-4.2.0/setup.py
new/flake8-isort-6.0.0/setup.py
--- old/flake8-isort-4.2.0/setup.py 2022-08-04 18:53:07.000000000 +0200
+++ new/flake8-isort-6.0.0/setup.py 2022-12-22 23:55:46.000000000 +0100
@@ -1,31 +1,26 @@
-# -*- coding: utf-8 -*-
from setuptools import setup
-import re
+short_description = 'flake8 plugin that integrates isort .'
-def get_version(file="flake8_isort.py"):
- with open(file) as f:
- for line in f:
- m = re.match(r"^__version__ = '(?P<version>.*?)'$", line)
- if m:
- return m.group('version')
+def read_file(filename):
+ with open(filename) as file_obj:
+ file_contents = file_obj.read()
+ return file_contents
-short_description = 'flake8 plugin that integrates isort .'
-
-long_description = '{0}\n{1}'.format(
- open('README.rst').read(),
- open('CHANGES.rst').read(),
-)
+long_description = f"""
+{read_file('README.rst')}
+{read_file('CHANGES.rst')}
+"""
setup(
name='flake8-isort',
- version=get_version(),
+ version='6.0.0',
description=short_description,
long_description=long_description,
- # Get more from http://pypi.python.org/pypi?%3Aaction=list_classifiers
+ # Get more from https://pypi.org/classifiers/
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
@@ -36,32 +31,40 @@
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
- 'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
+ 'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development',
'Topic :: Software Development :: Quality Assurance',
],
- keywords='pep8 flake8 isort imports',
+ python_requires='>=3.7',
+ keywords='pep8 flake8 python isort imports',
author='Gil Forcada',
author_email='[email protected]',
url='https://github.com/gforcada/flake8-isort',
license='GPL version 2',
- py_modules=['flake8_isort', ],
+ py_modules=[
+ 'flake8_isort',
+ ],
include_package_data=True,
+ test_suite='run_tests',
zip_safe=False,
install_requires=[
- 'flake8 >= 3.2.1, <6',
- 'isort >= 4.3.5, <6',
+ 'flake8',
+ 'isort >= 5.0.0, <6',
],
extras_require={
- 'test': ['pytest-cov'],
+ 'test': [
+ 'pytest',
+ ],
},
entry_points={
- 'flake8.extension': ['I00 = flake8_isort:Flake8Isort', ],
+ 'flake8.extension': [
+ 'I00 = flake8_isort:Flake8Isort',
+ ],
},
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-isort-4.2.0/test_flake8_isort.py
new/flake8-isort-6.0.0/test_flake8_isort.py
--- old/flake8-isort-4.2.0/test_flake8_isort.py 2022-08-04 18:53:07.000000000
+0200
+++ new/flake8-isort-6.0.0/test_flake8_isort.py 1970-01-01 01:00:00.000000000
+0100
@@ -1,216 +0,0 @@
-"""unit tests for flake8-isort
-
-the test should pass with both isort 4 and isort 5
-"""
-
-import collections
-import os
-import pytest
-
-from flake8_isort import Flake8Isort
-
-
-def write_python_file(tmpdir, content):
- file_path = os.path.join(str(tmpdir), 'test.py')
- with open(file_path, 'w') as python_file:
- python_file.write(content)
- return (file_path, content)
-
-
-def write_isort_cfg(tmpdir, content):
- content = '[settings]\n' + content
- write_config_file(tmpdir, '.isort.cfg', content)
-
-
-def write_setup_cfg(tmpdir, content):
- content = '[isort]\n' + content
- write_config_file(tmpdir, 'setup.cfg', content)
-
-
-def write_tox_ini(tmpdir, content):
- content = '[isort]\n' + content
- write_config_file(tmpdir, 'tox.ini', content)
-
-
-def write_pyproject_toml(tmpdir, content):
- content = '[tool.isort]\n' + content
- write_config_file(tmpdir, 'pyproject.toml', content)
-
-
-def write_config_file(tmpdir, filename, content):
- file_path = os.path.join(str(tmpdir), filename)
- with open(file_path, 'w') as config_file:
- config_file.write(content)
-
-
-def check_isort_ret(ret, ref):
- """Sort the return by (line, errortype) and compare it to the reference"""
- assert len(ret) == len(ref)
- for ret_i, ref_i in zip(sorted(ret, key=lambda x: (x[0], x[2])), ref):
- assert ret_i[:2] == ref_i[:2]
- assert ret_i[2].startswith(ref_i[2])
-
-
-testcases = [
- {'name': 'sorted_correctly_default',
- 'code': ('import os\n'
- 'from sys import path\n'),
- 'ref': []},
- {'name': 'sorted_correctly_alpha',
- 'config': 'force_single_line=True\n'
- 'force_alphabetical_sort=True\n',
- 'code': 'from sys import path\n'
- '\n'
- 'import os\n',
- 'ref': []},
- {'name': 'eof_blank_lines',
- 'code': 'import os\n'
- 'from sys import path\n'
- '\n'
- '\n'
- ' \n',
- 'ref': []},
- {'name': 'imports_requires_blank_line',
- 'code': 'from __future__ import division\n'
- 'import threading\n'
- 'from sys import pid\n',
- 'ref': [(2, 0, 'I003 ')]},
- {'name': 'isortcfg_skip_file',
- 'config': 'skip=test.py',
- 'code': 'skipped_file',
- 'ref': []},
- {'name': 'file_skipped_with_comment',
- 'code': '# isort:skip_file',
- 'ref': []},
- {'name': 'imports_unexpected_blank_line',
- 'code': 'from __future__ import division\n'
- '\n'
- 'import threading\n'
- '\n'
- 'from sys import pid\n',
- 'ref': [(4, 0, 'I004 ')]},
- {'name': 'sorted_incorrectly_multiple',
- 'code': 'from __future__ import division\n'
- 'import os\n'
- 'from sys import pid\n'
- 'import threading\n'
- '\n'
- 'import isort\n'
- '\n\n\n'
- 'def func()\n',
- 'ref': [(2, 0, 'I003 '),
- (4, 0, 'I001 '),
- (9, 0, 'I004 ')]},
- {'name': 'sorted_incorrectly',
- 'config': 'force_single_line=True',
- 'code': 'from sys import pid\n'
- 'import threading',
- 'ref': [(2, 0, 'I001 ')]},
- {'name': 'empty_file',
- 'code': '\n\n',
- 'ref': []},
- {'name': 'wrapped_imports',
- 'config': 'wrap_length=65',
- 'code': 'from deluge.common import (fdate, fpcnt, fpeer, fsize, fspeed,\n'
- ' ftime, get_path_size, is_infohash,\n'
- ' is_ip, is_magnet, is_url)\n',
- 'ref': []},
- {'name': 'force_single_line_imports',
- 'config': 'force_alphabetical_sort=True\n'
- 'force_single_line=True',
- 'code': 'from plone.app.testing import applyProfile\n'
- 'from plone.app.testing import FunctionalTesting\n',
- 'ref': []},
- {'name': 'missing_add_imports',
- 'config': 'add_imports=from __future__ import unicode_literals',
- 'code': 'import os\n',
- 'ref': [(1, 0, 'I003'),
- (1, 0, 'I005')]},
-]
-
-
[email protected]('mode', ["file", "code_string"])
[email protected]('testcase', testcases,
- ids=[t['name'] for t in testcases])
-def test_flake8_isort(tmpdir, testcase, mode):
- """Test the code examples in files and directly from string"""
- with tmpdir.as_cwd():
- if 'config' in testcase:
- write_isort_cfg(tmpdir, testcase['config'])
- if mode == "file":
- (file_path, lines) = write_python_file(tmpdir, testcase['code'])
- checker = Flake8Isort(None, file_path, lines)
- elif mode == "code_string":
- checker = Flake8Isort(None, None, testcase['code'])
- else:
- raise RuntimeError("invalid mode")
- ret = list(checker.run())
- check_isort_ret(ret, testcase['ref'])
-
-
-def test_isortcfg_found(tmpdir):
- (file_path, lines) = write_python_file(
- tmpdir,
- 'from sys import pid\n'
- 'import threading',
- )
- write_isort_cfg(tmpdir, 'force_single_line=True')
- checker = Flake8Isort(None, file_path, lines)
- checker.config_file = True
- ret = list(checker.run())
- check_isort_ret(ret, [(2, 0, 'I001 ')])
-
-
-def test_isortcfg_not_found(tmpdir):
- (file_path, lines) = write_python_file(
- tmpdir,
- 'from sys import pid, path'
- )
- checker = Flake8Isort(None, file_path, lines)
- checker.search_current = False
- checker.config_file = True
- ret = list(checker.run())
- check_isort_ret(ret, [(1, 0, 'I001 ')])
-
-
-def test_isort_formatted_output(tmpdir):
- options = collections.namedtuple(
- 'Options', [
- 'no_isort_config',
- 'isort_show_traceback',
- 'stdin_display_name'
- ]
- )
-
- (file_path, lines) = write_python_file(
- tmpdir,
- 'from __future__ import division\n'
- 'import os\n'
- 'from sys import pid\n',
- )
-
- diff = ' from __future__ import division\n+\n import os'
-
- checker = Flake8Isort(None, file_path, lines)
- checker.parse_options(options(None, True, 'stdin'))
- ret = list(checker.run())
- assert len(ret) == 1
- assert ret[0][0] == 2
- assert ret[0][1] == 0
- assert diff in ret[0][2]
-
-
[email protected](
- 'method_to_write_config',
- [write_isort_cfg, write_setup_cfg, write_tox_ini, write_pyproject_toml])
-def test_if_config_file_is_used(tmpdir, method_to_write_config):
- (file_path, lines) = write_python_file(
- tmpdir,
- 'import os\n'
- 'from sys import path\n',
- )
- method_to_write_config(tmpdir, 'lines_between_types=1')
-
- checker = Flake8Isort(None, file_path, lines)
- ret = list(checker.run())
- check_isort_ret(ret, [(2, 0, 'I003 ')])