[mypy] Enforcing typing for some modules (#9416)

Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
John Bodley
2020-04-04 12:45:14 -07:00
committed by GitHub
parent 1cdfb829d7
commit 5e55e09e3e
10 changed files with 39 additions and 27 deletions

View File

@@ -25,10 +25,10 @@ from superset.exceptions import SupersetException
class CommandException(SupersetException):
""" Common base class for Command exceptions. """
def __repr__(self):
def __repr__(self) -> str:
if self._exception:
return self._exception
return self
return repr(self._exception)
return repr(self)
class CommandInvalidError(CommandException):
@@ -36,14 +36,14 @@ class CommandInvalidError(CommandException):
status = 422
def __init__(self, message="") -> None:
def __init__(self, message: str = "") -> None:
self._invalid_exceptions: List[ValidationError] = []
super().__init__(self.message)
def add(self, exception: ValidationError):
def add(self, exception: ValidationError) -> None:
self._invalid_exceptions.append(exception)
def add_list(self, exceptions: List[ValidationError]):
def add_list(self, exceptions: List[ValidationError]) -> None:
self._invalid_exceptions.extend(exceptions)
def normalized_messages(self) -> Dict[Any, Any]:
@@ -76,12 +76,12 @@ class ForbiddenError(CommandException):
class OwnersNotFoundValidationError(ValidationError):
status = 422
def __init__(self):
def __init__(self) -> None:
super().__init__(_("Owners are invalid"), field_names=["owners"])
class DatasourceNotFoundValidationError(ValidationError):
status = 404
def __init__(self):
def __init__(self) -> None:
super().__init__(_("Datasource does not exist"), field_names=["datasource_id"])