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

@ -106,7 +106,7 @@ jobs:
isort --profile black ./onefuzz ./examples/ ./tests/ --check isort --profile black ./onefuzz ./examples/ ./tests/ --check
pytest -v tests pytest -v tests
../ci/disable-py-cache.sh ../ci/disable-py-cache.sh
mypy . --ignore-missing-imports mypy --ignore-missing-imports ./onefuzz ./examples ./tests
# set a minimum confidence to ignore known false positives # set a minimum confidence to ignore known false positives
vulture --min-confidence 61 onefuzz vulture --min-confidence 61 onefuzz

View File

@ -4,7 +4,7 @@
# Licensed under the MIT License. # Licensed under the MIT License.
from enum import Enum from enum import Enum
from typing import Any, Dict, NewType, Union, cast from typing import Any, Dict, NewType, Union
from uuid import UUID from uuid import UUID
from onefuzztypes.validators import check_alnum, check_alnum_dash from onefuzztypes.validators import check_alnum, check_alnum_dash
@ -15,30 +15,22 @@ Directory = NewType("Directory", str)
File = NewType("File", 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): class Region(str):
def __new__(cls, value: str) -> "Region": def __new__(cls, value: str) -> "Region":
check_alnum(value) check_alnum(value)
obj = super().__new__(cls, value) # type: ignore obj = super().__new__(cls, value)
return cast(Region, obj) return obj
class Container(str): class Container(str):
def __new__(cls, value: str) -> "Container": def __new__(cls, value: str) -> "Container":
check_alnum_dash(value) check_alnum_dash(value)
obj = super().__new__(cls, value) # type: ignore obj = super().__new__(cls, value)
return cast(Container, obj) return obj
class PoolName(str): class PoolName(str):
def __new__(cls, value: str) -> "PoolName": def __new__(cls, value: str) -> "PoolName":
check_alnum_dash(value) check_alnum_dash(value)
obj = super().__new__(cls, value) # type: ignore obj = super().__new__(cls, value)
return cast(PoolName, obj) return obj