Skip to content

Source code formatting#22

Open
fbrausse wants to merge 5 commits intomasterfrom
fb/format-yapf
Open

Source code formatting#22
fbrausse wants to merge 5 commits intomasterfrom
fb/format-yapf

Conversation

@fbrausse
Copy link
Collaborator

@fbrausse fbrausse commented Aug 23, 2025

This PR adds the config file .style.yapf for automated source code formatting to the top-level directory and applies it to smlp_regr.py.

yapf is a Python source code formatter, similar to clang-format. It has quite
a lot of configuration options, which are stored in the file .style.yapf.

I've adjusted the defaults from 79 to 80 columns line width, and some settings
that handle line splitting of parenthesised, comma-separated content. These
settings are my taste.

The main reason is that overly long files are not easy to read and must be
split at a certain length. This goes for comments as well. Also, git is a
line-based tool, so having long lines also leads to more merge conflicts.

If this PR is approved, I suggest to run yapf over all .py files in this repo. We can also do that within this PR.

yapf is a Python source code formatter, similar to clang-format. It has quite
a lot of configuration options, which are stored in the file .style.yapf.

I've adjusted the defaults from 79 to 80 columns line width, and some settins
that handle line splitting of parenthesised, comma-separated content. These
settings are my taste.

The main reason is that overly long files are not easy to read and must be
split at a certain length. This goes for comments as well. Also, git is a
line-based tool, so having long lines also leads to more merge conflicts.
@fbrausse fbrausse requested a review from zurabksmlp August 23, 2025 12:46
@fbrausse fbrausse force-pushed the fb/format-yapf branch 2 times, most recently from c06dd7b to 0336b37 Compare August 23, 2025 14:29
@Th0ught09
Copy link
Collaborator

I think ruff is more standard, due to it being to a lot faster and more up to Ate. Maybe switching to that would be a bit easier? It also goes really well with pre-commits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants