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

[doc] Apply black on the documentation where it makes sense #8650

Merged

Conversation

Pierre-Sassoulas
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas commented May 1, 2023

Type of Changes

Type
✨ New feature
🔨 Refactoring
📜 Docs

Description

Refs: #8630 (comment)

@Pierre-Sassoulas Pierre-Sassoulas added Documentation 📗 Maintenance Discussion or action around maintaining pylint or the dev workflow Skip news 🔇 This change does not require a changelog entry labels May 1, 2023
doc/data/messages/c/class-variable-slots-conflict/good.py Outdated Show resolved Hide resolved
doc/data/messages/i/invalid-all-format/bad.py Show resolved Hide resolved
doc/data/messages/i/invalid-slots/good.py Outdated Show resolved Hide resolved
doc/data/messages/t/too-many-ancestors/bad.py Outdated Show resolved Hide resolved
doc/data/messages/t/too-many-statements/bad.py Outdated Show resolved Hide resolved
@Pierre-Sassoulas Pierre-Sassoulas force-pushed the apply-black-on-relevant-doc branch from 1f11514 to 501c1e0 Compare May 1, 2023 20:55
@codecov
Copy link

codecov bot commented May 1, 2023

Codecov Report

Merging #8650 (7402131) into main (3bb57fa) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #8650   +/-   ##
=======================================
  Coverage   95.81%   95.81%           
=======================================
  Files         174      174           
  Lines       18337    18337           
=======================================
  Hits        17570    17570           
  Misses        767      767           

# Should be in sync with doc/data/ruff.toml
args: [--safe, --quiet, -l 103]
files: doc/data/messages/
exclude: |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we re-use this like we do with &fixtures and pass it in the pre-commit config?

Copy link
Member Author

Choose a reason for hiding this comment

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

What need to be in sync is the -l 103, black only looks at pyproject.toml so we have to give the option like this. (Alternatively we could use the default value, it's not super important.).

I don't think the exclude can be reused, this is the list of the message that black can fix automatically, it's really specific to black.

It's also a very useful list btw ! I'm considering to recover it automatically and generalize it to autofixxer (isort, autoflake, and ruff), in order to use this information directly in our doc for #8579

Copy link
Member Author

Choose a reason for hiding this comment

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

I.e. if applying a tool on doc/data makes the tests fail on a m/my-message/bad.py file, then the tool autofix my-message. We might have to use it on functional tests instead for complicated fixes like ruff or autoflake to check which use cases is autofixed or not, but for black on the doc is enough and you get the idea.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, let's use the default then. Less config == better imo

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm going to need to rebase and rewrite black from zero, it's not THAT good with comment after all 😄

Copy link
Collaborator

Choose a reason for hiding this comment

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

Shall we merge this and do another PR that removes the config?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it breaks the comments to go back to 88 char per line after doing 103 char per line, it's a lot easier to do it from scratch again :)

@Pierre-Sassoulas Pierre-Sassoulas force-pushed the apply-black-on-relevant-doc branch from 0034c3c to e4f17ec Compare May 2, 2023 09:16
@Pierre-Sassoulas
Copy link
Member Author

Sorry for the noise, should be ready for review again.

files: doc/data/messages/
exclude: |
(?x)^(
doc/data/messages/r/redundant-u-string-prefix/bad.py|
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shall we make this alphabetized?

@Pierre-Sassoulas Pierre-Sassoulas force-pushed the apply-black-on-relevant-doc branch from 876e5b8 to e7ba0a0 Compare May 2, 2023 11:17
@@ -52,6 +52,30 @@ repos:
- id: black
args: [--safe, --quiet]
exclude: *fixtures
- repo: https://github.com/psf/black
Copy link
Collaborator

Choose a reason for hiding this comment

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

One final nit, can't this be a separate hook in the repo above? Or this is not how pre-commit works?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's a yaml issue actually, we can't use *fixtures with another regex (or at least I'm not knowledgeable enough to do it).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Pushed a small change, let me know what you think!

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice !

Copy link
Member Author

Choose a reason for hiding this comment

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

Same thing could be done for ruff actually

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll do that next time there's a pre-commit autoupgrade, (should be soon).

@Pierre-Sassoulas Pierre-Sassoulas enabled auto-merge (squash) May 2, 2023 11:29
@Pierre-Sassoulas Pierre-Sassoulas merged commit 87fe5e5 into pylint-dev:main May 2, 2023
@Pierre-Sassoulas Pierre-Sassoulas deleted the apply-black-on-relevant-doc branch May 2, 2023 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation 📗 Maintenance Discussion or action around maintaining pylint or the dev workflow Skip news 🔇 This change does not require a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants