-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support both isort 4 and isort 5 #3725
Support both isort 4 and isort 5 #3725
Conversation
Pylint is not yet compatible with isort 5.x For more information please visit: * pylint-dev/pylint#3722 * pylint-dev/pylint#3725 Signed-off-by: Jürgen Löhel <juergen.loehel@inlyse.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup.
pylint/utils/utils.py
Outdated
if HAS_ISORT_5: | ||
self.isort5_config = isort.api.Config( | ||
known_third_party=known_third_party, | ||
known_standard_library=known_standard_library, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, you'll want to use extra_standard_library
here if you the behaviour to stay the same as the isort4 version: https://timothycrosley.github.io/isort/docs/upgrade_guides/5.0.0/#known_standard_library
This doesn't work yet. Have to wait for pylint-dev/pylint#3725 to land
It would be great if we could get this into the next release - a number of projects I am working on are blocked from isort5 adoption by pylint. Hopefully @timothycrosley 's point about |
Sorry, I did not have time to look at Timothy's comment, and will be away from a keyboard for a week. Anyone is welcome to amend the pull request in the meantime. :) As for the case in point:
The question is: do we want to keep the behaviour of isort 4? I confess I am not too familiar with the changes, but I'd say that we should keep in line with the default behavior of latest isort version (i.e. isort 5). This may generate new pylint warnings, but that's the cost of using the latest version of a dependency. And I think it's reasonable. |
I took a closer look and I think @dbaty is right that it should be okay. I may suggest however that an
Now, nothing but sre_parse would match as standard library.
It also in my mind depends on whether or not the pylint project sees |
please |
Bothered by the incompatible message, look forward for this MR be merged. |
FWIW I've been using this branch of Pylint together with isort 5.x for a month now, without problems. |
Arch Linux has just updated to isort 5.2.2, so Pylint is broken on Arch until there is a release with this fix. https://bugs.archlinux.org/task/67555 Edit: Arch is now shipping this patch |
Hi @timothycrosley, thanks for your insight and precious advice.
That's a very good point. And the target implementation in pylint (this very PR) depends on the answer to this. I will assume the following: most users who specify Considering that, I see two ways to deal with this change in pylint:
I am inclined to favor option 2 because:
This is an important decision that warrants the point of view of a real maintainer (and not only contributors like me). |
Thanks @Pierre-Sassoulas for the review. :) I addressed your comments and actually implemented what you and I see as the best option. I force-pushed to the branch to "ease" any other review (and so that the branch can be merged as is, hopefully). The message of the main commit ( Note for other reviewers: as another commenter noted above, this pull request has 3 separate commits. I suggest to review them one by one (through the "Commits" tab, not the "Files changed" tab). (Updated 2020-08-18 06:48 UTC: update to the link of the main commit since I push-force again to update the "What's New" page, as recommended by PIerre-Sassoulas. I also fixed the typo in the commit message, report by bnavigator.) |
5fff33f : - isort 5. Users that really the _new_ meaning of
+ isort 5. Users that really want the _new_ meaning of |
Thanks, the commit message is very clear. By the way I forgot, that you should also add a summary in https://github.com/PyCQA/pylint/blob/master/doc/whatsnew/2.6.rst, as this is a notable change and the third paragraph with I have no estimate of the time the next version will be released as I can't release myself. We probably want to release ASAP because of the number of persons that want this and also because of #3761 . (@AWhetter or @hippo91 you seem to have maintainer right on pypi, could you do something about it?) |
The API of isort 5 (released on 2020-07-04) is completely different. We must still support isort 4 because isort 5 dropped the compatibility with Python 3.5, which pylint still supports. Note about the `known-standard-library` option: it has been included in pylint for years. Until now, it was mapped with the option of the same name in isort. However, isort 5 has changed the meaning of this option (see https://timothycrosley.github.io/isort/docs/upgrade_guides/5.0.0/#known_standard_library). Most users of pylint want the meaning of the new `extra-standard-library` option. To avoid a breaking change in pylint, the `known-standard-library` pylint option is now mapped to `known-standard-library` in isort 4, and `extra-standard-library` in isort 5. Users that really want the _new_ meaning of `known-standard-library` in isort 4 must disable the `wrong-import-order` check in pylint and run isort manually, outside of pylint. Fix #3722.
isort is already a dependency of pylint, there is no need to mention it explicitly. Except for the "formatting" environment where we want to pin a specific version to avoid noise when a new version of isort is released that reports errors.
It's done (in 03053c0) and I updated the branch. I also fixed the typo (in this commit message) reported by @bnavigator. |
Thanks for the great work! Any idea when this will make it into a (patch) release? |
@dbaty and other contributors, thanks a lot for this good job! |
In the absence of @PCManticore, yes let's do a new release and get this out soon. @hippo91 how do you feel about doing your first release? The release process is documented here: https://github.com/PyCQA/pylint/blob/master/doc/release.txt |
@AWhetter ok lets do this. I will try the process tomorrow. |
Thank you both ! I did not know about this doc. If I understand correctly I could have released myself just by creating a tag. Sorry for pinging you unnecessarily, it won't happen next time :) |
@AWhetter @Pierre-Sassoulas
I don't know why this error occurs but i will investigate tomorrow, if you have some idea... |
hmm I don't know why that is. But the documentation that I linked to also includes steps for performing the release manually. You should be able to perform those steps despite whatever Travis tried to do. |
@hippo91, I'm afraid you have to be logged as yourself in order to relaunch your repository's job (for pylint it would be as PyCQA ?). The button for restart should be at the top right side check one of your own repository. Manual release seems to be the only way now (but should not be a problem with maintainer right). Do you have the right to give me the pypi right ? If such a case happen again I would not have to ping everyone during summer holiday :D |
I don't have those management permissions unfortunately. |
I finally succeed in making 2.6.0. |
Thank you! |
Pylint is not yet compatible with isort 5.x For more information please visit: * pylint-dev/pylint#3722 * pylint-dev/pylint#3725 Signed-off-by: Jürgen Löhel <juergen.loehel@inlyse.com>
Pylint is not yet compatible with isort 5.x For more information please visit: * pylint-dev/pylint#3722 * pylint-dev/pylint#3725 Signed-off-by: Jürgen Löhel <juergen.loehel@inlyse.com>
Pylint is not yet compatible with isort 5.x For more information please visit: * pylint-dev/pylint#3722 * pylint-dev/pylint#3725 Signed-off-by: Jürgen Löhel <juergen.loehel@inlyse.com>
See pylint-dev/pylint#3725 Additionally fixes the py3 intersphinx inventory url, which was throwing an error, and explicitly adds pylint to the dev requirements.
Description
isort 5 has been released a few days ago (2020-07-04) but its API is not compatible anymore with pylint. We could switch to isort 5 (and require
isort>=5,<6
) as I did in #3724, but isort 5 dropped the compatibility with Python 3.5, which pylint still supports. So a better option could be this pull request that supports both isort 4 and isort 5 via a small wrapper.All tests run with isort 5, except the Python 3.5 build that installs isort 4 (see bc0a82a#diff-b91f3d5bd63fcd17221b267e851608e8R61-R62). One of the test is manually skipped there, as it seems complex to have a different expected output depending on the installed version of isort (see bc0a82a#diff-37021361f4a7fe2764d8ff4537f22facR81-R84).
I switched the style of pylint's own import statements and its tests to isort 5 in a separate commit.
(Since pylint currently pins the version of isort to ">=4.2.5,<5", I don't think there is anything urgent, despite the comments in #3722...)
Type of Changes
Related Issue
Closes #3722
Steps