-
Notifications
You must be signed in to change notification settings - Fork 4
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
build: add import formatting with autoflake and isort #247
Conversation
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified FilesNo covered modified files...
|
Makefile
Outdated
fmt: | ||
$(PYTHON) -m autoflake --remove-all-unused-imports --in-place --recursive . |
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.
ruff check --fix
will also remove unused imports; if you only want to sort imports and remove unused, you can run ruff check --select I,F401 --fix
. (F401
is the code for unused imports, and I
is the code group for isort-related issues).
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.
haha, I also just realized that. I had forgotten Ruff is a drop-in replacement for all of these tools.
ceb3331
to
5acdd24
Compare
@@ -22,7 +22,7 @@ Before contributing to the `posit-sdk`, ensure that the following prerequisites | |||
1. Create a new branch for your feature or bug fix. | |||
1. Run `make` to run the default development workflow. | |||
1. Make your changes and test them thoroughly using `make test` | |||
1. Run `make fmt`, `make lint`, and `make fix` to verify adherence to the project style guide. | |||
1. Run `make fmt` and `make lint` to verify adherence to the project style guide. | |||
1. Commit your changes and push them to your forked repository. | |||
1. Submit a pull request to the main repository. | |||
|
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 can't comment lower where it's talked about, but do we give folks steps for setting up ruff? IMO having a "run these lines of code and it will make your dev environment work" really helpful.
Alternatively / in addition: this is something we could trigger a bot on a comment and then CI deals with having an env setup. I've found this pattern to be suuuuper helpful for drop-by contributors
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.
Ruff is installed as part of make deps
(which is part of default make
). I'll update the README to make this obvious.
CI runs make lint
and will fail if there are errors. My assumption is a contributor would be able to figure things out from there.
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.
My assumption is a contributor would be able to figure things out from there.
IME, this works sometimes, but not always.
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.
IME, this works sometimes, but not always.
Sure. We can add more context if needed in the future. I believe there are GitHub Actions that will annotate the source code with lining errors.
No description provided.