Skip to content

Commit d4b55b5

Browse files
committed
fix: add some types in the error module
1 parent 2472eb1 commit d4b55b5

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ docstring-code-format = true
117117
plugins = [
118118
"pydantic.mypy"
119119
]
120+
exclude = [
121+
"tests/",
122+
]
120123

121124
[tool.pytest.ini_options]
122125
asyncio_mode="auto"

scim2_client/errors.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ class SCIMClientError(Exception):
99
caused the exception.
1010
"""
1111

12-
def __init__(self, message: str, source: Any = None, *args, **kwargs):
12+
def __init__(
13+
self, message: str, source: Any = None, *args: Any, **kwargs: Any
14+
) -> None:
1315
self.message = message
1416
self.source = source
1517
super().__init__(*args, **kwargs)
1618

17-
def __str__(self):
19+
def __str__(self) -> str:
1820
return self.message or "UNKNOWN"
1921

2022

@@ -29,7 +31,7 @@ class RequestNetworkError(SCIMRequestError):
2931
The original :class:`~httpx.RequestError` is available with :attr:`~BaseException.__cause__`.
3032
"""
3133

32-
def __init__(self, *args, **kwargs):
34+
def __init__(self, *args: Any, **kwargs: Any) -> None:
3335
message = kwargs.pop("message", "Network error happened during request")
3436
super().__init__(message, *args, **kwargs)
3537

@@ -54,7 +56,7 @@ class RequestPayloadValidationError(SCIMRequestError):
5456
print("Original validation error cause", exc.__cause__)
5557
"""
5658

57-
def __init__(self, *args, **kwargs):
59+
def __init__(self, *args: Any, **kwargs: Any) -> None:
5860
message = kwargs.pop("message", "Server request payload validation error")
5961
super().__init__(message, *args, **kwargs)
6062

@@ -69,7 +71,7 @@ class SCIMResponseErrorObject(SCIMResponseError):
6971
Those errors are only raised when the :code:`raise_scim_errors` parameter is :data:`True`.
7072
"""
7173

72-
def __init__(self, obj, *args, **kwargs):
74+
def __init__(self, obj: Any, *args: Any, **kwargs: Any) -> None:
7375
message = kwargs.pop(
7476
"message", f"The server returned a SCIM Error object: {obj}"
7577
)
@@ -79,7 +81,7 @@ def __init__(self, obj, *args, **kwargs):
7981
class UnexpectedStatusCode(SCIMResponseError):
8082
"""Error raised when a server returned an unexpected status code for a given :class:`~scim2_models.Context`."""
8183

82-
def __init__(self, status_code: int, *args, **kwargs):
84+
def __init__(self, status_code: int, *args: Any, **kwargs: Any) -> None:
8385
message = kwargs.pop(
8486
"message", f"Unexpected response status code: {status_code}"
8587
)
@@ -89,15 +91,15 @@ def __init__(self, status_code: int, *args, **kwargs):
8991
class UnexpectedContentType(SCIMResponseError):
9092
"""Error raised when a server returned an unexpected `Content-Type` header in a response."""
9193

92-
def __init__(self, content_type, *args, **kwargs):
94+
def __init__(self, content_type: str, *args: Any, **kwargs: Any) -> None:
9395
message = kwargs.pop("message", f"Unexpected content type: {content_type}")
9496
super().__init__(message, *args, **kwargs)
9597

9698

9799
class UnexpectedContentFormat(SCIMResponseError):
98100
"""Error raised when a server returned a response in a non-JSON format."""
99101

100-
def __init__(self, *args, **kwargs):
102+
def __init__(self, *args: Any, **kwargs: Any) -> None:
101103
message = kwargs.pop("message", "Unexpected response content format")
102104
super().__init__(message, *args, **kwargs)
103105

@@ -117,6 +119,6 @@ class ResponsePayloadValidationError(SCIMResponseError):
117119
print("Original validation error cause", exc.__cause__)
118120
"""
119121

120-
def __init__(self, *args, **kwargs):
122+
def __init__(self, *args: Any, **kwargs: Any) -> None:
121123
message = kwargs.pop("message", "Server response payload validation error")
122124
super().__init__(message, *args, **kwargs)

0 commit comments

Comments
 (0)