[Bf-blender-cvs] [30acc5f9cde] master: pyproject: add configuration for autopep8

Campbell Barton noreply at git.blender.org
Fri Apr 22 02:16:20 CEST 2022


Commit: 30acc5f9cde7e94713600b8481837bda996f9753
Author: Campbell Barton
Date:   Tue Apr 19 15:50:35 2022 +1000
Branches: master
https://developer.blender.org/rB30acc5f9cde7e94713600b8481837bda996f9753

pyproject: add configuration for autopep8

This adds pyproject.toml, needed to configure defaults for autopep8.

The file is auto-discovered in a similar way to .clang-format, other
tools could be configured here too. For now just configure autopep8 so
this can be enabled in IDE's without causing unexpected edits such as
wrapping lines over 80 columns in width.

Now autopep8 can be used from the root directory by running: autopep8 .

This uses multiple-jobs to run autopep8 over all Python scripts except
paths that are explicitly ignored in exclude defined by pyproject.toml.

Reviewed By: mont29, brecht, sybren

Ref D14686

===================================================================

M	.editorconfig
A	pyproject.toml

===================================================================

diff --git a/.editorconfig b/.editorconfig
index 41ec3a1dc3d..0d2ec3d0766 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -34,6 +34,15 @@ indent_style = space
 indent_size = 2
 max_line_length = 99
 
+# Tom's Obvious Minimal Language
+[*.toml]
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+indent_style = space
+indent_size = 4
+max_line_length = 120
+
 # reStructuredText
 [*.rst]
 charset = utf-8
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 00000000000..921157d9034
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+[tool.autopep8]
+# Configuratuion for `autopep8`, allowing the command: autopep8 .
+# to reformat all source files.
+#
+# NOTE: the settings defined here map directly to commmand line arguments
+# which will override these settings when passed in to autopep8.
+
+max_line_length = 120
+
+ignore = [
+    # Info: Use `isinstance()` instead of comparing types directly.
+    # Why disable? Changes code logic, in rare cases we want to compare exact types.
+    "E721",
+    # Info: Fix bare except.
+    # Why disable? Disruptive, leave our exceptions alone.
+    "E722",
+    # Info: Fix module level import not at top of file.
+    # Why disable? Re-ordering imports is disruptive and breaks some scripts
+    # that need to check if a module has already been loaded in the case of reloading.
+    "E402",
+    # Info: Fix various deprecated code (via lib2to3)
+    # Why disable? Does nothing besides incorrectly adding a duplicate import,
+    # could be reported as a bug except this is likely to be removed soon, see:
+    # https://github.com/python/cpython/issues/84540.
+    "W690",
+]
+
+# Exclude:
+# - `./extern/` because it's maintained separately.
+# - `./release/scripts/addons*` & `./source/tools/` because they are external repositories
+#   which can contain their own configuration and be handled separately.
+# - `./release/scripts/modules/rna_manual_reference.py` because it's a generated data-file.
+exclude = """
+./extern/*,
+./release/scripts/addons/*,
+./release/scripts/addons_contrib/*,
+./release/scripts/modules/rna_manual_reference.py,
+./source/tools/*,
+"""
+
+# Match CPU count.
+jobs = 0
+
+# Format files in-place.
+in_place = true
+
+# Format directories recursively (except for excluded paths).
+recursive = true



More information about the Bf-blender-cvs mailing list