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.
For some context Jon Denning posted in #blender-coders:
C/C++ code should use clang format, but what about python? use PEP8? use none? I touched the space_view3d.py in a few spots, but PEP8 wants to reformat almost every line!
It was a while since I last looked into configuring autopep8, it used to always re-arrange imports in a way that broke our detection for module reloading and there wasn't a good way to configure it. Since then both issues are resolved, so committing this file makes it simpler to run autopep8 in a similar way to how clang-format can be used on Blender's C/C++ code.
Further work:
- Investigate removing some fixes from the ignore list, this needs to be done carefully as some of these could potentially break existing code / unintentional functional changes.
- Investigate making this part of make format
- For this to be done it might be best to include autopep8 with Blender so people aren't using different versions of the formatting tool.
- Check if the performance is prohibitively slow, on my system time autopep8 . -j 4 takes 7.26 seconds which doesn't seem too bad, although it's much slower than 3.23 seconds to run make format with cpu_count manually set to 4.
- Investigate improving autopep8's exclude checks, currently they're quite weak. autopep8 . works, but autopep8 $PWD doesn't because the resulting paths being matches against no longer have a ./ prefix, this seems like something the autopep8 tool would need to resolve - making paths relative to the pyproject.toml before checking if they should be excluded (submitted pull request to resolve this issue).
- Investigate running this on MS-Windows (check paths are properly excluded for example).
- Document using autopep8 on the wiki (similar to our docs for clang-format).