Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pylint does not seem to respect custom isort sections #3817

Closed
webknjaz opened this issue Sep 6, 2020 · 1 comment
Closed

pylint does not seem to respect custom isort sections #3817

webknjaz opened this issue Sep 6, 2020 · 1 comment
Labels
Help wanted 🙏 Outside help would be appreciated, good for new contributors High effort 🏋 Difficult solution or problem to solve Won't fix/not planned

Comments

@webknjaz
Copy link
Contributor

webknjaz commented Sep 6, 2020

Steps to reproduce

I have third-parties divided into several sections in isort configuration like this:

# .isort.cfg
default_section = THIRDPARTY
known_frameworks = towncrier, sphinx
sections = STDLIB, TESTING, FRAMEWORKS, THIRDPARTY, FIRSTPARTY, LOCALFOLDER

And when I run pylint on a module that has

from towncrier._settings import load_config_from_file


try:
    from towncrier.build import find_fragments  # noqa: WPS433
except ImportError:
    from towncrier import find_fragments  # noqa: WPS433, WPS440

from docutils import statemachine

it complains that docutils import should be before that first towncrier import.

It seems like pylint does not understand that there are custom sections and tries to shove everything into third-party.

Side note: does pylint understand # isort: split? I guess not.

Current behavior

src/sphinxcontrib/towncrier/__init__.py:29:0: C0411: third party import "from docutils import statemachine" should be placed before "from towncrier._settings import load_config_from_file" (wrong-import-order)

Expected behavior

There should be no conflict with isort, hence no error

pylint --version output

pylint 2.6.0
astroid 2.4.2
Python 3.7.1 (default, Jan 28 2019, 08:25:13) 
[GCC 7.3.0]
@Pierre-Sassoulas
Copy link
Member

pylint uses isort internally. If you're using isort with a proper configuration file yourself, you should probably disable wrong-import-order or other import messages in pylint, because pylint is bound to be lagging behind the features of isort, and because isort is already fixing import order automatically for you. See #3722, #3725 and in particular dbaty very detailed comment :

If you need something special, you need to disable the wrong-import-order check in pylint and run isort manually with a proper isort configuration file.

There is a discussion to propose default configuration for such cases in #3517 in order for this problem to not appear in the first place.

@Pierre-Sassoulas Pierre-Sassoulas added Help wanted 🙏 Outside help would be appreciated, good for new contributors High effort 🏋 Difficult solution or problem to solve Won't fix/not planned labels Sep 6, 2020
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Sep 6, 2020
Following pylint-dev#3817, documentation in the FAQ seems warranted.
Pierre-Sassoulas added a commit that referenced this issue Sep 7, 2020
Following #3817, documentation in the FAQ seems warranted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help wanted 🙏 Outside help would be appreciated, good for new contributors High effort 🏋 Difficult solution or problem to solve Won't fix/not planned
Projects
None yet
Development

No branches or pull requests

2 participants