gh-36922: using less isinstance(..., Ring)
in favour of the more categorical `... in Rings()`
also fixing a few pep8 details in passing but not too much
### :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/36922
Reported by: Frédéric Chapoton
Reviewer(s): Frédéric Chapoton, Matthias Köppe, Travis Scrimshaw