redstreet / beancount_reds_importers

Simple ingesting tools for Beancount (plain text, double entry accounting software). More importantly, a framework to allow you to easily write your own importers.
GNU General Public License v3.0
111 stars 38 forks source link

Enforce formatting #95

Closed ranebrown closed 7 months ago

ranebrown commented 7 months ago

Adds a job to check formatting and formats all existing files with ruff.

Config options if you want anything changed from the defaults.

redstreet commented 7 months ago

Hello there, thanks for the PR! I think this is in general a good idea, and in particular helpful to keep contributions from multiple users consistent. However, it does seem to reduce readability in a few cases. I quickly highlighted a couple patterns, there are probably a few others. If you're familiar with ruff and its options, it'd be great if you could help figure out those cases at least, and I'd be happy to take it in. Thanks again!

ranebrown commented 7 months ago

I did a bit more digging and the option set is pretty limited. The ruff formatter pretty much matches black which intentionally gives you very few options to change so all code formatted with it should look the same. For specific cases this can be done:

# fmt: off
code_here()
...
#fmt: on

I would argue consistency across the board is better but let me know if you want formatting disabled on the sections you pointed out.

redstreet commented 7 months ago

Thanks for looking this up. You make a good point, and I agree overall. I still feel like target_accounts_map should be the one exception and remain unformatted, but I'm fine with leaving it to ruff on everything else for the sake of consistency.

f you're okay making the change to exclude those blocks alone, I'd be happy to take it in. Thank you!

ranebrown commented 7 months ago

Made a few more changes:

  1. Added exceptions for transaction_type_map and header_map.
  2. Changed max line length to 88 which makes things more readable in most cases (easy to change back to 127 if you prefer).
  3. Added isort formatting
  4. Moved ruff (and isort) config to a pyproject.toml file
redstreet commented 7 months ago

Looks great, I appreciate the PR and the changes! This was long needed. Merged. Thank you!