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

[RFC] Code-style for cms-bot scripts #2097

Closed
iarspider opened this issue Oct 30, 2023 · 5 comments
Closed

[RFC] Code-style for cms-bot scripts #2097

iarspider opened this issue Oct 30, 2023 · 5 comments

Comments

@iarspider
Copy link
Contributor

To make maintaining cms-bot easier, especially for new people, I'd like to propose to start enforcing code format. We already enforce it for main cmssw repo.

For initial reformat, we can use black - it is guaranteed to preserve AST (abstract syntax tree, i.e. logic). After that, we can add other tools, like flake8, mypy

@iarspider iarspider changed the title [RFQ] Code-style for cms-bot scripts [RFC] Code-style for cms-bot scripts Oct 30, 2023
@cmsbuild
Copy link
Contributor

A new Issue was created by @iarspider .

@Dr15Jones, @antoniovilela, @smuzaffar, @sextonkennedy, @rappoccio, @makortel can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

@iarspider
Copy link
Contributor Author

See #2099 for results of reformatting. I will add github actions in a followup commit to that PR.

@iarspider
Copy link
Contributor Author

https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#ast-before-and-after-formatting

To put things in perspective, the code equivalence check is a feature of Black which other formatters don’t implement at all. It is of crucial importance to us to ensure code behaves the way it did before it got reformatted. We treat this as a feature and there are no plans to relax this in the future. The exceptions enumerated above stem from either user feedback or implementation details of the tool. In each case we made due diligence to ensure that the AST divergence is of no practical consequence.

@smuzaffar
Copy link
Contributor

thanks @iarspider for the suggestion and setting up the github action to check for black format.
I guess this issue resolved and can be closed ... right?

@iarspider
Copy link
Contributor Author

Yes, let's close this, unless we want to implement more stricter checks (via flake8). black ensures minimal readability, while tools like flake8 can do static checks, but the proposed changes are not guaranteed to preserve AST and need to be reviewed/checked.

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

No branches or pull requests

3 participants