codecs: add missing function, reflect runtime import * (#7918)

This commit is contained in:
Jelle Zijlstra
2022-05-22 16:06:21 -07:00
committed by GitHub
parent 18433202ba
commit 9660ee97ee
5 changed files with 73 additions and 64 deletions

View File

@@ -0,0 +1,13 @@
# pyright: reportUnnecessaryTypeIgnoreComment=true
import codecs
from typing_extensions import assert_type
assert_type(codecs.decode("x", "unicode-escape"), str)
assert_type(codecs.decode(b"x", "unicode-escape"), str)
assert_type(codecs.decode(b"x", "utf-8"), str)
codecs.decode("x", "utf-8") # type: ignore[call-overload]
assert_type(codecs.decode("ab", "hex"), bytes)
assert_type(codecs.decode(b"ab", "hex"), bytes)