[Backport maintenance/4.0.x] Improve self argument typing (#2904)

Improve self argument typing (#2900)

(cherry picked from commit bf68bf895a411646f18c08ef7d5d34319d65fe11)

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