-
Notifications
You must be signed in to change notification settings - Fork 339
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
Restore isort to pre-commit check; apply to entire codebase #857
Restore isort to pre-commit check; apply to entire codebase #857
Conversation
Codecov Report
@@ Coverage Diff @@
## master #857 +/- ##
=======================================
Coverage 96.18% 96.18%
=======================================
Files 60 60
Lines 5368 5368
=======================================
Hits 5163 5163
Misses 205 205
Continue to review full report at Codecov.
|
plasmapy/diagnostics/langmuir.py
Outdated
import numpy as np | ||
from astropy import units as u | ||
from astropy.constants import si as const | ||
from astropy.visualization import quantity_support | ||
from scipy.optimize import curve_fit | ||
|
||
from plasmapy.particles import Particle | ||
from plasmapy.utils.decorators import validate_quantities | ||
from scipy.optimize import curve_fit |
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.
More tinkering with config
- separate plasmapy imports by newline
I'll have to try this again now that isort 5 is out |
Okay. I updated isort to 5.2.2 (the current stable release), merged in current master and #878 because that's soon to be merged, then applied the full pre-commit suite to all of those changes. The commit to really look through here would thus be 18b60ba . I think the changes it applies look fine now. |
simulation, | ||
utils, | ||
) | ||
from plasmapy import diagnostics, formulary, particles, plasma, simulation, utils |
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.
This looks a bit weird but I guess it's just below the line length limit, and I'm not going to argue with autotools on that point.
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.
Agreed! I guess it's practice in bowing down to our robotic overlords.
Oh right, squash merges do that. I'll rebase later. |
51bf085
to
24c4518
Compare
Okay, fixed the conflicts! |
setup.cfg
Outdated
[isort] | ||
# Set sorting of imports to be consistent with black formatting | ||
line_length=90 | ||
multi_line_output=3 | ||
include_trailing_comma: True | ||
include_trailing_comma=True | ||
force_grid_wrap=0 | ||
use_parentheses=True | ||
line_length=88 |
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.
After playing around with isort
, I'm really excited to have this implemented!!
According to isort
, the preferred configuration files are .isort.cfg
or pyproject.toml
. Since we already have a pyproject.toml
, I say we migrate the configuration to that file.
After playing with the isort
options, I think this would be the closes to what we've been implementing so far...
[tool.isort]
line_length = 88
wrap_length = 80
sections = ["FUTURE", "STDLIB", "FIRSTPARTY", "LOCALFOLDER"]
known_first_party = ["plasmapy", ]
default_section = "STDLIB"
multi_line_output = 3
use_parentheses = true
include_trailing_comma = true
force_alphabetical_sort_within_sections = true
lines_between_types = 1
Note, this will force third party packages and standard library packages into the same import section. That is how we've been organizing imports thus far. If we want to split up standard library and third party imports, then that's fine too. I just figure we stick with what we've been doing.
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 don't really see that as something worth setting up custom settings for - I'd be happy to go for isort defaults. But since you've gone to the trouble of doing it, and you likely have Opinions about this, I'll add this config and rerun the full isort pass.
@rocco8773 I've applied the changes. If they look okay, hit approve - but please don't merge, I'll do it manually locally to get .git-blame-ignore-revs right in a single pass. |
Apply Erik's changes to isort config Move its config to pyproject.toml Apply isort with the new config to the entire codebase Create .git-blame-ignore-revs
@@ -6,8 +6,7 @@ | |||
InvalidElementError, | |||
InvalidParticleError, | |||
) | |||
from plasmapy.particles.parsing import ( | |||
# duplicate with utils.pytest_helpers.error_messages.call_string? | |||
from plasmapy.particles.parsing import ( # duplicate with utils.pytest_helpers.error_messages.call_string? |
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.
This is odd. I've confirmed isort
is placing the comment here, which then violates PEP8 max line-length. I've played with the configuration options, but I couldn't find a solution. Maybe run black
after isort
.
In the end, this comment does not make much sense to me and can probably be deleted.
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.
Okay, I'll remove that one. Anything else that needs changing?
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.
Nope, everything else looks good to me.
c1b73e9
to
cd0af01
Compare
#846 removed isort from the pre-commit suite because it didn't play nicely
with CI. Well, according to
PyCQA/isort#1147 (comment)
isort will work well now. Let's see if that works.
a release out.
I also brought back the 88 line limit for consistency between the two
(it got the suite stuck in a permanent 2-cycle of 2 character line length
changes) - it turns out it's the default
in
black
, and I figure if Łukasz Langa believes in that default,it's a sane default.
I also added a file that lets you ignore isort/black commits in git blame locally.