-
Notifications
You must be signed in to change notification settings - Fork 7
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
Black formatting and workflow integrations #475
Conversation
* pre-commit uses some general file hooks, black hooks, and rst hooks * black configured for github workflows to run on push and pull request
* autoflake for removing unused imports in Python files * clang-format for formatting C++ code * cppcheck for static analysis of C++ code * check-toml and check-yaml for parsing those filetypes * requirements-txt-fixer for sorting requirements.txt files * check-hooks-apply and check-useless-excludes to verify that pre-commit hooks and excludes are applicable * Added Black badge to README.md
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 like the overall consistency - 90% of it looks great. There are few instances where the linter changes commands to use multiple lines, making them less readable. If we decide this is our standard, I guess its alright - we'd be consistent at least.
See https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html for the rules that Black adheres to when reformatting code |
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.
Looks great! Overall I'm a big fan of the formatting changes. Make sure you have tested to make sure everything works properly though. Run the radar in both release and debug mode, test the scheduler, test the experiments, run any other test scripts we have that are functional, etc...
As long as everything still works properly, I think this will be a very welcome update to the code.
args = [ | ||
"--site_id", | ||
self.site_id, | ||
"--experiments", | ||
line_dict["experiment"], | ||
"--kwargs", | ||
line_dict["kwargs"], | ||
"--module", | ||
"experiment_unittests", | ||
] |
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.
This one is a bit rough to be split. I'm not sure my suggestion here is doable with black formatting. Maybe if this was changed to a dictionary? It would just be nice to have the --option
on the same line as the option value
.
args = [ | |
"--site_id", | |
self.site_id, | |
"--experiments", | |
line_dict["experiment"], | |
"--kwargs", | |
line_dict["kwargs"], | |
"--module", | |
"experiment_unittests", | |
] | |
args = [ | |
"--site_id", self.site_id, | |
"--experiments", line_dict["experiment"], | |
"--kwargs", line_dict["kwargs"], | |
"--module", "experiment_unittests", | |
] |
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.
Sorry but that's just the way it works, your suggestion does not pass the pre-commit Black formatting check. This a feature of Black; it has an opinion about how things should be formatted, and it is rigid in enforcing it.
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.
What happened to this file? I think it's fine, a whole section seems to have been removed so I just want to make sure someone double checks it.
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.
Previously this file contained a bunch of results from having run the notebook, which I have removed.
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.e. the reformatting didn't touch this file, I did
I've tested running normalscan on the lab computer in |
Added
pre-commit
and GitHub workflow integrations for enforcing code standards.pre-commit
has the following hooks:requirements.txt
filesBlack
.git-blame-ignore-revs
file which Git and GitHub respect.Most of the dependencies for using
pre-commit
on a machine can be installed in a virtual environment from thepyproject.toml
specification for Borealis; within the Borealis directory, runpip install .[dev]
. You will also need to installcppcheck
, which can be installed via zypper (or your native package manager).