mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-20 05:23:44 +00:00
remove workaround for an issue addressed in latest mypy (#455)
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user