Skip to content

Commit

Permalink
Techdebt: MyPy ECR (#5943)
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers authored Feb 18, 2023
1 parent eb79d06 commit b241c16
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 215 deletions.
44 changes: 22 additions & 22 deletions moto/ecr/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
class LifecyclePolicyNotFoundException(JsonRESTError):
code = 400

def __init__(self, repository_name, registry_id):
def __init__(self, repository_name: str, registry_id: str):
super().__init__(
error_type=__class__.__name__,
error_type="LifecyclePolicyNotFoundException",
message=(
"Lifecycle policy does not exist "
f"for the repository with name '{repository_name}' "
Expand All @@ -18,19 +18,19 @@ def __init__(self, repository_name, registry_id):
class LimitExceededException(JsonRESTError):
code = 400

def __init__(self):
def __init__(self) -> None:
super().__init__(
error_type=__class__.__name__,
error_type="LimitExceededException",
message=("The scan quota per image has been exceeded. Wait and try again."),
)


class RegistryPolicyNotFoundException(JsonRESTError):
code = 400

def __init__(self, registry_id):
def __init__(self, registry_id: str):
super().__init__(
error_type=__class__.__name__,
error_type="RegistryPolicyNotFoundException",
message=(
f"Registry policy does not exist in the registry with id '{registry_id}'"
),
Expand All @@ -40,9 +40,9 @@ def __init__(self, registry_id):
class RepositoryAlreadyExistsException(JsonRESTError):
code = 400

def __init__(self, repository_name, registry_id):
def __init__(self, repository_name: str, registry_id: str):
super().__init__(
error_type=__class__.__name__,
error_type="RepositoryAlreadyExistsException",
message=(
f"The repository with name '{repository_name}' already exists "
f"in the registry with id '{registry_id}'"
Expand All @@ -53,9 +53,9 @@ def __init__(self, repository_name, registry_id):
class RepositoryNotEmptyException(JsonRESTError):
code = 400

def __init__(self, repository_name, registry_id):
def __init__(self, repository_name: str, registry_id: str):
super().__init__(
error_type=__class__.__name__,
error_type="RepositoryNotEmptyException",
message=(
f"The repository with name '{repository_name}' "
f"in registry with id '{registry_id}' "
Expand All @@ -67,9 +67,9 @@ def __init__(self, repository_name, registry_id):
class RepositoryNotFoundException(JsonRESTError):
code = 400

def __init__(self, repository_name, registry_id):
def __init__(self, repository_name: str, registry_id: str):
super().__init__(
error_type=__class__.__name__,
error_type="RepositoryNotFoundException",
message=(
f"The repository with name '{repository_name}' does not exist "
f"in the registry with id '{registry_id}'"
Expand All @@ -80,9 +80,9 @@ def __init__(self, repository_name, registry_id):
class RepositoryPolicyNotFoundException(JsonRESTError):
code = 400

def __init__(self, repository_name, registry_id):
def __init__(self, repository_name: str, registry_id: str):
super().__init__(
error_type=__class__.__name__,
error_type="RepositoryPolicyNotFoundException",
message=(
"Repository policy does not exist "
f"for the repository with name '{repository_name}' "
Expand All @@ -94,9 +94,9 @@ def __init__(self, repository_name, registry_id):
class ImageNotFoundException(JsonRESTError):
code = 400

def __init__(self, image_id, repository_name, registry_id):
def __init__(self, image_id: str, repository_name: str, registry_id: str):
super().__init__(
error_type=__class__.__name__,
error_type="ImageNotFoundException",
message=(
f"The image with imageId {image_id} does not exist "
f"within the repository with name '{repository_name}' "
Expand All @@ -108,16 +108,16 @@ def __init__(self, image_id, repository_name, registry_id):
class InvalidParameterException(JsonRESTError):
code = 400

def __init__(self, message):
super().__init__(error_type=__class__.__name__, message=message)
def __init__(self, message: str):
super().__init__(error_type="InvalidParameterException", message=message)


class ScanNotFoundException(JsonRESTError):
code = 400

def __init__(self, image_id, repository_name, registry_id):
def __init__(self, image_id: str, repository_name: str, registry_id: str):
super().__init__(
error_type=__class__.__name__,
error_type="ScanNotFoundException",
message=(
f"Image scan does not exist for the image with '{image_id}' "
f"in the repository with name '{repository_name}' "
Expand All @@ -129,5 +129,5 @@ def __init__(self, image_id, repository_name, registry_id):
class ValidationException(JsonRESTError):
code = 400

def __init__(self, message):
super().__init__(error_type=__class__.__name__, message=message)
def __init__(self, message: str):
super().__init__(error_type="ValidationException", message=message)
Loading

0 comments on commit b241c16

Please sign in to comment.