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

🔧 Ruff format python files within utils folder #12142

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

chrisjsewell
Copy link
Member

Next "un-controversial" formatting

Next "un-controversial" formatting
@@ -24,7 +24,8 @@


def stringify_version(
version_info: VersionInfo, in_develop: bool = True,
version_info: VersionInfo,
Copy link
Member

Choose a reason for hiding this comment

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

Just wondering, but did it put this on one two lines because we disabled the trailing comma?

Copy link
Member Author

@chrisjsewell chrisjsewell Mar 19, 2024

Choose a reason for hiding this comment

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

Ha, so this is a little ideocyncracy, that black/ruff always "respects" existing trailing-commas, explained here: https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#the-magic-trailing-comma

I've just made a commit, removing the trailing commas, and you can see the signatures are now on one line

You can remove this behaviour with https://docs.astral.sh/ruff/settings/#format_skip-magic-trailing-comma

Copy link
Member Author

Choose a reason for hiding this comment

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

So, to respect existing trailing commas or not?

Copy link
Member

Choose a reason for hiding this comment

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

So... should we change the behaviour? As I said before, it's a personal taste but if we are running ruff format then I won't complain to whatever it decides to do. However, if it's possible to avoid adding lines to files that are sometimes already large, I'd be happy (and stay consistent with the rules we have).

Copy link
Member

Choose a reason for hiding this comment

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

(Actually, I wasn't expecting you to change the lines)

Copy link
Member Author

Choose a reason for hiding this comment

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

So... should we change the behaviour?

well I guess what kinda makes sense is that, the first time you run the formatting on an un-formatted file, you use skip-magic-trailing-comma = false, but then in general you just run with the default skip-magic-trailing-comma = true

anyway, with the changes I just made it now stays the same whether you use true or false

Copy link
Member

Choose a reason for hiding this comment

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

I agree with that. Maybe you can open an issue for ruff formatting the code base so that contributors know about it.

utils/babel_runner.py Outdated Show resolved Hide resolved
Copy link
Contributor

@danieleades danieleades left a comment

Choose a reason for hiding this comment

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

huge improvement

@chrisjsewell chrisjsewell merged commit 392358d into sphinx-doc:master Mar 19, 2024
7 checks passed
@chrisjsewell chrisjsewell deleted the ruff-format-utils branch March 19, 2024 18:32
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 19, 2024
@AA-Turner AA-Turner added this to the 7.3.0 milestone Jul 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants