Skip to content

Use ruff for formatting #1275

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

calad0i
Copy link
Contributor

@calad0i calad0i commented Apr 16, 2025

Description

While the current codebase favors single quote strings, black cannot enforce that (only otherwise around). This PR replaces black by ruff which can enforce single quote for one-line strings, and double quote for docstring/other multiline string.

Other formatting behavior also changes, mainly assert no longer breaks at the strange location, multiple imports from the same location will be merged automatically, etc.

This PR will introduce major merge conflicts if added as-is.

isort's functionality is covered thus removed. flake8 doesn't seem to be really necessary but is kept just in case.

Type of change

  • Other (Specify)

'--skip-string-normalization']
- id: ruff
args: [--fix]
- id: ruff-format
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to enforce the line length of 125

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in pyproject.toml now

'--extend-ignore=E203,T201'] # E203 is not PEP8 compliant
'--extend-ignore=E203,T201,F401']
# E203 is not PEP8 compliant
# F401 included in ruff (behaves slightly differently for noqa flags)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is F401 ignored everywhere? If so, I think it's a bad idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F401 included in ruff, see pyproject.toml. Only ignored for __init__.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants