[llvm] 83768e6 - [docs] Add Python coding standard to documentation
Tobias Hieta via llvm-commits
llvm-commits at lists.llvm.org
Mon May 15 01:58:57 PDT 2023
Author: Tobias Hieta
Date: 2023-05-15T10:58:51+02:00
New Revision: 83768e66108f583dcb2807a04662cfb9709ab2cf
URL: https://github.com/llvm/llvm-project/commit/83768e66108f583dcb2807a04662cfb9709ab2cf
DIFF: https://github.com/llvm/llvm-project/commit/83768e66108f583dcb2807a04662cfb9709ab2cf.diff
LOG: [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
Added:
Modified:
llvm/docs/CodingStandards.rst
Removed:
################################################################################
diff --git a/llvm/docs/CodingStandards.rst b/llvm/docs/CodingStandards.rst
index 49a23e0dcb3ac..9f0316bd49393 100644
--- a/llvm/docs/CodingStandards.rst
+++ b/llvm/docs/CodingStandards.rst
@@ -50,6 +50,9 @@ code imported into the tree. Generally, our preference is for standards
conforming, modern, and portable C++ code as the implementation language of
choice.
+For automation, build-systems and utility scripts Python is preferred and
+is widely used in the LLVM repository already.
+
C++ Standard Versions
---------------------
@@ -102,6 +105,21 @@ For more information about LLVM's data structures and the tradeoffs they make,
please consult `that section of the programmer's manual
<https://llvm.org/docs/ProgrammersManual.html#picking-the-right-data-structure-for-a-task>`_.
+Python version and Source Code Formatting
+-----------------------------------------
+
+The current minimum version of Python required is documented in the :doc:`GettingStarted`
+section. Python code in the LLVM repository should only use language features
+available in this version of Python.
+
+The Python code within the LLVM repository should adhere to the formatting guidelines
+outlined in `PEP-8 <https://peps.python.org/pep-0008/>`_.
+
+For consistency and to limit churn, code should be automatically formatted with the
+`black <https://github.com/psf/black>`_ utility. Black allows changing the formatting
+rules based on major version. In order to avoid unecessary churn in the formatting rules
+we currently use black version 23.x in LLVM.
+
Mechanical Source Issues
========================
More information about the llvm-commits
mailing list