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

Apply some ruff C4,UP,W fixes #75

Merged
merged 1 commit into from
Sep 26, 2023
Merged

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Sep 20, 2023

% pipx run ruff --select=C,UP,W --statistics .

6	C408 	[*] Unnecessary `dict` call (rewrite as a literal)
3	UP005	[*] `assertEquals` is deprecated, use `assertEqual`
2	UP004	[*] Class `Request` inherits from `object`
2	UP008	[*] Use `super()` instead of `super(__class__, self)`
2	UP030	[*] Use implicit references for positional format fields
1	W291 	[*] Trailing whitespace
1	UP009	[*] UTF-8 encoding declaration is unnecessary
1	UP010	[*] Unnecessary `__future__` import `unicode_literals` for target Python version

% pipx run ruff --select=C,UP,W --fix .

Found 18 errors (18 fixed, 0 remaining).

% pipx run ruff rule C408

unnecessary-collection-call (C408)

Derived from the flake8-comprehensions linter.

Autofix is always available.

What it does

Checks for unnecessary dict, list or tuple calls that can be
rewritten as empty literals.

Why is this bad?

It's unnecessary to call e.g., dict() as opposed to using an empty
literal ({}). The former is slower because the name dict must be
looked up in the global scope in case it has been rebound.

Examples

dict()
dict(a=1, b=2)
list()
tuple()

Use instead:

{}
{"a": 1, "b": 2}
[]
()

@nicholasserra
Copy link
Collaborator

Thanks!

@nicholasserra nicholasserra merged commit 543f300 into revsys:master Sep 26, 2023
17 checks passed
@cclauss cclauss deleted the more-ruff branch September 26, 2023 03: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.

2 participants