Skip to content
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

Introduce isort linting and apply it #169

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

leo-gan
Copy link
Contributor

@leo-gan leo-gan commented Aug 23, 2023

Sorted imports by 1.isort; 2.black (order is important)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 23, 2023
@patricklabatut
Copy link
Contributor

A few remarks:

  • requirements-dev.txt should also be updated,
  • There is a linter script (scripts/lint.sh) that should also be updated to run isort now,
  • The specific configuration of isort should be specified (via .isort.cfg or others).

Also I now remember why we ended up not applying isort: it's doing changes that are then undone by black... We would want to have configurations for isort and black that do not conflict like this.

@schmidt-ai
Copy link

schmidt-ai commented Aug 23, 2023

isort and black are compatible, given you configure isort correctly. @patricklabatut you are still seeing them conflict even in that case?

Also would strongly recommend adopting the ruff + black stack rather than isort...

@patricklabatut
Copy link
Contributor

I am definitely not saying the tools are not compatible, just that we did not spend enough time to figure this out if they are. If you can figure out settings that do not alternate changes applied by the two tools, I will gladly approve.

@schmidt-ai
Copy link

schmidt-ai commented Aug 23, 2023

Gotcha. Yeah that's a two-liner in pyproject.toml:

[tool.isort]
profile = "black"

cc @leo-gan

@patricklabatut
Copy link
Contributor

patricklabatut commented Aug 23, 2023

Yeah that's a two-liner in pyproject.toml:

Finding a "fixed point" for the sequence of linters was unfortunately a bit more complicated than just using the "black" profile of isort... Here is what seemed to work for me (in .isort.cfg):

[settings]
profile=black
multi_line_output=3
line_length=120
include_trailing_comma=true

@patricklabatut patricklabatut changed the title formatting Introduce isort linting and apply it Aug 23, 2023
@patricklabatut patricklabatut self-requested a review August 23, 2023 23:27
@patricklabatut patricklabatut self-assigned this Aug 23, 2023
@schmidt-ai
Copy link

schmidt-ai commented Aug 23, 2023

Where is .isort.cfg in the repo? Or is that your local config?

If the black integration is broken, a bug report should be filed with isort

@patricklabatut
Copy link
Contributor

That's a configuration file I just created locally to test again this problem of alternating changes. It's not (yet) in the repository.

If the black integration is broken, a bug report should be filed with isort

I won't jump yet to the conclusion that the integration is broken. For instance, we do specify a different maximum line length for black which has to be matched by isort, see the tip on the documentation page you linked:

Beyond the profile, it is common to set [...] line_length as it is common to deviate from black's default of 88.

@leo-gan
Copy link
Contributor Author

leo-gan commented Aug 23, 2023

[tool.isort]
profile = "black"

Yeah, I'm actually using ruff. Just had a feeling that isort would be a simpler option here. Anyway, if @patricklabatut is OK, ruff to be.

@leo-gan
Copy link
Contributor Author

leo-gan commented Aug 24, 2023

Note of sanity:
I don't see a good reason to use line_length=88 (black default). In my screens, 140 is much better. Maybe there are some devs with CGA or even with Hercules adapters?

@leo-gan
Copy link
Contributor Author

leo-gan commented Sep 13, 2023

@patricklabatut Any comments?

@patricklabatut
Copy link
Contributor

@patricklabatut Any comments?

I believe the feedback from previous comments [1] [2] still need to be integrated, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants