-
Notifications
You must be signed in to change notification settings - Fork 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
Import sorting does not (immediately) converge? #12872
Comments
I can take a look. |
It's possible that we've just never seen this pattern before and so the sort isn't stable: from amrex.space1d.amrex_1d_pybind import IntVect1D
from amrex.space1d.amrex_1d_pybind import IntVect1D as IntVect |
Thank you for taking a look. Yes, an unstable isort pattern seems to cause this. I recently switched over to all-
The pattern here is for backwards compatibility as we face out the `IntVect` type for more explicit versions in our public APIs. Technically, the file that shows this is autogenerated from [pybind11-stubgen](https://github.com/sizmailov/pybind11-stubgen).
This is the line we do to declare the alias: https://github.com/AMReX-Codes/pyamrex/blob/c61add4fd44ad4ec69b131865375d76c68f12b29/src/Base/IntVect.cpp#L185
|
Did you have any sort of configuration set? Like: [tool.ruff.lint.isort]
force-single-line = true The style in those files doesn't match our standard style, so trying to figure out how to reproduce. |
No, none of that kind set. I now add "amrex" as known first party module, but that's all I set (no change with or without that option regarding the stability issue). I just realized I rebaded out the unstable sort commits yesterday in my mainline (using isort again for a stable sort), please let me know if I shall add those again in a feature branch. |
Okay thanks. I'm just struggling because if I check out |
That is right, this is the commit just right before I switched from black+isort to ruff. Here is how I see the issue:
The last two steps repeated create the unstable result for these imports. (Automated via pre-commit rules - I just added |
Example file after step 1 & 2: After running |
This is super interesting, the local files I create differ from the commits I autogenerated with pre-commit above (only difference I know is that they used ruff 0.5.6). |
Oh no, I think I see the issue, it's the pre commit. Either I should list no types or include explicitly pyi |
I think it was indeed the case that in the pre-commit rules, the The underlying issue is that I did not know what to put in I am so sorry for the confusion and noise. |
Hi,
I am using
ruff
verison 0.5.6 in pyAMReX (linter, not the formatter).I am using pre-commit to update our source code after merge to
development
. I usedblack
in the past and switched this week, discovering on August 10th and following thatruff
creates a lot of rotating changes when run multiple times:AMReX-Codes/pyamrex@74e0762
AMReX-Codes/pyamrex@5dc9c02
AMReX-Codes/pyamrex@902c41b
...
https://github.com/AMReX-Codes/pyamrex/commits/development/
for code of the form
Is there a way to avoid this?
This happens for us on
.pyi
headers and we intentionally have an alias for some of those imports (for backwards compatibility with a public API change that we are shipping).The text was updated successfully, but these errors were encountered: