[Backport maintenance/4.0.x] Fix base class inference for dataclasses with PEP 695 syntax (#2919)

(cherry picked from commit 3774c0a788ca665ecd7d28a064e56651efc4a3c1)

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
3 files changed