Skip to content

Commit

Permalink
fix: Apply mypy 0.920 update (#104)
Browse files Browse the repository at this point in the history
* setup: Upgrade mypy to 0.920
* fix: Remove bogus type-casting
* fix: Call `__init__()` as a classmethod
  • Loading branch information
achimnol committed Dec 18, 2021
1 parent 40b49b4 commit 686d6b7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions changes/104.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix minor typing errors discovered by mypy 0.920 update
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/ai/backend/common/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/ai/backend/common/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 686d6b7

Please sign in to comment.