[typing] Add sys check guard for typing.Self for python < 3.11 (#2911)

Closes #2910
3 files changed