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

Use ruff instead of isort and black and enforce basic linting #152

Conversation

elliot-100
Copy link
Collaborator

@elliot-100 elliot-100 commented Sep 6, 2024

This PR effectively replaces isort + black with ruff check/ruff format, including in CI.

  • It enforces ruff's formatting rules - these differ slightly from black's, but I don't think it's worth worrying about that.
  • It also enforces a few basic linting rules that the code already meets (a subset of those suggested at https://docs.astral.sh/ruff/linter/#rule-selection). These can be extended in future.

How to use at CLI when developing:

  • Use ruff check --fix to autolint, instead of isort . to just sort imports
  • Use ruff format instead of black .

@elliot-100 elliot-100 self-assigned this Sep 6, 2024
@elliot-100 elliot-100 force-pushed the 115-ci-isort-github-action-doesnt-report-expected-issues branch from 2ea13d2 to ac3bafa Compare September 6, 2024 21:03
@elliot-100 elliot-100 force-pushed the 115-ci-isort-github-action-doesnt-report-expected-issues branch from ac3bafa to 19f6697 Compare September 14, 2024 12:36
@elliot-100 elliot-100 force-pushed the 115-ci-isort-github-action-doesnt-report-expected-issues branch 2 times, most recently from df4a246 to 64995bb Compare October 13, 2024 15:50
@elliot-100 elliot-100 added the enhancement New feature or request label Oct 22, 2024
@elliot-100 elliot-100 force-pushed the 115-ci-isort-github-action-doesnt-report-expected-issues branch 3 times, most recently from 0655499 to 0458dc6 Compare February 12, 2025 18:02
This enforces import sorting in example files, which isort didn't do.

Notes:

- Ruff takes a single value for `target-version` - the minimum Python version that should be supported
- Use `ruff check --fix` instead of `isort .` at CLI
- Use `ruff format` instead of `black .` at CLI
@elliot-100 elliot-100 force-pushed the 115-ci-isort-github-action-doesnt-report-expected-issues branch from 0458dc6 to 1fa9053 Compare February 12, 2025 18:27
@elliot-100 elliot-100 marked this pull request as ready for review February 12, 2025 18:38
@elliot-100 elliot-100 requested a review from Olen February 12, 2025 18:39
@elliot-100 elliot-100 marked this pull request as draft February 12, 2025 19:02
@elliot-100
Copy link
Collaborator Author

Back to draft as I am still getting inconsistent behaviour between local and CI...

@elliot-100 elliot-100 removed the request for review from Olen February 12, 2025 19:03
`config` module may be present in local dev, but won't be in CI - this causes inconsistent behaviour
@elliot-100 elliot-100 marked this pull request as ready for review February 12, 2025 19:13
@elliot-100 elliot-100 requested a review from Olen February 12, 2025 19:14
@elliot-100
Copy link
Collaborator Author

OK, that now gives consistent behaviour whether config module is present (as it is likely to be in local dev) or not (in CI)

@elliot-100 elliot-100 changed the title Use ruff instead of isort and black Use ruff instead of isort and black and enforce basic linting Feb 13, 2025
@elliot-100
Copy link
Collaborator Author

@Olen are you OK with this please?

@Olen
Copy link
Owner

Olen commented Feb 13, 2025

LGTM

@Olen Olen merged commit 1adb152 into Olen:main Feb 13, 2025
5 checks passed
@elliot-100 elliot-100 deleted the 115-ci-isort-github-action-doesnt-report-expected-issues branch February 13, 2025 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI: isort GitHub action doesn't report expected issues
2 participants