Skip to content

Some miscellaneous Ruff fixes - #7697

Merged
mekarpeles merged 1 commit into
internetarchive:masterfrom
cclauss:misc-fixes
Mar 21, 2023
Merged

mekarpeles merged 1 commit into
internetarchive:masterfrom
cclauss:misc-fixes

Conversation

@cclauss

@cclauss cclauss commented Mar 21, 2023

Copy link
Copy Markdown
Contributor

Closes #

ruff --fix enables us to clean up our code. Not all rules should be fixed up but my sense is that these ones are OK. I picked some rules that only have less than a handful of instances in our codebase.

ruff --select=B010,B011,C400,C406,C416,D208,D210,D211,PIE802,PIE807,PLR0402,PLR1711,RET501,UP031 --statistics .

1	B010   	[*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access.
1	B011   	[*] Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`
1	C400   	[*] Unnecessary generator (rewrite as a `list` comprehension)
1	C406   	[*] Unnecessary `tuple` literal (rewrite as a `dict` literal)
3	C416   	[*] Unnecessary `list` comprehension (rewrite using `list()`)
2	D208   	[*] Docstring is over-indented
3	D210   	[*] No whitespaces allowed surrounding docstring text
2	D211   	[*] No blank lines allowed before class docstring
3	PIE802 	[*] Unnecessary list comprehension.
1	PIE807 	[*] Prefer `list` over useless lambda
1	PLR0402	[*] Use `from os import path` in lieu of alias
1	PLR1711	[*] Useless `return` statement at the end of a function
3	RET501 	[*] Do not explicitly `return None` in function if it is the only possible return value
2	UP031  	[*] Use format specifiers instead of percent format

Technical

Testing

Screenshot

Stakeholders

"v.transaction_id=t.id AND t.created >= '{}' and t.created < '{}' AND "
"t.author_id IN (SELECT thing_id FROM account WHERE bot = 't')".format(
start, end
)

@cclauss cclauss Mar 21, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is there a security reason not to use str.format() in SQL queries?

@mekarpeles
mekarpeles merged commit 7582534 into internetarchive:master Mar 21, 2023
@cclauss
cclauss deleted the misc-fixes branch March 21, 2023 19:39
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