Closed cclauss closed 3 months ago
If you want to submit the patch related code style issue, would you like to submit the patch including the CI works? cc @vstinner
@cclauss cclauss closed
This change combines many different changes. Some of them are uncontroversial, I have an opinion on the others :-)
I understand.
These PRs are super easy to create locally with syntax like:
% ruff check --select=UP004 --fix
I'm fine with these changes, coming from the old time when pyperf worked on Python 2:
10 UP004 [*] Class `BaseTestCase` inherits from `object`
1 UP009 [*] UTF-8 encoding declaration is unnecessary
1 UP020 [*] Use builtin `open`
18 UP024 [*] Replace aliased errors with `OSError`
9 UP025 [*] Remove unicode literals from strings
Merged, thanks.
%
ruff check --select=UP --ignore=UP015,UP031 --statistics | sort -k2
%
ruff rule UP024
os-error-alias (UP024)
Derived from the pyupgrade linter.
Fix is always available.
What it does
Checks for uses of exceptions that alias
OSError
.Why is this bad?
OSError
is the builtin error type used for exceptions that relate to the operating system.In Python 3.3, a variety of other exceptions, like
WindowsError
were aliased toOSError
. These aliases remain in place for compatibility with older versions of Python, but may be removed in future versions.Prefer using
OSError
directly, as it is more idiomatic and future-proof.Example
Use instead:
References
OSError