[Misc] Fix Python issues marked by Ruff CI job
Description
Fixes a number of issues marked by Ruff and ensures the corresponding CI job is not allowed to fail anymore.
Checklist
-
Documentation reflects the changes made. -
Merge Request title is clear, concise, and suitable as a changelog entry. See our contributing docs
References
Closes #1418 (closed)