mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
[mypy] Enforcing typing for some modules (#9416)
Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
@@ -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"])
|
||||
|
||||
Reference in New Issue
Block a user