Skip to content

Commit 83768e6

Browse files
committed
[docs] Add Python coding standard to documentation
As discussed on the forums: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style/ Reviewed By: jhenderson, JDevlieghere Differential Revision: https://reviews.llvm.org/D143852
1 parent 4bfe410 commit 83768e6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

llvm/docs/CodingStandards.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ code imported into the tree. Generally, our preference is for standards
5050
conforming, modern, and portable C++ code as the implementation language of
5151
choice.
5252

53+
For automation, build-systems and utility scripts Python is preferred and
54+
is widely used in the LLVM repository already.
55+
5356
C++ Standard Versions
5457
---------------------
5558

@@ -102,6 +105,21 @@ For more information about LLVM's data structures and the tradeoffs they make,
102105
please consult `that section of the programmer's manual
103106
<https://llvm.org/docs/ProgrammersManual.html#picking-the-right-data-structure-for-a-task>`_.
104107

108+
Python version and Source Code Formatting
109+
-----------------------------------------
110+
111+
The current minimum version of Python required is documented in the :doc:`GettingStarted`
112+
section. Python code in the LLVM repository should only use language features
113+
available in this version of Python.
114+
115+
The Python code within the LLVM repository should adhere to the formatting guidelines
116+
outlined in `PEP-8 <https://peps.python.org/pep-0008/>`_.
117+
118+
For consistency and to limit churn, code should be automatically formatted with the
119+
`black <https://github.com/psf/black>`_ utility. Black allows changing the formatting
120+
rules based on major version. In order to avoid unecessary churn in the formatting rules
121+
we currently use black version 23.x in LLVM.
122+
105123
Mechanical Source Issues
106124
========================
107125

0 commit comments

Comments
 (0)