Cleanup ruff ignores
Author: stefan6419846Created Jun 22, 2025Updated Sep 4, 2026
Labelsis-maintenance
We currently have lots of global ruff ignores in our pyproject.toml. These should be cleaned up where useful.
I have identified the following rules which we could/should fix instead of ignoring them:
- A001 (Variable is shadowing a Python builtin)
- A002 (Function argument is shadowing a Python builtin) - If changed, requires a deprecation process!
- B904 (Within an
exceptclause, raise exceptions with ...) - B905 (
zip()without an explicitstrict=parameter) - Can be removed directly. Will become relevant once we are targeting Python 3.10 as the parameter is new there. - BLE001 (Do not catch blind exception
Exception) - Keep the rule, but fix the tests! - DTZ001 (
datetime.datetime()called withouttzinfoargument) - Make sure that we actually know the timezone beforehand! - FA100 (Missing
from __future__ import annotations, but uses ...) - Lots of work - FA102 (Missing
from __future__ import annotations, but uses PEP 604 union) - Rule can be removed after configuring the checks to skip the sample-files directory. - FBT002 (Boolean default value in function definition) - If changed, requires a deprecation process!
- FBT003 (Boolean positional value in function call)
- G004 (f-string in logging statement)
- N806 (non-lowercase-variable-in-function)
- PGH003 (Use specific rule codes when ignoring type issues)
- PLW2901 (context statement variable overwritten by assignment target)
- PT011 (
pytest.raises(ValueError)is too broad, set thematch) - PT012 (
pytest.raises()block should contain a single simple statement) - PT014 (Duplicate of test case at index 1 in
pytest.mark.parametrize) - Exclude individually - PTH123 (
open()should be replaced byPath.open()) - PYI042 (Type alias should be CamelCase) - If used in public API, requires a deprecation process!
- RET503 (Missing explicit
returnat the end of function able to return non-Nonevalue) - S110 (
try-except-passdetected, consider logging the exception) - Needs further individual reviews! - SIM105 (Use
contextlib.suppress()) - Refactor where useful, consider rewriting tests to avoid it if required. - TC006 (Add quotes to type expression in
typing.cast()) - Requires discussion. - TRY002 (Create your own exception) - Requires further individual reviews!
- TRY004 (Prefer
TypeErrorexception for invalid type) - TRY201 (Use
raisewithout specifying exception name) - TRY300 (Consider moving this statement to an
elseblock) - Local ignores per module
External contributions are appreciated, but please try to keep the changes small by only handling one rule per PR.
Source: py-pdf/pypdf