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

build: add import formatting with autoflake and isort #247

Merged
merged 8 commits into from
Jul 29, 2024

Conversation

tdstein
Copy link
Collaborator

@tdstein tdstein commented Jul 26, 2024

No description provided.

Copy link

github-actions bot commented Jul 26, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
1227 1158 94% 0% 🟢

New Files

No new covered files...

Modified Files

No covered modified files...

updated for commit: 5acdd24 by action🐍

Makefile Outdated Show resolved Hide resolved
Makefile Outdated
fmt:
$(PYTHON) -m autoflake --remove-all-unused-imports --in-place --recursive .

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).

Copy link
Collaborator Author

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.

Base automatically changed from tdstein/cleanup-imports to main July 29, 2024 13:56
@tdstein tdstein force-pushed the tdstein/add-import-organization-to-fmt branch from ceb3331 to 5acdd24 Compare July 29, 2024 14:11
@tdstein tdstein merged commit b04a500 into main Jul 29, 2024
30 checks passed
@tdstein tdstein deleted the tdstein/add-import-organization-to-fmt branch July 29, 2024 14:19
@@ -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.

Copy link
Collaborator

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

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

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

Successfully merging this pull request may close these issues.

4 participants