From 47ca0b475a3515dde00f7dd461e0b907f3c14405 Mon Sep 17 00:00:00 2001 From: Joongi Kim Date: Sat, 18 Dec 2021 02:49:27 +0000 Subject: [PATCH 1/5] setup: Upgrade mypy to 0.920 --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 25f38dc7..0af12eda 100644 --- a/setup.cfg +++ b/setup.cfg @@ -83,7 +83,7 @@ lint = flake8>=4.0.1 flake8-commas>=2.1 typecheck = - mypy>=0.910 + mypy>=0.920 types-python-dateutil types-toml types-setuptools From ae5f43fa46999654f29cb1e98e14f40f2abd1592 Mon Sep 17 00:00:00 2001 From: Joongi Kim Date: Sat, 18 Dec 2021 02:49:37 +0000 Subject: [PATCH 2/5] fix: Remove bogus type-casting --- src/ai/backend/common/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ai/backend/common/cli.py b/src/ai/backend/common/cli.py index 415e8f20..33b6cd55 100644 --- a/src/ai/backend/common/cli.py +++ b/src/ai/backend/common/cli.py @@ -58,7 +58,7 @@ class EnumChoice(click.Choice): enum: Type[Enum] def __init__(self, enum: Type[Enum]): - super().__init__([*cast(Enum, enum)._member_map_.keys()]) + super().__init__([*enum._member_map_.keys()]) self.enum = enum def convert(self, value: Any, param, ctx): From 0aab37ca08ae223d1debcc620064f2141d2bf893 Mon Sep 17 00:00:00 2001 From: Joongi Kim Date: Sat, 18 Dec 2021 02:51:17 +0000 Subject: [PATCH 3/5] fix: Call `__init__()` as a classmethod --- src/ai/backend/common/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ai/backend/common/types.py b/src/ai/backend/common/types.py index da063d4f..fa49473f 100644 --- a/src/ai/backend/common/types.py +++ b/src/ai/backend/common/types.py @@ -99,7 +99,7 @@ async def new(cls: Type[T_aobj], *args, **kwargs) -> T_aobj: This is a copy of ``__new__()`` to workaround it. ''' instance = super().__new__(cls) - instance.__init__(*args, **kwargs) + cls.__init__(instance, *args, **kwargs) await instance.__ainit__() return instance From e781449440ca9dc04e49b0ddcbdc8454fffdc32e Mon Sep 17 00:00:00 2001 From: Joongi Kim Date: Sat, 18 Dec 2021 02:53:22 +0000 Subject: [PATCH 4/5] docs: Add news fragment --- changes/104.fix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/104.fix diff --git a/changes/104.fix b/changes/104.fix new file mode 100644 index 00000000..eb79f4b0 --- /dev/null +++ b/changes/104.fix @@ -0,0 +1 @@ +Fix minor typing errors discovered by mypy 0.920 update From efc45b5af4b8387133bd651d98e32b6f554d329c Mon Sep 17 00:00:00 2001 From: Joongi Kim Date: Sat, 18 Dec 2021 03:38:44 +0000 Subject: [PATCH 5/5] fix: lint error --- src/ai/backend/common/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ai/backend/common/cli.py b/src/ai/backend/common/cli.py index 33b6cd55..90347b78 100644 --- a/src/ai/backend/common/cli.py +++ b/src/ai/backend/common/cli.py @@ -4,7 +4,7 @@ from importlib import import_module import re from types import FunctionType -from typing import Any, Optional, Union, Type, cast +from typing import Any, Optional, Union, Type import click