-
Notifications
You must be signed in to change notification settings - Fork 148
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 isort5 #92
Support isort5 #92
Conversation
99dfe71
to
be08f43
Compare
3eb8410
to
bc0818c
Compare
22ce173
to
e531517
Compare
e531517
to
e502c24
Compare
Isort > 5 does not have the pyproject extra either. Just require toml directly for the tests
This let's pytest discover the file on its own.
Nice, but why keep compatibility with isort < 5? It's a lot of code! |
From a rolling distrubution package maintainer point of view: Hard sudden changes in requirements create unnecessary friction. The sudden switch from isort 4 to isort 5 API is what triggered this PR and others like pylint-dev/pylint#3725. Downstream packages apparently were not aware of the change and everything that did not declare This PR is about additional support. @gforcada can decide later on to drop isort 4. But I would strongly advise to introduce a |
Additionally, if you drop isort 4, you also have to drop Python < 3.6 |
isort 5.1.1 changed the code how to write the unified diff a bit. Now std.out is not always captured and unit tests fail. Investigating... |
The default value of So the new commit unwraps
|
😱 I never actually said anything! 🤦 sorry for that @bnavigator and all that have made comments and suggestions! 🙇 Great job!!! 💯 I did a first review some weeks ago, but I will do a second pass and make a release, even an alpha or beta one so whoever wants a release with isort 5 support at least does not have to roll their own releases or use git checkouts 👍 |
yield line_num, self.isort_add_unexp | ||
|
||
|
||
Flake8Isort = Flake8Isort5 if hasattr(isort, 'api') else Flake8Isort4 |
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.
🎉 💯
@bnavigator thanks a lot! 🙇 💯 |
Please give feedback with this release and I will make a final a few days/weeks later if no negative (and some positive) feedback is received 👍 |
|
I've been using this PR for a couple weeks and it's been working perfectly in my setup with |
using with |
Thanks for all the feedback, you can do a last update to bump flake8-isort to 4.0.0! 🎉 Again, thanks to all that contributed on bringing isort 5 compatibility! 🙇 ✨ |
Hi,
This PR adds support for isort >=5 while retaining the code for isort 4.
The new code parses the unified diff output produced by
isort.api.check_file
andisort.api.check_code_string
.isort5 only reads one config file and uses a specific order. So the tests need their own temporary dir each. So I started to rewrite the tests and because the
self.assertEqual()
calls in the unit tests made it hard to debug, I moved everything to pytest fixtures.Pytest is used by the CI anyway.
I started to work on a PR to support isort 5 before I saw #88 (comment), but I think it is the same approach. Please review.
Fixes #88