gh-36462: using ruff for UP004, UP008, UP028
this was scripted using
`ruff check --fix --select UP004,UP008,UP028 src/sage`
here is the link to `ruff` documentation:
https://docs.astral.sh/ruff/rules/
### :memo: Checklist
- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
URL: https://github.com/sagemath/sage/pull/36462
Reported by: Frédéric Chapoton
Reviewer(s): Kwankyu Lee