Support ruff 0.5.0 in CI

Support ruff 0.5.0 in CI and revert:
- #7007

Fix #7008.