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

Replace black with ruff-format #15312

Merged
merged 10 commits into from
Mar 15, 2024
Merged

Conversation

mroeschke
Copy link
Contributor

@mroeschke mroeschke commented Mar 14, 2024

Description

xref #14882

This PR replaces black with ruff-format with it's default configurations. The ruff configuration had a line length of 88 while black had a line length configuration of 79, so aligned them to 79.

The next step would be to consider replacing isort too

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@mroeschke mroeschke added Python Affects Python cuDF API. improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Mar 14, 2024
@mroeschke mroeschke requested review from a team as code owners March 14, 2024 22:08
f"{string.ascii_lowercase[i]}": ["sum", "mean", "count"]
for i in range(6)
},
{f"{string.ascii_lowercase[i]}": ["sum", "mean", "count"] for i in range(6)},
Copy link
Contributor

Choose a reason for hiding this comment

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

I find the previous version more readable, do we have to configure any line length settings to achieve that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can re-configure ruff to go back to a 79 line length

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of note: Some of our copyright lines lines are longer than 79 line length, so I had to noqa those.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! I think noqa'ing those is fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

#15312 (comment)

Adding noqa here isn't ideal. The SPDX identifiers are meant to be machine-readable...

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a documented limitation:
astral-sh/ruff#4429
astral-sh/ruff#5899

☹️

Copy link
Contributor

Choose a reason for hiding this comment

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

The reason I hesitate on this is that I think we are supposed to migrate towards SPDX identifiers in all our copyright headers. We shouldn’t noqa every file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW I would also be OK with a line-length of 88 (that's what we use in pandas)

Copy link
Contributor

Choose a reason for hiding this comment

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

We can, as the ruff FAQs suggest, run ruff format but ignore E501 (line length issues). This might lead to some lines that are over the line length, but with the conservative value of 79, I don't think it is necessarily that problematic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea with ignoring E501. Yeah we can go with that for now.

@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION & AFFILIATES.
# SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION & AFFILIATES. # noqa: E501
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really want to make linter exceptions for the copyrights "inline". 😕 What alternatives do we have? A line length of 88 would permit this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Almost everywhere else (which is why we don't need it), we have NVIDIA CORPORATION rather than NVIDIA CORPORATION & AFFILIATES.

Not saying which is right/wrong, just noting.

Copy link
Contributor

Choose a reason for hiding this comment

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

For these files, it needs to stay as-is with the "& AFFILIATES".

Copy link
Contributor

@wence- wence- left a comment

Choose a reason for hiding this comment

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

I am happy with this, pending resolution of the line length issues in comments one way or another.

@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION & AFFILIATES.
# SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION & AFFILIATES. # noqa: E501
Copy link
Contributor

Choose a reason for hiding this comment

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

Almost everywhere else (which is why we don't need it), we have NVIDIA CORPORATION rather than NVIDIA CORPORATION & AFFILIATES.

Not saying which is right/wrong, just noting.

pyproject.toml Show resolved Hide resolved
Copy link
Contributor

@bdice bdice left a comment

Choose a reason for hiding this comment

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

This is an acceptable compromise (disabling E501 and having the formatter enforce line lengths). But we should remove the [tool.ruff.format] excludes list. It's not needed.

pyproject.toml Outdated Show resolved Hide resolved
@mroeschke
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit 13f6cd3 into rapidsai:branch-24.04 Mar 15, 2024
75 checks passed
@mroeschke mroeschke deleted the format/ruff branch March 15, 2024 22:45
rapids-bot bot pushed a commit that referenced this pull request Oct 25, 2024
since #15312 moved formatting from Black to Rufft, it would make sense also unify import formatting under the same ruff so use build-in `I` rule instead of additional `isort`

Authors:
  - Jirka Borovec (https://github.com/Borda)
  - Kyle Edwards (https://github.com/KyleFromNVIDIA)
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - Bradley Dice (https://github.com/bdice)
  - Vyas Ramasubramani (https://github.com/vyasr)
  - https://github.com/jakirkham

URL: #16685
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants