Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Black formatting #249

Open
incaseoftrouble opened this issue Nov 25, 2023 · 3 comments
Open

Use Black formatting #249

incaseoftrouble opened this issue Nov 25, 2023 · 3 comments

Comments

@incaseoftrouble
Copy link
Contributor

Hi,

This is more of a recommendation that would ease PR / Merging significantly: Namely, use / require the python formatter black. See here for its documentation.

Basically, black defines one very "rigid" code style, i.e. after formatting a file with black, it will almost always look the same, no matter what formatting one starts from. This may at first sound constricting, but if the style is so rigid, no formatting changes can accidentally creep into MRs and only "actual" changes appear in the PR.

Usage is quite simple. pip install black followed by black problemtools/ to format all .py files in that folder. So it also is rather simple to update all existing forks etc.

@Tagl
Copy link
Contributor

Tagl commented Nov 29, 2023

An alternative is ruff

@incaseoftrouble
Copy link
Contributor Author

Oh thanks, I didn't know that. I have no strong opinion on ruff over black, the main point of this issue is to suggest to use any of the reasonably popular formatters to have a defined formatting. This project is small enough that there probably isn't a noticeable difference between black and ruff, and its just about deciding whether it is a good idea (I really think so) and picking whichever seems more stable (both seem very mature).

@incaseoftrouble
Copy link
Contributor Author

incaseoftrouble commented Feb 12, 2024

Bump on this: I "switched" most of my projects to ruff thanks to your suggestion @Tagl

For the sake of this issue: Note that ruff and black are the "same", in the sense that ruff does black formatting + a lot of other stuff. Using ruff is nice because it also does a lot of static analysis and quick fixes.

I can add ruff with a pre-commit hook / open a PR to see how the repo would look like with ruff applied.

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

No branches or pull requests

2 participants