diff --git a/mypy_extensions.py b/mypy_extensions.py index 891766b..8002360 100644 --- a/mypy_extensions.py +++ b/mypy_extensions.py @@ -220,6 +220,34 @@ def __new__(cls, x=0, base=_sentinel): return int(x) +class i8(metaclass=_NativeIntMeta): + def __new__(cls, x=0, base=_sentinel): + if base is not _sentinel: + return int(x, base) + return int(x) + + +class u64(metaclass=_NativeIntMeta): + def __new__(cls, x=0, base=_sentinel): + if base is not _sentinel: + return int(x, base) + return int(x) + + +class u32(metaclass=_NativeIntMeta): + def __new__(cls, x=0, base=_sentinel): + if base is not _sentinel: + return int(x, base) + return int(x) + + +class u16(metaclass=_NativeIntMeta): + def __new__(cls, x=0, base=_sentinel): + if base is not _sentinel: + return int(x, base) + return int(x) + + class u8(metaclass=_NativeIntMeta): def __new__(cls, x=0, base=_sentinel): if base is not _sentinel: @@ -227,7 +255,7 @@ def __new__(cls, x=0, base=_sentinel): return int(x) -for _int_type in i64, i32, i16, u8: +for _int_type in i64, i32, i16, i8, u64, u32, u16, u8: _int_type.__doc__ = \ """A native fixed-width integer type when used with mypyc. diff --git a/tests/testextensions.py b/tests/testextensions.py index 72a4a49..068d160 100644 --- a/tests/testextensions.py +++ b/tests/testextensions.py @@ -5,7 +5,7 @@ import warnings from contextlib import contextmanager from unittest import TestCase, main -from mypy_extensions import TypedDict, i64, i32, i16, u8 +from mypy_extensions import TypedDict, i64, i32, i16, i8, u64, u32, u16, u8 class BaseTestCase(TestCase): @@ -150,7 +150,7 @@ def test_total(self): self.assertEqual(Options.__total__, False) # noqa -native_int_types = [i64, i32, i16, u8] +native_int_types = [i64, i32, i16, i8, u64, u32, u16, u8] class MypycNativeIntTests(TestCase):