scim2-client 0.7.2__tar.gz → 0.7.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: scim2-client
3
- Version: 0.7.2
3
+ Version: 0.7.3
4
4
  Summary: Pythonically build SCIM requests and parse SCIM responses
5
5
  Keywords: scim,scim2,provisioning,rfc7643,rfc7644,httpx,api
6
6
  Author: Yaal Coop
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "scim2-client"
7
- version = "0.7.2"
7
+ version = "0.7.3"
8
8
  description = "Pythonically build SCIM requests and parse SCIM responses"
9
9
  authors = [{name="Yaal Coop", email="contact@yaal.coop"}]
10
10
  license = {file = "LICENSE.md"}
@@ -83,6 +83,7 @@ exclude_lines = [
83
83
  "@pytest.mark.skip",
84
84
  "pragma: no cover",
85
85
  "raise NotImplementedError",
86
+ "if TYPE_CHECKING:",
86
87
  "\\.\\.\\.\\s*$", # ignore ellipsis
87
88
  ]
88
89
 
@@ -312,7 +312,7 @@ class SCIMClient:
312
312
  if response_payload and response_payload.get("schemas") == [Error.__schema__]:
313
313
  error = Error.model_validate(response_payload)
314
314
  if raise_scim_errors:
315
- raise SCIMResponseErrorObject(obj=error.detail, source=error)
315
+ raise SCIMResponseErrorObject(error)
316
316
  return error
317
317
 
318
318
  self._check_status_codes(status_code, expected_status_codes)
@@ -1,5 +1,9 @@
1
+ from typing import TYPE_CHECKING
1
2
  from typing import Any
2
3
 
4
+ if TYPE_CHECKING:
5
+ from scim2_models import Error
6
+
3
7
 
4
8
  class SCIMClientError(Exception):
5
9
  """Base exception for scim2-client.
@@ -69,14 +73,24 @@ class SCIMResponseErrorObject(SCIMResponseError):
69
73
  """The server response returned a :class:`scim2_models.Error` object.
70
74
 
71
75
  Those errors are only raised when the :code:`raise_scim_errors` parameter is :data:`True`.
76
+
77
+ :param error: The :class:`~scim2_models.Error` object returned by the server.
72
78
  """
73
79
 
74
- def __init__(self, obj: Any, *args: Any, **kwargs: Any) -> None:
75
- message = kwargs.pop(
76
- "message", f"The server returned a SCIM Error object: {obj}"
77
- )
80
+ def __init__(self, error: "Error", *args: Any, **kwargs: Any) -> None:
81
+ self._error = error
82
+ parts = []
83
+ if error.scim_type:
84
+ parts.append(error.scim_type + ":")
85
+ if error.detail:
86
+ parts.append(error.detail)
87
+ message = " ".join(parts) if parts else "SCIM Error"
78
88
  super().__init__(message, *args, **kwargs)
79
89
 
90
+ def to_error(self) -> "Error":
91
+ """Return the :class:`~scim2_models.Error` object returned by the server."""
92
+ return self._error
93
+
80
94
 
81
95
  class UnexpectedStatusCode(SCIMResponseError):
82
96
  """Error raised when a server returned an unexpected status code for a given :class:`~scim2_models.Context`."""
File without changes
File without changes