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 PERF rules, fix E711 and F841 #624

Merged
merged 3 commits into from
Jun 20, 2024

Conversation

ajay-sentry
Copy link
Contributor

@ajay-sentry ajay-sentry commented Jun 19, 2024

Purpose/Motivation

Part of the lint enhancement epic, this PR aims to add the Perflint PERF rules, and fix E711 and F841, which are for Comparison to None should be cond is None and Local variable {name} is assigned to but never used respectively.

These can be found here:

Links to relevant tickets

Closes codecov/engineering-team#1965

What does this PR do?

This PR adds the rules listed above and fixes any errors that stemmed from them.

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 June 19, 2024 00:23
@codecov-staging
Copy link

codecov-staging bot commented Jun 19, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 3 lines in your changes missing coverage. Please review.

Files Patch % Lines
upload/helpers.py 0.00% 2 Missing ⚠️
open_telemetry.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Jun 19, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 3 lines in your changes missing coverage. Please review.

Project coverage is 91.52%. Comparing base (8ab87fd) to head (066b40c).

✅ All tests successful. No failed tests found.

@@           Coverage Diff           @@
##             main     #624   +/-   ##
=======================================
  Coverage   91.51%   91.52%           
=======================================
  Files         620      620           
  Lines       16478    16469    -9     
=======================================
- Hits        15080    15073    -7     
+ Misses       1398     1396    -2     
Flag Coverage Δ
unit 91.52% <83.33%> (+<0.01%) ⬆️
unit-latest-uploader 91.52% <83.33%> (+<0.01%) ⬆️

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

Files Coverage Δ
codecov_auth/authentication/repo_auth.py 96.87% <100.00%> (ø)
codecov_auth/views/base.py 99.08% <100.00%> (-0.01%) ⬇️
graphql_api/actions/commits.py 100.00% <100.00%> (ø)
graphql_api/helpers/lookahead.py 100.00% <100.00%> (ø)
graphql_api/types/pull/pull.py 100.00% <100.00%> (ø)
services/billing.py 92.44% <100.00%> (ø)
services/bundle_analysis.py 100.00% <100.00%> (ø)
services/report.py 96.63% <100.00%> (ø)
upload/tokenless/github_actions.py 98.36% <ø> (ø)
upload/tokenless/tokenless.py 100.00% <100.00%> (ø)
... and 5 more

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

Copy link

codecov bot commented Jun 19, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 3 lines in your changes missing coverage. Please review.

Project coverage is 95.94%. Comparing base (8ab87fd) to head (066b40c).

Files Patch % Lines
upload/helpers.py 0.00% 2 Missing ⚠️
open_telemetry.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##               main       #624        +/-   ##
================================================
+ Coverage   95.93000   95.94000   +0.01000     
================================================
  Files           798        798                
  Lines         17795      17786         -9     
================================================
- Hits          17072      17065         -7     
+ Misses          723        721         -2     
Flag Coverage Δ
unit 91.52% <83.33%> (+<0.01%) ⬆️
unit-latest-uploader 91.52% <83.33%> (+<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.

Copy link

codecov-public-qa bot commented Jun 19, 2024

Codecov Report

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

Project coverage is 91.52%. Comparing base (8ab87fd) to head (066b40c).

✅ All tests successful. No failed tests found ☺️

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #624   +/-   ##
=======================================
  Coverage   91.51%   91.52%           
=======================================
  Files         620      620           
  Lines       16478    16469    -9     
=======================================
- Hits        15080    15073    -7     
+ Misses       1398     1396    -2     
Flag Coverage Δ
unit 91.52% <83.33%> (+<0.01%) ⬆️
unit-latest-uploader 91.52% <83.33%> (+<0.01%) ⬆️

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

Files Coverage Δ
codecov_auth/authentication/repo_auth.py 96.87% <100.00%> (ø)
codecov_auth/views/base.py 99.08% <100.00%> (-0.01%) ⬇️
graphql_api/actions/commits.py 100.00% <100.00%> (ø)
graphql_api/helpers/lookahead.py 100.00% <100.00%> (ø)
graphql_api/types/pull/pull.py 100.00% <100.00%> (ø)
services/billing.py 92.44% <100.00%> (ø)
services/bundle_analysis.py 100.00% <100.00%> (ø)
services/report.py 96.63% <100.00%> (ø)
upload/tokenless/github_actions.py 98.36% <ø> (ø)
upload/tokenless/tokenless.py 100.00% <100.00%> (ø)
... and 5 more

Impacted file tree graph

@@ -262,9 +262,7 @@ def get_and_modify_owner(self, user_dict, request) -> Owner:
]

self._check_enterprise_organizations_membership(user_dict, formatted_orgs)
upserted_orgs = []
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perf 1

if coverage_status:
to_be_included = []
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perf 2

@@ -56,7 +56,7 @@ def _flatten_selections(self, selection_set: SelectionSetNode) -> Iterable[Node]
if isinstance(selection, FragmentSpreadNode):
fragment = self.info.fragments[selection.name.value]
for selection in fragment.selection_set.selections:
selections.append(selection)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Skipped Perf

@@ -419,16 +419,16 @@ def compute_report(
branch=self.branch,
)

results = []
for measurable_id in measurable_ids:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perf 4

@@ -29,7 +29,7 @@ def file_reports(self):
def flags(self):
"""returns dict(:name=<Flag>)"""
flags_dict = {}
for sid, session in self.sessions.items():
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perf 5

@ajay-sentry ajay-sentry added this pull request to the merge queue Jun 20, 2024
Merged via the queue into main with commit d37f5c7 Jun 20, 2024
17 of 22 checks passed
@ajay-sentry ajay-sentry deleted the Ajay/ruff-perf-and-E711-F841 branch June 20, 2024 17:44
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 Perf, Fix E711 and F841 to API
3 participants