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

Add Pre-Commit Python Linting #44

Merged
merged 2 commits into from
Jun 7, 2024
Merged

Conversation

hello-amal
Copy link
Collaborator

@hello-amal hello-amal commented May 21, 2024

Description

This PR, in partial service of #43 , builds off of #42 to add Python linting to the pre-commit hooks.

Testing procedure

  • Re-run all tests from Add Pre-Commit Hooks #42 with the following Stretch Configurations:
    • Stretch RE2 + no dex wrist w/ beta teleop kit
    • Stretch RE2 + dex wrist w/ beta teleop kit
    • Stretch RE2 + dex wrist w/ d405
    • Stretch 3 + current teleop kit + dex wrist

Before opening a pull request

From the top-level of this repository, run:

  • pre-commit run --all-files

To merge

  • Squash & Merge

@hello-binit
Copy link
Collaborator

What are your thoughts on flake8 vs Black for linting Python code?

@hello-amal
Copy link
Collaborator Author

hello-amal commented Jun 3, 2024

They are complementary. black is a formatter, so it automatically formats the code (e.g., for readability and consistency). flake8 is a linter, so it points out potential style and syntax errors. There are some overlaps (like with line length), but generally both are useful. For example, a linter will point out things like a missing import, an unused import/variable, catching too broad of an exception, etc., which a formatter will not.

@hello-binit
Copy link
Collaborator

Gotcha, so this PR adds the linter and optional type checking (with Mypy), but not the formatter. Is that correct?

@hello-amal
Copy link
Collaborator Author

Yes. The previous PR (#42 ) added the formatter.

The reason I split it up this way is that the formatter is guaranteed to not change code functionality. Whereas when I implement linting fixes, it is possible to change code functionality. So I wanted them to be in two separate PRs, to be able to more easily test and compare the diff.

@hello-binit
Copy link
Collaborator

Great, that makes sense. Since you've confirmed that no functionality is broken from the changes in these large PRs, I've approved these two PRs (#42 and this one). Are you planning on merging them into mainline?

@hello-amal
Copy link
Collaborator Author

Yes I'll merge them. I'm just waiting on to test it on a Stretch 2 without a dex wrist, and will then merge them in.

@hello-binit
Copy link
Collaborator

Cool! I have one, so I can test this next week if you need it.

Base automatically changed from amaln/pre_commit to master June 4, 2024 20:33
@hello-amal
Copy link
Collaborator Author

hello-amal commented Jun 7, 2024

Merging without testing on the "Stretch RE2 + no dex wrist w/ beta teleop kit" configuration because:

  1. I've double-checked the code, plus we've already tested with the beta teleop kit, so I'm fairly confident that it is unlikely to break that test case.
  2. We haven't yet been able to procure that specific configuration.
  3. Few users still use that configuration.

@hello-amal hello-amal merged commit 99eb857 into master Jun 7, 2024
1 check passed
@hello-amal hello-amal deleted the amaln/pre_commit_linting branch June 7, 2024 17:56
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.

2 participants