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 ruff rules A,B,C4,EM,ISC,PERF,PGH,RET,RUF,S,SIM,SLF #549

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Feb 24, 2025

Copy link

codecov bot commented Feb 24, 2025

Codecov Report

Attention: Patch coverage is 57.74648% with 30 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@f5fd6fc). Learn more about missing BASE report.

Files with missing lines Patch % Lines
waffle/management/commands/waffle_flag.py 27.27% 8 Missing ⚠️
waffle/__init__.py 0.00% 6 Missing ⚠️
waffle/management/commands/waffle_sample.py 37.50% 5 Missing ⚠️
waffle/management/commands/waffle_switch.py 50.00% 4 Missing ⚠️
waffle/templatetags/waffle_tags.py 0.00% 2 Missing ⚠️
waffle/tests/test_middleware.py 0.00% 2 Missing ⚠️
waffle/admin.py 80.00% 1 Missing ⚠️
waffle/managers.py 0.00% 1 Missing ⚠️
waffle/utils.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master     #549   +/-   ##
=========================================
  Coverage          ?   95.42%           
=========================================
  Files             ?       36           
  Lines             ?     2450           
  Branches          ?        0           
=========================================
  Hits              ?     2338           
  Misses            ?      112           
  Partials          ?        0           

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

"F", # Pyflakes
"FIX", # flake8-fixme
"FLY", # flynt
"G", # flake8-logging-format
"ICN", # flake8-import-conventions
"INP", # flake8-no-pep420
"INT", # flake8-gettext
"ISC", # flake8-implicit-str-concat
Copy link
Contributor

Choose a reason for hiding this comment

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

The above lints look useful to me in that the changes made to make the lints pass mostly look like useful improvements. The possible exception to my mind is defining a msg variable before raising the exception - I am ambivalent to that one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

% ruff rule EM101

Why is this bad?
By using a string literal, the error message will be duplicated in the traceback, which can make the traceback less readable.

If you would like, we can revert the EM transformations.

% ruff check --select=EM--statistics

10	EM101  	[*] raw-string-in-exception
 6	EM102  	[*] f-string-in-exception
[*] fixable with `ruff check --fix`

"NPY", # NumPy-specific rules
"PD", # pandas-vet
"PERF", # Perflint
Copy link
Contributor

Choose a reason for hiding this comment

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

perflint describes itself as "This project is an early beta. It will likely raise many false-positives in your code" - you have previously said that you think any and all passing lints should be included - more is necessarily better.
I am worried that new linting raises the bar for new contributors, making it harder to get started - linting has advantages and disadvantages.
If any lints should be excluded then I think this one should, given the warning from its creator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This pull request did not make any PERF-related changes (other than enabling PERF).

When I read the Why is this bad? section of these rule I see quantified performance gains.

Here we are not running perflint. Instead, we are running ruff which uses the original project as inspiration but rewrites each rule that the project team deems valuable in Rust. Often useless or conflicting rules are dropped. There is active discussion in the ruff repo about which rules to adopt and which to drop.

If you would like, we can disable the PERF rules.

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