Fix CI by temporarily pinning ruff < 0.5.0

As a hotfix for CI, temporarily pin ruff upper version < 0.5.0.

Fix #7006.

Revert once root cause is fixed.