Use more precise exception types in `assertRaises` in typing tests (GH-98650)

(cherry picked from commit 45c89358b71e4638455e75ba6e60b42c511bbc2a)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
1 file changed