Skip to content

STY: Partially apply ruff/pycodestyle rules (E) #28775

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

Merged
merged 7 commits into from
Apr 28, 2025

Conversation

DimitriPapadopoulos
Copy link
Contributor

Partially apply some ignored E rules.

These rules cannot be applied blindly. For example, tabular data requires extra spaces to remain aligned.

Not sure yet how to enable these rules. For example, exclude files that contain tabular data?

This comment has been minimized.

@jorenham jorenham self-requested a review April 19, 2025 19:06
@jorenham

This comment was marked as resolved.

This comment has been minimized.

@DimitriPapadopoulos

This comment was marked as resolved.

@jorenham

This comment was marked as resolved.

@charris
Copy link
Member

charris commented Apr 23, 2025

It probably won't be enforced globally anytime soon

The problem is with reformatting multidimensional array data, the result is just awful.

@jorenham
Copy link
Member

It probably won't be enforced globally anytime soon

The problem is with reformatting multidimensional array data, the result is just awful.

Yea I agree. But in this case it's a 1d array that's arbitrarily split over two lines.

BTW, enforcing ruff format isn't absolute: You can temporarily disable it with # fmt: skip for a single statement, and with # fmt: off and # fmt: on for a range of code.

@DimitriPapadopoulos
Copy link
Contributor Author

I unwrapped the split line as it fits the new line-length limit of 88 characters.

By the way, would you accept a PR that runs ruff format on Numpy, but wraps multidimensional arrays in # fmt: off/on?

This comment has been minimized.

@jorenham
Copy link
Member

By the way, would you accept a PR that runs ruff format on Numpy, but wraps multidimensional arrays in # fmt: off/on?

Only if it's possible to enforce a different max-line-length for .py (88) and .pyi (130) (astral-sh/ruff#16057, astral-sh/ruff#7696).

@charris
Copy link
Member

charris commented Apr 25, 2025

Rebase needed.

DimitriPapadopoulos and others added 7 commits April 27, 2025 11:55
Multiple spaces after comma

Do not apply this rule to tabular data, tables must remain aligned.
Unexpected spaces around keyword / parameter equals

For now, do not modify large and consistent code blocks that use spaces on
purpose, mostly when the default values are arrays.
Block comment should start with `# `

For now, keep commented out code as is.
Too many leading `#` before block comment

For now, do not modify titles.
Co-authored-by: Joren Hammudoglu <jhammudoglu@gmail.com>
Unwrap the array arbitrarily split over two lines, as it fits the new
default line-length limit of 88 characters.

Co-authored-by: Joren Hammudoglu <jhammudoglu@gmail.com>
@jorenham
Copy link
Member

FYI, it turned out that the mypy_primer issue was unrelated after all: hauntsaninja/mypy_primer#161

@jorenham jorenham merged commit 000b28d into numpy:main Apr 28, 2025
75 checks passed
@jorenham
Copy link
Member

Thanks Dimitri :)

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

Successfully merging this pull request may close these issues.

3 participants