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 code hygiene for python #660

Closed
wants to merge 8 commits into from

Conversation

peternied
Copy link
Member

Description

Add code hygiene checks for python, broken apart by the different projects within the repo.

Testing

New GitHub action is triggered on any changes via a pull request or push to the repository.

Check List

  • New functionality includes testing
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link

codecov bot commented May 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.51%. Comparing base (4ea97f1) to head (9739b1e).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##           main     #660       +/-   ##
=========================================
+ Coverage      0   91.51%   +91.51%     
=========================================
  Files         0       25       +25     
  Lines         0     1155     +1155     
  Branches      0      122      +122     
=========================================
+ Hits          0     1057     +1057     
- Misses        0       83       +83     
- Partials      0       15       +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member Author

@peternied peternied left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do folks think?

strategy:
fail-fast: false
matrix:
location:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we might have some dead code, should we delete some of these?

Comment on lines +53 to +56
- run: python3 -m pip install -r dev-requirements.txt
continue-on-error: true # Not all projects have dev-requirements.txt, safe to ignore
- run: python3 -m pip install -r requirements.txt
continue-on-error: true # Not all projects have requirements.txt, safe to ignore
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe replace these with a pipenv file?

Comment on lines +64 to +66
- id: mypy
continue-on-error: true # Success/failure checked in last job step
run: python3 -m mypy .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into mypy a bit and think I'm in favor of trying it out. I'd love to take a gradual approach here if possible. Maybe you have thoughts on the topic, but what about the following high level approach

  • Add mypy to the repo's Python packages
  • Make it easy to run mypy and other style checks locally before submitting your PR
  • Update READMEs as appropriate to document how to run the checks locally
  • Configure mypy to:
    • Error if a type annotation exists, but is wrong
    • Warn if a type annotation is missing, but not count it as a failure
    • Ignore missing type annotations from third-party, imported Python modules

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming all of the projects that I'm running this job over are code we care about - I'll fix all the errors to get us into a passing state before merging. How we handle different errors, such as missing type annotations can be done on a case-by-case basis.

Update READMEs as appropriate to document how to run the checks locally

For which README(s) should be updated, do we do this at the project level or individual project level?

@peternied
Copy link
Member Author

Since its been a while since I've put attention on this PR I'm going to close it out; if/when I get time I'll reopen this.

@peternied peternied closed this Jun 4, 2024
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