blender/pyproject.toml
Sybren A. Stüvel f6fc417fec Black: skip string normalisation
Black (the Python formatter) shouldn't be used on Blender. However, it
is still the default formatter for some people's IDE (like mine). If
it's accidentally used, its default behaviour is to normalise strings so
they use double quotes.

This string normalisation can be tedious to recover from. This PR
configures Black so that it doesn't do that any more. This makes such a
mistake easier to recover.

An additional comment explains that Black shouldn't be used, and that
the configuration is there just to make it less annoying in case of
mistakes.

For the same reasons, this commit also includes the config option
`line_length = 120`. It just makes Black change less of our code when
it's accidentally used.
2024-01-22 10:09:33 +01:00

58 lines
2.3 KiB
TOML

# SPDX-License-Identifier: GPL-2.0-or-later
[tool.autopep8]
# Configuration for `autopep8`, allowing the command: autopep8 .
# to reformat all source files.
#
# NOTE: the settings defined here map directly to command 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",
]
# Use aggressive as many useful edits are disabled unless it's enabled.
# Any edits which are overly disruptive or risky can be removed in the `ignore` list.
aggressive = 2
# Exclude:
# - `./extern/` because it's maintained separately.
# - `./tools/svn_rev_map/` contains data-files which are slow to re-format and don't benefit from formatting.
# - `./scripts/addons*` because it is an external repository.
# which can contain their own configuration and be handled separately.
# - `./scripts/modules/rna_manual_reference.py` because it's a generated data-file.
exclude = """
./extern/*,
./scripts/addons/*,
./scripts/addons_contrib/*,
./scripts/modules/rna_manual_reference.py,
./tools/svn_rev_map/sha1_to_rev.py,
./tools/svn_rev_map/rev_to_sha1.py,
"""
# Omit settings such as `jobs`, `in_place` & `recursive` as they can cause editor utilities that auto-format on save
# to fail if the STDIN/STDOUT is used for formatting (which isn't compatible with these options).
# Black shouldn't be used as a formatter. But if it's accidentally
# used, it certainly shouldn't change all the quote marks around
# strings. This simply makes such a mistake easier to recover from.
[tool.black]
skip-string-normalization = true
line-length = 120