I004 isort found an unexpected blank line in imports как исправить

flake8 plugin that integrates isort .

Use isort to check if the imports on your python files are sorted the way you expect.

Add an .isort.cfg to define how you want your imports sorted and run flake8 as you usually do.

See isort documentation for .isort.cfg available options.

Install

Install with pip:

$ pip install flake8-isort

Install with conda:

$ conda install -c conda-forge flake8-isort

Configuration

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

Error code

Description

I001

isort found an import in the wrong position

I002

no configuration found (.isort.cfg or [isort] in configs)

I003

isort expected 1 blank line in imports, found 0

I004

isort found an unexpected blank line in imports

I005

isort found an unexpected missing import

Requirements

  • Python 3.7, 3.8, 3.9, 3.10, 3.11 and pypy3

  • flake8

  • isort

Relation to flake8-import-order

As an alternative to this flake8 plugin, there’s flake8-import-order that could be worth checking out. In contrast to this plugin that defers all logic to isort, the flake8-import-order comes bundled with it’s own logic.

flake8-import-order comes with a few predefined set of styles meanwhile this plugin can be customized a bit more. But the biggest difference could lie in that flake8-isort actually has the corresponding sorting engine isort that can sort the import orders of your existing python files. Meanwhile flake8-import-order has no such corresponding tool, hence big existing projects who want to adopt either would get a more automized experience choosing flake8-isort.

License

GPL 2.0

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)

  • Fix compatibility with flake8 version 5. [nhymxu]

4.1.2.post0 (2022-07-25)

  • Release it as a wheel as well. [gforcada]

4.1.2 (2022-07-25)

  • The package no longer depends on testfixtures.

4.1.1 (2021-10-14)

  • Release py3 only wheels..

4.1.0 (2021-10-14)

  • Support flake8 4.x [g-as]

  • Switch from travis-ci to github actions. [g-as]

  • Drop python 2.7 support and 3.5 as well [g-as]

4.0.0 (2020-08-11)

  • Nothing changed yet.

4.0.0a0 (2020-08-07)

  • support isort >= 5 [bnavigator, pkolbus]

3.0.1 (2020-07-08)

  • Work around FailedToLoadPlugin exception by requiring isort 4.x. Likewise,
    pin the major version of all dependencies, to reduce risk of any future
    incompatibilities.
    [pkolbus]

3.0.0 (2020-04-15)

  • Let isort search the configuration, rather than flake8-isort try to find it.
    [jnns]

2.9.1 (2020-03-28)

  • Fix flake8 warning.
    [sobolevn]

2.9.0 (2020-03-16)

  • Add python3.8 support.
    [sobolevn]

2.8.0 (2019-12-05)

  • Look for isort configuration on .flake8 files as well.
    [JohnHBrock]

  • Document how to install flake8-isort on conda.
    [marcelotrevisani]

  • Look for isort configuration on pyproject.toml files as well.
    [sanjioh]

2.7.0 (2019-03-19)

  • Improve the README.
    [barbossa]

  • Fix isort output when pipes are used.
    [maerteijn]

2.6.0 (2018-12-01)

  • Use pytest to run tests.
    [gforcada]

  • New error code I005 isort foundan unexpected missing import.
    [charettes]

  • Add isort_show_traceback option to show verbose multi-line output
    from isort, turned off by default
    [sobolevn]

2.5 (2018-03-15)

  • Now requires isort >= 4.3.0.
    [jleclanche]

2.4 (2018-02-25)

  • Fix input handling with flake8’s –stdin-display-name, and simplify it.
    [blueyed]

  • Remove flake8-polyfill dependency. flake8 >= 3.2.1 is required already, and
    stdin is not read directly anymore.
    [blueyed]

2.3 (2017-12-22)

  • Fix typo.
    [paltman]

  • Add tox.ini and .editorconfig to config search.
    [cas–]

  • Make this plugin compatible with flake8 hook.
    As the hook copies the files out of tree,
    flake8-isort never finds the correct configuration.
    [jaysonsantos]

2.2.2 (2017-08-19)

  • Workaround for isort bug when skipping files.
    [danpalmer]

2.2.1 (2017-05-12)

  • Release as universal wheel.
    [gforcada]

2.2 (2017-03-26)

  • Support flake8 git hook.
    [sergio-alonso]

  • Support python 3.6.
    [gforcada]

  • Search configuration on home folder.
    [gforcada]

2.1.3 (2016-11-25)

  • Fix yet another corner case.
    [gforcada]

2.1.2 (2016-11-25)

  • Fix another corner case: ignored files.
    [cas–]

2.1.1 (2016-11-25)

  • Fix corner cases of isort: newlines and grouped imports.
    [cas–]

2.1.0 (2016-11-24)

  • Show the exact line and kind of error,
    rather than a generic message.
    [cas–]

2.0.3 (2016-11-22)

  • Update trove classifiers.
    [gforcada]

2.0.2 (2016-11-22)

  • Add flake8 classifier.
    [sigmavirus24]

  • Require flake8 3.2.1.
    flake8 series 3.1.x and 3.2.0 where not reporting flake8-isort errors.
    [gforcada]

  • Test on pypy and pypy3.
    [gforcada]

  • Fix tests and formatting.
    [gforcada]

2.0.1 (2016-09-22)

  • Fix standard input processing.
    [carljm]

2.0 (2016-09-14)

  • Refactor code to handle flake8 version 3.
    [danpalmer]

  • Require flake8 version 3.0.
    [gforcada]

1.3 (2016-06-20)

  • Make error messages clearer.
    [do3cc]

  • Use either pep8 or pycodestyle (new name for pep8).
    [Maxim Novikov]

  • Fix coveralls.
    [gforcada]

1.2 (2016-03-05)

  • Allow stdin processing, this way text editor can pass input to flake8.
    [mjacksonw]

1.1.1 (2016-02-16)

  • Silence isort messages.
    [gforcada]

  • Improve wording.
    [gforcada]

1.1 (2016-02-16)

  • Check for isort configuration on setup.cfg as well.
    [plumdog]

1.0 (2015-12-16)

  • Check for an isort configuration file.
    [gforcada]

0.2 (2015-09-14)

  • Fix entry point.
    [gforcada]

0.1.post0 (2015-09-13)

  • Release wheels as well.
    [gforcada]

0.1 (2015-09-13)

  • Initial release
    [gforcada]

  • Add all boilerplate files.
    [gforcada]

  • Create the flake8 plugin per se.
    [gforcada]

Recommend Projects

  • React photo

    React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo

    Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo

    Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo

    TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo

    Django

    The Web framework for perfectionists with deadlines.

  • Laravel photo

    Laravel

    A PHP framework for web artisans

  • D3 photo

    D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Visualization

    Some thing interesting about visualization, use data art

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo

    Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo

    Microsoft

    Open source projects and samples from Microsoft.

  • Google photo

    Google

    Google ❤️ Open Source for everyone.

  • Alibaba photo

    Alibaba

    Alibaba Open Source for everyone

  • D3 photo

    D3

    Data-Driven Documents codes.

  • Tencent photo

    Tencent

    China tencent open source team.

.. —— coding: utf-8 —

.. 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
:target: https://coveralls.io/github/gforcada/flake8-isort?branch=master

Use isort_ to check if the imports on your python files are sorted the way you expect.

Add an .isort.cfg to define how you want your imports sorted and run flake8 as you usually do.

See isort documentation_ for .isort.cfg available options.

Install

Install with pip::

$ pip install flake8-isort

Install with conda::

$ conda install -c conda-forge flake8-isort

Configuration

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

+————+————————————————————+
| Error code | Description |
+============+===========================================================+
| I001 | isort found an import in the wrong position |
+————+————————————————————+
| I002 | no configuration found (.isort.cfg or [isort] in configs) |
+————+————————————————————+
| I003 | isort expected 1 blank line in imports, found 0 |
+————+————————————————————+
| I004 | isort found an unexpected blank line in imports |
+————+————————————————————+
| I005 | isort found an unexpected missing import |
+————+————————————————————+

Requirements

  • Python 3.7, 3.8, 3.9, 3.10, 3.11 and pypy3
  • flake8
  • isort

Relation to flake8-import-order

As an alternative to this flake8 plugin, there’s flake8-import-order_ that could be worth checking out. In contrast to this plugin that defers all logic to isort, the flake8-import-order comes bundled with it’s own logic.

flake8-import-order comes with a few predefined set of styles meanwhile this plugin can be customized a bit more. But the biggest difference could lie in that flake8-isort actually has the corresponding sorting engine isort that can sort the import orders of your existing python files. Meanwhile flake8-import-order has no such corresponding tool, hence big existing projects who want to adopt either would get a more automized experience choosing flake8-isort.

License

GPL 2.0

.. isort: https://pypi.python.org/pypi/isort
..
isort documentation: https://pycqa.github.io/isort/docs/configuration/options.html
.. flake8-import-order: https://pypi.python.org/pypi/flake8-import-order
..
option from flake8: http://flake8.pycqa.org/en/latest/user/options.html#cmdoption-flake8-select

.. —— coding: utf-8 —

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)

  • Fix compatibility with flake8 version 5. [nhymxu]

4.1.2.post0 (2022-07-25)

  • Release it as a wheel as well. [gforcada]

4.1.2 (2022-07-25)

  • The package no longer depends on testfixtures.

4.1.1 (2021-10-14)

  • Release py3 only wheels..

4.1.0 (2021-10-14)

  • Support flake8 4.x [g-as]

  • Switch from travis-ci to github actions. [g-as]

  • Drop python 2.7 support and 3.5 as well [g-as]

4.0.0 (2020-08-11)

  • Nothing changed yet.

4.0.0a0 (2020-08-07)

  • support isort >= 5 [bnavigator, pkolbus]

3.0.1 (2020-07-08)

  • Work around FailedToLoadPlugin exception by requiring isort 4.x. Likewise,
    pin the major version of all dependencies, to reduce risk of any future
    incompatibilities.
    [pkolbus]

3.0.0 (2020-04-15)

  • Let isort search the configuration, rather than flake8-isort try to find it.
    [jnns]

2.9.1 (2020-03-28)

  • Fix flake8 warning.
    [sobolevn]

2.9.0 (2020-03-16)

  • Add python3.8 support.
    [sobolevn]

2.8.0 (2019-12-05)

  • Look for isort configuration on .flake8 files as well.
    [JohnHBrock]

  • Document how to install flake8-isort on conda.
    [marcelotrevisani]

  • Look for isort configuration on pyproject.toml files as well.
    [sanjioh]

2.7.0 (2019-03-19)

  • Improve the README.
    [barbossa]

  • Fix isort output when pipes are used.
    [maerteijn]

2.6.0 (2018-12-01)

  • Use pytest to run tests.
    [gforcada]

  • New error code I005 isort foundan unexpected missing import.
    [charettes]

  • Add isort_show_traceback option to show verbose multi-line output
    from isort, turned off by default
    [sobolevn]

2.5 (2018-03-15)

  • Now requires isort >= 4.3.0.
    [jleclanche]

2.4 (2018-02-25)

  • Fix input handling with flake8’s —stdin-display-name, and simplify it.
    [blueyed]

  • Remove flake8-polyfill dependency. flake8 >= 3.2.1 is required already, and
    stdin is not read directly anymore.
    [blueyed]

2.3 (2017-12-22)

  • Fix typo.
    [paltman]

  • Add tox.ini and .editorconfig to config search.
    [cas—]

  • Make this plugin compatible with flake8 hook.
    As the hook copies the files out of tree,
    flake8-isort never finds the correct configuration.
    [jaysonsantos]

2.2.2 (2017-08-19)

  • Workaround for isort bug when skipping files.
    [danpalmer]

2.2.1 (2017-05-12)

  • Release as universal wheel.
    [gforcada]

2.2 (2017-03-26)

  • Support flake8 git hook.
    [sergio-alonso]

  • Support python 3.6.
    [gforcada]

  • Search configuration on home folder.
    [gforcada]

2.1.3 (2016-11-25)

  • Fix yet another corner case.
    [gforcada]

2.1.2 (2016-11-25)

  • Fix another corner case: ignored files.
    [cas—]

2.1.1 (2016-11-25)

  • Fix corner cases of isort: newlines and grouped imports.
    [cas—]

2.1.0 (2016-11-24)

  • Show the exact line and kind of error,
    rather than a generic message.
    [cas—]

2.0.3 (2016-11-22)

  • Update trove classifiers.
    [gforcada]

2.0.2 (2016-11-22)

  • Add flake8 classifier.
    [sigmavirus24]

  • Require flake8 3.2.1.
    flake8 series 3.1.x and 3.2.0 where not reporting flake8-isort errors.
    [gforcada]

  • Test on pypy and pypy3.
    [gforcada]

  • Fix tests and formatting.
    [gforcada]

2.0.1 (2016-09-22)

  • Fix standard input processing.
    [carljm]

2.0 (2016-09-14)

  • Refactor code to handle flake8 version 3.
    [danpalmer]

  • Require flake8 version 3.0.
    [gforcada]

1.3 (2016-06-20)

  • Make error messages clearer.
    [do3cc]

  • Use either pep8 or pycodestyle (new name for pep8).
    [Maxim Novikov]

  • Fix coveralls.
    [gforcada]

1.2 (2016-03-05)

  • Allow stdin processing, this way text editor can pass input to flake8.
    [mjacksonw]

1.1.1 (2016-02-16)

  • Silence isort messages.
    [gforcada]

  • Improve wording.
    [gforcada]

1.1 (2016-02-16)

  • Check for isort configuration on setup.cfg as well.
    [plumdog]

1.0 (2015-12-16)

  • Check for an isort configuration file.
    [gforcada]

0.2 (2015-09-14)

  • Fix entry point.
    [gforcada]

0.1.post0 (2015-09-13)

  • Release wheels as well.
    [gforcada]

0.1 (2015-09-13)

  • Initial release
    [gforcada]

  • Add all boilerplate files.
    [gforcada]

  • Create the flake8 plugin per se.
    [gforcada]

Total Weekly Downloads (200,355)

GitHub Stars

141

Forks

87

Contributors

40


Direct Usage Popularity


The PyPI package flake8-isort receives a total of
200,355 downloads a week. As such, we scored
flake8-isort popularity level to be Popular.

Based on project statistics from the GitHub repository for the
PyPI package flake8-isort, we found that it has been
starred 141 times.

The download numbers shown are the average weekly downloads from the
last 6 weeks.

Security and license risk for latest version

Release Date
Dec 22, 2022

Direct Vulnerabilities
  • 0

    C

  • 0

    H

  • 0

    M

  • 0

    L

Indirect Vulnerabilities
  • 0

    C

  • 0

    H

  • 0

    M

  • 0

    L

All security vulnerabilities belong to
production dependencies of direct and indirect
packages.


License

GPL-2.0

Alert

Non-Permissive License

We noticed that this project uses a license which requires less
permissive conditions such as disclosing the source code, stating
changes or redistributing the source under the same license. It is
advised to further consult the license terms before use.


Security Policy

No

We found a way for you to contribute to the project! Looks like
flake8-isort is missing a security policy.


You can
connect your project’s repository to Snyk
to stay up to date on security alerts and receive automatic fix pull
requests.

Keep your project free of vulnerabilities with Snyk

Commit Frequency

Open Issues
7

Open PR
2

Last Release

2 months ago

Last Commit

2 months ago


Further analysis of the maintenance status of flake8-isort based on
released PyPI versions cadence, the repository activity,
and other data points determined that its maintenance is
Healthy.

We found that flake8-isort demonstrates a positive version release cadence
with at least one new version released in the past 3 months.

In the past month we didn’t find any pull request activity or change in
issues status has been detected for the GitHub repository.

Python Versions Compatibility

>=3.7


Age

7 years

Latest Release

2 months ago

Dependencies

2 Direct / 8 Total

Versions

41

Maintainers

1

Wheels

OS Independent

Hi,

I’m using flake8-isort plugin in my projects and since isort released the new version, v5.0.0, the plugin stopped working.
Here is the log with traceback:

Traceback (most recent call last):
  File "/app/.tox/lint/lib/python3.6/site-packages/flake8/plugins/manager.py", line 157, in load_plugin
    self._load()
  File "/app/.tox/lint/lib/python3.6/site-packages/flake8/plugins/manager.py", line 134, in _load
    self._plugin = self.entry_point.load()
  File "/app/.tox/lint/lib/python3.6/site-packages/importlib_metadata/__init__.py", line 105, in load
    module = import_module(match.group('module'))
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/app/.tox/lint/lib/python3.6/site-packages/flake8_isort.py", line 3, in <module>
    from isort import SortImports
ImportError: cannot import name 'SortImports'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/.tox/lint/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "/app/.tox/lint/lib/python3.6/site-packages/flake8/main/cli.py", line 22, in main
    app.run(argv)
  File "/app/.tox/lint/lib/python3.6/site-packages/flake8/main/application.py", line 360, in run
    self._run(argv)
  File "/app/.tox/lint/lib/python3.6/site-packages/flake8/main/application.py", line 347, in _run
    self.initialize(argv)
  File "/app/.tox/lint/lib/python3.6/site-packages/flake8/main/application.py", line 328, in initialize
    self.find_plugins(config_finder)
  File "/app/.tox/lint/lib/python3.6/site-packages/flake8/main/application.py", line 159, in find_plugins
    self.check_plugins.load_plugins()
  File "/app/.tox/lint/lib/python3.6/site-packages/flake8/plugins/manager.py", line 415, in load_plugins
    plugins = list(self.manager.map(load_plugin))
  File "/app/.tox/lint/lib/python3.6/site-packages/flake8/plugins/manager.py", line 302, in map
    yield func(self.plugins[name], *args, **kwargs)
  File "/app/.tox/lint/lib/python3.6/site-packages/flake8/plugins/manager.py", line 413, in load_plugin
    return plugin.load_plugin()
  File "/app/.tox/lint/lib/python3.6/site-packages/flake8/plugins/manager.py", line 164, in load_plugin
    raise failed_to_load
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "I00" due to cannot import name 'SortImports'.

Понравилась статья? Поделить с друзьями:
  • I would like to report a problem error details attached below
  • Icanclave ошибка е13
  • I went to the beach and swam with parents then we flew a kite ошибки
  • Ic2 error invalid value at line 191
  • Ibox ошибка е16 устройство не подключено