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

[docs] Add more details about Python formatting #66141

Merged
merged 4 commits into from
Sep 14, 2023

Conversation

jdenny-ornl
Copy link
Collaborator

Describe the darker utility. Make it clear that black/darker's default rules should be used.

See ongoing discussion at
https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style/68257.

Describe the darker utility.  Make it clear that black/darker's
default rules should be used.

See ongoing discussion at
<https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style/68257>.
Comment on lines 126 to 127
<https://pypi.org/project/darker/>`_ utility with its default rules to format
any changed Python code. Doing so should ensure the patch will pass the Python
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not have a specific suggestion, but could we make it clearer that darker is something that calls black rather than a different formatter?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hah, yeah I was just going to post the same suggestion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea. Done.


.. code-block:: bash

$ pip install black darker
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should pin versions here, maybe use a requirements.txt or something? We have it stated above that we recommend version 23.x for now, and the point of this is that black only guarantees a stable format within the major versions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To keep the example simple, does the following seem reasonable?

$ pip install black=='23.*' darker

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.


When contributing a patch unrelated to formatting, you should format only the
Python code that the patch modifies. For this purpose, use the `darker
<https://pypi.org/project/darker/>`_ utility to call black with its default
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would probably say something like "darker utility which runs default black rules over only the changed patch"..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done. Let me know if the wording I chose doesn't satisfy the concern.

Wordsmith.

Specify black version in example `pip install` command.

In the example, use `HEAD` instead of `@` as more git users probably
know the former.

In the example, drop `..:WORKTREE:` as it's hard to remember and,
fortunately, redundant.  Leave that part to the darker documentation.
Copy link
Collaborator

@tru tru left a comment

Choose a reason for hiding this comment

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

LGTM

@jdenny-ornl jdenny-ornl merged commit 15a1d28 into llvm:main Sep 14, 2023
1 of 2 checks passed
ZijunZhaoCCK pushed a commit to ZijunZhaoCCK/llvm-project that referenced this pull request Sep 19, 2023
Describe the darker utility. Make it clear that black/darker's default
rules should be used. Add some examples.

See ongoing discussion at
<https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style/68257>.
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.

None yet

4 participants