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

dev: Add Ruff to API, enable F541 as first rule #555

Merged
merged 3 commits into from
May 10, 2024
Merged

Conversation

ajay-sentry
Copy link
Contributor

@ajay-sentry ajay-sentry commented May 10, 2024

Purpose/Motivation

Part of https://www.notion.so/sentry/Migrating-to-Ruff-bf528650b6d14fad8cb9964da7cafcbe proposal, we are moving over to using Ruff for linting and formatting, deprecating isort and black in the process.

This PR simply plugs in ruff into our make lint command and enables a single rule https://docs.astral.sh/ruff/rules/f-string-missing-placeholders/

Links to relevant tickets

closes codecov/engineering-team#1719

What does this PR do?

Adds ruff.toml, which is basically our ruff configuration file that is checked against when running the make command. This will allow us to easily update configuration in the future without having to muddy the make command as we add more rules.

Updates the make lint, make install, and make run commands to be Ruff specific, deprecating use of isort and black.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@ajay-sentry ajay-sentry requested review from a team as code owners May 10, 2024 14:05
Copy link

codecov bot commented May 10, 2024

Codecov Report

Attention: Patch coverage is 88.23529% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 95.82%. Comparing base (5aa4b11) to head (5eee349).

Changes have been made to critical files, which contain lines commonly executed in production. Learn more

✅ All tests successful. No failed tests found.

Files Patch % Lines
billing/views.py 0.00% 1 Missing ⚠️
upload/helpers.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #555     +/-   ##
=======================================
+ Coverage   95.81   95.82   +0.01     
=======================================
  Files        777     777             
  Lines      17267   17265      -2     
=======================================
- Hits       16544   16543      -1     
+ Misses       723     722      -1     
Flag Coverage Δ
unit 91.32% <88.23%> (-0.01%) ⬇️
unit-latest-uploader 91.32% <88.23%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

echo "Installing..."
pip install -Iv black==22.3.0 isort
pip install -Iv ruff

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this file the only non auto generated change in the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and the ruff.toml which has some slight tweaks from the default here: https://docs.astral.sh/ruff/configuration/

Copy link
Contributor

Choose a reason for hiding this comment

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

Are the rules same as the the worker repo?

Copy link
Contributor

Choose a reason for hiding this comment

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

worker is more or less using the default except for the extra linting of F401. It's good that you added the ruff.toml file!

Copy link
Contributor

@JerrySentry JerrySentry left a comment

Choose a reason for hiding this comment

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

lgtm

@codecov-qa
Copy link

codecov-qa bot commented May 10, 2024

Codecov Report

Attention: Patch coverage is 88.23529% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 91.32%. Comparing base (5aa4b11) to head (5eee349).

✅ All tests successful. No failed tests found.

Files Patch % Lines
billing/views.py 0.00% 1 Missing ⚠️
upload/helpers.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #555      +/-   ##
==========================================
- Coverage   91.32%   91.32%   -0.01%     
==========================================
  Files         599      599              
  Lines       15948    15947       -1     
==========================================
- Hits        14565    14564       -1     
  Misses       1383     1383              
Flag Coverage Δ
unit 91.32% <88.23%> (-0.01%) ⬇️
unit-latest-uploader 91.32% <88.23%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@codecov-notifications
Copy link

Codecov Report

Attention: Patch coverage is 88.23529% with 2 lines in your changes are missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files Patch % Lines
billing/views.py 0.00% 1 Missing ⚠️
upload/helpers.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link

Codecov Report

Attention: Patch coverage is 88.23529% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 91.32%. Comparing base (5aa4b11) to head (5eee349).

✅ All tests successful. No failed tests found ☺️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #555      +/-   ##
==========================================
- Coverage   91.32%   91.32%   -0.01%     
==========================================
  Files         599      599              
  Lines       15948    15947       -1     
==========================================
- Hits        14565    14564       -1     
  Misses       1383     1383              
Flag Coverage Δ
unit 91.32% <88.23%> (-0.01%) ⬇️
unit-latest-uploader 91.32% <88.23%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
api/internal/feature/views.py 96.49% <100.00%> (ø)
api/internal/owner/serializers.py 99.01% <ø> (ø)
api/shared/compare/mixins.py 98.64% <ø> (ø)
api/shared/compare/serializers.py 100.00% <ø> (ø)
api/shared/permissions.py 98.83% <100.00%> (-0.02%) ⬇️
billing/migrations/0001_initial.py 100.00% <ø> (ø)
codecov/admin.py 91.11% <100.00%> (ø)
codecov_auth/admin.py 100.00% <ø> (ø)
codecov_auth/migrations/0001_initial.py 0.00% <ø> (ø)
codecov_auth/migrations/0002_auto_20210817_1346.py 0.00% <ø> (ø)
... and 123 more

Impacted file tree graph

Copy link
Contributor

@michelletran-codecov michelletran-codecov left a comment

Choose a reason for hiding this comment

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

🚀

@ajay-sentry ajay-sentry added this pull request to the merge queue May 10, 2024
Merged via the queue into main with commit 7fc9bc5 May 10, 2024
14 of 22 checks passed
@ajay-sentry ajay-sentry deleted the Ajay/ruff-for-api branch May 10, 2024 14:53
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.

Add Ruff to API
3 participants