Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flask_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Increment versions here according to SemVer
__version__ = "0.7.0"
__version__ = "0.7.1"
Comment thread
Seluj78 marked this conversation as resolved.

from flask_utils.utils import is_it_true
from flask_utils.errors import GoneError
Expand Down
15 changes: 15 additions & 0 deletions flask_utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def _is_optional(type_hint: Type) -> bool: # type: ignore
"""Check if the type hint is :data:`~typing.Optional`.

:param type_hint: Type hint to check.
:type type_hint: Type

:return: True if the type hint is :data:`~typing.Optional`, False otherwise.
:rtype: bool

:Example:

Expand All @@ -62,7 +65,10 @@ def _make_optional(type_hint: Type) -> Type: # type: ignore
"""Wrap type hint with :data:`~typing.Optional` if it's not already.

:param type_hint: Type hint to wrap.
:type type_hint: Type

:return: Type hint wrapped with :data:`~typing.Optional`.
:rtype: Type

:Example:

Expand All @@ -85,10 +91,14 @@ def _is_allow_empty(value: Any, type_hint: Type, allow_empty: bool) -> bool: #
"""Determine if the value is considered empty and whether it's allowed.

:param value: Value to check.
:type value: Any
:param type_hint: Type hint to check against.
:type type_hint: Type
:param allow_empty: Whether to allow empty values.
:type allow_empty: bool

:return: True if the value is empty and allowed, False otherwise.
:rtype: bool

:Example:

Expand Down Expand Up @@ -118,11 +128,16 @@ def _check_type(value: Any, expected_type: Type, allow_empty: bool = False, curr
"""Check if the value matches the expected type, recursively if necessary.

:param value: Value to check.
:type value: Any
:param expected_type: Expected type.
:type expected_type: Type
:param allow_empty: Whether to allow empty values.
:type allow_empty: bool
:param curr_depth: Current depth of the recursive check.
:type curr_depth: int

:return: True if the value matches the expected type, False otherwise.
:rtype: bool

:Example:

Expand Down
2 changes: 2 additions & 0 deletions flask_utils/errors/badrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class BadRequestError(_BaseFlaskException):
When raised, it will return a 400 status code with the message and solution provided.

:param msg: The message to be displayed in the error.
:type msg: str
:param solution: The solution to the error.
:type solution: str
Comment thread
Seluj78 marked this conversation as resolved.
Outdated

:Example:

Expand Down
2 changes: 2 additions & 0 deletions flask_utils/errors/conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class ConflictError(_BaseFlaskException):
When raised, it will return a 409 status code with the message and solution provided.

:param msg: The message to be displayed in the error.
:type msg: str
:param solution: The solution to the error.
:type solution: str
Comment thread
Seluj78 marked this conversation as resolved.
Outdated

:Example:

Expand Down
2 changes: 2 additions & 0 deletions flask_utils/errors/failed_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class FailedDependencyError(_BaseFlaskException):
When raised, it will return a 424 status code with the message and solution provided.

:param msg: The message to be displayed in the error.
:type msg: str
:param solution: The solution to the error.
:type solution: str
Comment thread
Seluj78 marked this conversation as resolved.
Outdated

:Example:

Expand Down
2 changes: 2 additions & 0 deletions flask_utils/errors/forbidden.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class ForbiddenError(_BaseFlaskException):
When raised, it will return a 403 status code with the message and solution provided.

:param msg: The message to be displayed in the error.
:type msg: str
:param solution: The solution to the error.
:type solution: str
Comment thread
Seluj78 marked this conversation as resolved.
Outdated

:Example:

Expand Down
2 changes: 2 additions & 0 deletions flask_utils/errors/gone.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class GoneError(_BaseFlaskException):
When raised, it will return a 410 status code with the message and solution provided.

:param msg: The message to be displayed in the error.
:type msg: str
:param solution: The solution to the error.
:type solution: str
Comment thread
Seluj78 marked this conversation as resolved.
Outdated

:Example:

Expand Down
2 changes: 2 additions & 0 deletions flask_utils/errors/notfound.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class NotFoundError(_BaseFlaskException):
When raised, it will return 404 status code with the message and solution provided.

:param msg: The message to be displayed in the error.
:type msg: str
:param solution: The solution to the error.
:type solution: str

:Example:

Expand Down
2 changes: 2 additions & 0 deletions flask_utils/errors/origin_is_unreachable.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class OriginIsUnreachableError(_BaseFlaskException):
When raised, it will return a 523 status code with the message and solution provided.

:param msg: The message to be displayed in the error.
:type msg: str
:param solution: The solution to the error.
:type solution: str
Comment thread
Seluj78 marked this conversation as resolved.
Outdated

:Example:

Expand Down
2 changes: 2 additions & 0 deletions flask_utils/errors/service_unavailable.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class ServiceUnavailableError(_BaseFlaskException):
When raised, it will return a 503 status code with the message and solution provided.

:param msg: The message to be displayed in the error.
:type msg: str
:param solution: The solution to the error.
:type solution: str
Comment thread
Seluj78 marked this conversation as resolved.
Outdated

:Example:

Expand Down
2 changes: 2 additions & 0 deletions flask_utils/errors/unauthorized.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class UnauthorizedError(_BaseFlaskException):
When raised, it will return a 401 status code with the message and solution provided.

:param msg: The message to be displayed in the error.
:type msg: str
:param solution: The solution to the error.
:type solution: str
Comment thread
Seluj78 marked this conversation as resolved.
Outdated

:Example:

Expand Down
2 changes: 2 additions & 0 deletions flask_utils/errors/unprocessableentity.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class UnprocessableEntityError(_BaseFlaskException):
When raised, it will return a 422 status code with the message and solution provided.

:param msg: The message to be displayed in the error.
:type msg: str
:param solution: The solution to the error.
:type solution: str
Comment thread
Seluj78 marked this conversation as resolved.
Outdated

:Example:

Expand Down
2 changes: 2 additions & 0 deletions flask_utils/errors/web_server_is_down.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class WebServerIsDownError(_BaseFlaskException):
When raised, it will return a 521 status code with the message and solution provided.

:param msg: The message to be displayed in the error.
:type msg: str
:param solution: The solution to the error.
:type solution: str
Comment thread
Seluj78 marked this conversation as resolved.
Outdated

:Example:

Expand Down