remove workaround for an issue addressed in latest mypy (#455)

This commit is contained in:
bmc-msft
2021-01-22 14:00:35 -05:00
committed by GitHub
parent 3c76baa3bb
commit c0a4b0dba4
2 changed files with 8 additions and 16 deletions

View File

@ -4,7 +4,7 @@
# Licensed under the MIT License.
from enum import Enum
from typing import Any, Dict, NewType, Union, cast
from typing import Any, Dict, NewType, Union
from uuid import UUID
from onefuzztypes.validators import check_alnum, check_alnum_dash
@ -15,30 +15,22 @@ Directory = NewType("Directory", str)
File = NewType("File", str)
# We ignore typing for the following super().__new__ calls
# specifically because mypy does not handle subclassing
# builtins well. As is, mypy generates the error
# 'Too many arguments for "__new__" of "object"'
#
# However, this works in practice.
class Region(str):
def __new__(cls, value: str) -> "Region":
check_alnum(value)
obj = super().__new__(cls, value) # type: ignore
return cast(Region, obj)
obj = super().__new__(cls, value)
return obj
class Container(str):
def __new__(cls, value: str) -> "Container":
check_alnum_dash(value)
obj = super().__new__(cls, value) # type: ignore
return cast(Container, obj)
obj = super().__new__(cls, value)
return obj
class PoolName(str):
def __new__(cls, value: str) -> "PoolName":
check_alnum_dash(value)
obj = super().__new__(cls, value) # type: ignore
return cast(PoolName, obj)
obj = super().__new__(cls, value)
return obj