-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: make modules use black formatter #11
base: main
Are you sure you want to change the base?
Conversation
Quality Gate passedIssues Measures |
Agree, 100% |
For automating it, in the PR I have set the VSCode configuration to So yes, it could be nice to have something in Jenkins to auto-format, just in case. |
I see it, nice add! |
tox checks for line length 80 but back is configured for 88 ai4-template/{{ cookiecutter.__repo_name }}/tox.ini Lines 25 to 29 in 4e8a88f
ai4-template/{{ cookiecutter.__repo_name }}/.vscode/settings.json Lines 10 to 12 in 4e8a88f
Is a reason why to check for 88? |
I would also recommend to add "isort". |
|
||
For an optimal development experience, we recommend installing the VScode extensions | ||
[Black](https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter) | ||
and [Format on Auto Save](https://marketplace.visualstudio.com/items?itemName=BdSoftware.format-on-auto-save). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if BdSoftware is needed?
I run it in my local and it was all working without it.
If we do not add BdSoftware then I would remove this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my case, formatting did not happen without BSsoftware extension.
I'm using VScode 1.92.1 on Ubuntu 20.04. As far as I can tell, people still complain it not working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have 1.92.2 and U 22.04, however, It should be the same.
I was not trying exactly the same but rather the config here (updated):
https://github.com/ai4os-hub/demo-advanced/blob/main/.vscode/settings.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested with your configuration and it still does not work in my local. So to be on the save side, I would just keep the BSsoftware extension.
The tox configuration is the one recommended by Black. I think it's something like 80 + 10% --> 88 But I remember doing so when I manually installed black + bugbear with pip. Alternative options:
|
I'm fine adding isort. Probably adding the Python extension (which includes isort) is a good idea, although this may add several other extensions that people may not want. So I'm fine adding only isort. |
Bugbear does not ship with black.
We can fix to for example:
To do not use the binary, I tested adding the following: "black-formatter.path": [ "black" ],
"black-formatter.args": [ "--line-length=80" ], I never used "editor.rulers", but with You can check it is working by uninstalling black from the env and see it is not working. Sadly it does not raise a warning that you have to install black. |
Regarding the line-length, B950 sets the max-length to 88, though recommended length is still 80. For me it makes more sense the ruler to be at the max-length. |
First line works, but as I said in the previous comment, I don't think we should touch Black default's line-length. It's already being taking care of by B950.
If we add black and bugbear in the |
LGTM |
Well, in reality for formatting during development we don't need bugbear right? So we can use the Black binary (ie. do not change With this we avoid making the user install |
@vykozlov @BorjaEst
Maybe it's a good idea to start suggesting modules to use Black as formater, as it is starting to become a standard in many big Python projects.
Content of this PR:
For reference, I recently implemented it in the demo app and it's working fine as far as I can tell.