-
Notifications
You must be signed in to change notification settings - Fork 370
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
pre-commit: adopt isort hook #2150
Conversation
@dopplershift Thanks for the merges 👍 I'll rebase the other outstanding PRs asap... I'm afk atm |
pre-commit.ci autofix |
@dopplershift Conflicts resolved 👍 |
Is it perhaps worth being consistent with MPL and their configuration? They recently changed over to isort for some of their examples: matplotlib/matplotlib#25099 |
@greglucas They appear to be appyling |
Bingo! Yup, it certainly does. So it's possible to have Option 1import cartopy.crs as ccrs
from .helpers import check_proj_params Option 2import cartopy.crs as ccrs
from .helpers import check_proj_params Option 3from .helpers import check_proj_params
import cartopy.crs as ccrs Option 4from .helpers import check_proj_params
import cartopy.crs as ccrs Which pattern do you guys want to adopt? Option 1 is the @QuLogic was suggesting Option 2 (but this could also be Option 4, now we know the pattern to apply) |
I think this is the reasoning for the |
I don't have a strong opinion here; it was also mostly curiosity. I'd slightly lean towards 1 or 2, so maybe just leave it at the default? |
What about switching all of those from relative imports to explicit? |
Cool, okay. Let's minimise the |
94e4117
to
499e728
Compare
I kinda like the convenience of relative imports, but that's just me. We certainly could do this, but to enforce it we'd need another hook that runs before |
TBH I'm at the stage where I'm kinda done with this PR. Perhaps any additional changes could be made in a separate PR, when there is consensus for what's wanted? As it's a wee bit unclear to me what I'm aiming for otherwise. |
So overall I'm good with this. I personally find the empty line between "cartopy" imports and relative imports to be odd, so I'd personally opt for (2) from the options above. That would have the benefit of shrinking this diff a bit. Otherwise if there's better consensus around the current PR, I'm happy to merge. |
@dopplershift Thanks. Okay, thumbs up this comment to confirm you guys are happy with Option 2, and we'll roll with that 😀 |
@dopplershift @greglucas @QuLogic Okay guys, thanks for all your help on this. Very much appreciated 🍻 I've now pushed the final changes to go with Option 2, and I also fixed-up the commits to tidy things up. |
BTW I've managed to secure funding to go to SciPy 2023 this year 🥳 Are any of you guys going? If so, I'd love to hangout and catch-up 😄 |
I'm currently planning on attending. Looking forward to seeing you there! |
This PR adds support for the isort pre-commit git hook to enforce an opinionated
import
sort order throughout the code-base.The benefit is that there is one less distraction to consider for devs when reviewing pull-requests. Win 🥳
Reference: #1934