Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ Greenify pylint (after Pydantic v2 migration) #6747

Merged
5 changes: 0 additions & 5 deletions packages/aws-library/src/aws_library/s3/_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,20 @@ class S3NotConnectedError(S3RuntimeError):


class S3AccessError(S3RuntimeError):
code = "s3_access.error" # type: ignore[assignment]
msg_template: str = "Unexpected error while accessing S3 backend"


class S3BucketInvalidError(S3AccessError):
code = "s3_bucket.invalid_error" # type: ignore[assignment]
msg_template: str = "The bucket '{bucket}' is invalid"


class S3KeyNotFoundError(S3AccessError):
code = "s3_key.not_found_error" # type: ignore[assignment]
msg_template: str = "The file {key} in {bucket} was not found"


class S3UploadNotFoundError(S3AccessError):
code = "s3_upload.not_found_error" # type: ignore[assignment]
msg_template: str = "The upload for {key} in {bucket} was not found"


class S3DestinationNotEmptyError(S3AccessError):
code = "s3_destination.not_empty_error" # type: ignore[assignment]
msg_template: str = "The destination {dst_prefix} is not empty"
2 changes: 0 additions & 2 deletions packages/common-library/tests/test_errors_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,10 @@ class MyValueError(MyBaseError, ValueError):
assert f"{error}" == "Wrong value 42"

class MyTypeError(MyBaseError, TypeError):
code = "i_want_this"
msg_template = "Wrong type {type}"

error = MyTypeError(type="int")

assert error.code == "i_want_this"
assert f"{error}" == "Wrong type int"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@


class TaskValueError(OsparcErrorMixin, ValueError):
code = "task.value_error" # type: ignore[assignment]
...


class TaskCancelledError(OsparcErrorMixin, RuntimeError):
code = "task.cancelled_error" # type: ignore[assignment]
msg_template = "The task was cancelled"


class ServiceRuntimeError(OsparcErrorMixin, RuntimeError):
code = "service.runtime_error" # type: ignore[assignment]
msg_template = (
"The service {service_key}:{service_version}"
" running in container {container_id} failed with code"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ def regex_pattern(self) -> str:
if self.oneOf:
msg = "Current version cannot compute regex patterns in case of oneOf. Please go ahead and implement it yourself."
raise NotImplementedError(msg)
if self.anyOf:
if self.anyOf is not None:
return "|".join(
[
elm.regex_pattern
for elm in self.anyOf # pylint:disable=not-an-iterable
]
)
if self.allOf:
if self.allOf is not None:
return "&".join(
[
elm.regex_pattern
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@


class PortValueError(OsparcErrorMixin, ValueError):
code = "port_validation.schema_error" # type: ignore
msg_template = "Invalid value in port {port_key!r}: {schema_error_message}"

# pylint: disable=useless-super-delegation
Expand All @@ -38,7 +37,6 @@ def __init__(self, *, port_key: str, schema_error: JsonSchemaValidationError):


class PortUnitError(OsparcErrorMixin, ValueError):
code = "port_validation.unit_error" # type: ignore
msg_template = "Invalid unit in port {port_key!r}: {pint_error_msg}"

# pylint: disable=useless-super-delegation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,13 @@ def get_errors(self) -> list[ErrorDict]:
class MissingComputationalResourcesError(TaskSchedulingError):
"""A task cannot be scheduled because the cluster does not have the required resources"""

code = "scheduler_error.missing_resources"

def __init__(self, project_id: ProjectID, node_id: NodeID, msg: str | None = None):
super().__init__(project_id, node_id, msg=msg)


class InsuficientComputationalResourcesError(TaskSchedulingError):
"""A task cannot be scheduled because the cluster does not have *enough* of the required resources"""

code = "scheduler_error.insuficient_resources"

def __init__(self, project_id: ProjectID, node_id: NodeID, msg: str | None = None):
super().__init__(project_id, node_id, msg=msg)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@ class LegacyServiceIsNotSupportedError(DirectorError):


class UnexpectedContainerStatusError(OsparcErrorMixin, DynamicSidecarError):
code = "dynamic_sidecar.container_status" # type: ignore
msg_template = "Unexpected status from containers: {containers_with_error}"
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class BaseDynamicSchedulerError(OsparcErrorMixin, ValueError):
code = "simcore.service.dynamic.scheduler" # type:ignore[assignment]
...
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, message: str, status_code: int) -> None:


class BaseError(OsparcErrorMixin, BaseDynamicSidecarError):
code = "dy_sidecar.error" # type: ignore[assignment]
...


class ContainerExecContainerNotFoundError(BaseError):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class BaseServicesPreferencesError(OsparcErrorMixin, Exception):
code = "dynamic_sidecar.user_service_preferences" # type: ignore[assignment]
...


class DestinationIsNotADirectoryError(BaseServicesPreferencesError):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,18 @@ class StudyDispatcherError(WebServerBaseError, ValueError):


class IncompatibleService(StudyDispatcherError):
code = "studies_dispatcher.incompatible_service" # type: ignore
msg_template = "None of the registered services can handle '{file_type}'"


class FileToLarge(StudyDispatcherError):
code = "studies_dispatcher.file_to_large" # type: ignore
msg_template = "File size {file_size_in_mb} MB is over allowed limit"


class ServiceNotFound(StudyDispatcherError):
code = "studies_dispatcher.service_not_found" # type: ignore
msg_template = "Service {service_key}:{service_version} not found"


class InvalidRedirectionParams(StudyDispatcherError):
code = "studies_dispatcher.invalid_redirection_params" # type: ignore
msg_template = (
"The link you provided is invalid because it doesn't contain any information related to data or a service."
" Please check the link and make sure it is correct."
Expand Down
Loading