-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Apply import formatter isort
#4805
Comments
Would you consider adding the following labels to this issue so that new contributors can work on this issue...? |
it's a pre-commit hook right? wouldn't it be done automatically when someone makes changes to a file in a PR just before it gets merged?? otherwise, I would suggest doing it all at once in a single PR just before the next release (v1.1, I suppose). |
@rohitgr7 Yes, #4242 added Also, #4242 actually tried to apply isort to all files at once, but I think we agreed to split the PR to avoid unexpected errors as @Borda mentioned in the PR:
|
oh okay, I thought pre-commit hook runs before a PR get's merged. Is there something like a pre-merge hook which always runs on the changed files before a PR get's merged. If there is one I feel it will be useful to avoid any import formatting issues in the future. |
yes, that is the CI as @akihironitta mentioned, but at this moment we have almost all files ignored so when a file is fixed we remove it from the ignore lost and since that time it shall be checked with each PR before merge... |
EDIT: pls ignore the above statements :] |
Happy to help with this, if more helping hands are needed. |
sure go ahead. @hassiahk |
@rohitgr7, I will start from the bottom |
@akihironitta sure, definitely. |
I have all commits ready to fix isort (~20). Should I create 20 PRs for that? |
I noticed that isort and black change import formatting differently, which leads to unnecessary file changes. Maybe consider this configuration: https://black.readthedocs.io/en/stable/compatible_configs.html#isort |
We are actually introducing |
Once @arnaudgelas updates all the PRs, I'll start to check them and mark them as ready-to-go. #5420 (comment) https://github.com/PyTorchLightning/pytorch-lightning/pulls?q=is%3Apr+is%3Aopen+isort |
@Borda I just realised that I'm not authorised to relabel issues/PRs in PL repo, so if you'd like me to do so, add me to the team on GitHub :] |
🚀 Refactoring
As
isort
has been added to ci in #4242, we now need to apply the formatter step by step i.e. a submodule per PR (recommended in #4242 (comment) by @Borda)Steps
For each PR:
isort
to itpyproject.toml
isort --check
passesProgress
The rest of the submodules should be done by @arnaudgelas.The followings are PL submodules.
pytorch_lightning/*.py
>> Apply import formatting to files in the 2nd top level #4717pytorch_lightning/accelerators/
pytorch_lightning/callbacks/
pytorch_lightning/cluster_environments/
pytorch_lightning/core/
pytorch_lightning/distributed/
pytorch_lightning/loggers/
pytorch_lightning/metrics/
pytorch_lightning/overrides/
pytorch_lightning/plugins/
pytorch_lightning/profiler/
pytorch_lightning/trainer/
pytorch_lightning/tuner/
pytorch_lightning/utilities/
The followings are tests.
tests/*.py
>> Apply import formatting to files in the 2nd top level #4717tests/backends/
>> Fix pre-commit isort failure on tests/backends/*.py #5430tests/base/
>> Fix pre-commit isort failure on tests/base/*.py #5429tests/callbacks/
>> Fix pre-commit isort failure on tests/callbacks/*.py #5428tests/checkpointing/
>> Fix pre-commit isort failure on tests/checkpointing/*.py #5427tests/core/
>> Fix pre-commit isort failure on tests/core/*.py #5426tests/loggers/
>> Fix pre-commit isort failure on tests/loggers/*.py #5425tests/plugins/
>> Fix pre-commit isort failure on tests/plugins/*.py #5422tests/metrics/
>> Fix pre-commit isort failure on tests/metrics/*.py #5424tests/models/
>> Fix pre-commit isort failure on tests/models/*.py #5423tests/trainer/
>> Fix pre-commit isort failure on tests/trainer/*.py #5421tests/tuner/
tests/utilities/
>> Fix pre-commit isort failure on tests/utilities/*.py #5420The followings are other python files.
*.py
(CI: Added isort import check for the code on pull-request #4242)docs/
(CI: Added isort import check for the code on pull-request #4242)pl_examples/
(Apply isort topl_examples/
#5291)The text was updated successfully, but these errors were encountered: