scim2-models 0.4.0__py3-none-any.whl → 0.4.1__py3-none-any.whl

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.
@@ -143,7 +143,7 @@ class PatchOp(Message, Generic[T]):
143
143
  - Using PatchOp without a type parameter raises TypeError
144
144
  """
145
145
 
146
- def __new__(cls, *args, **kwargs):
146
+ def __new__(cls, *args: Any, **kwargs: Any):
147
147
  """Create new PatchOp instance with type parameter validation.
148
148
 
149
149
  Only handles the case of direct instantiation without type parameter (PatchOp()).
@@ -165,9 +165,23 @@ class PatchOp(Message, Generic[T]):
165
165
  def __class_getitem__(cls, item):
166
166
  """Validate type parameter when creating parameterized type.
167
167
 
168
- Ensures the type parameter is a concrete Resource subclass (not Resource itself).
169
- Rejects invalid types (str, int, etc.) and Union types.
168
+ Ensures the type parameter is a concrete Resource subclass (not Resource itself)
169
+ or a TypeVar bound to Resource. Rejects invalid types (str, int, etc.) and Union types.
170
170
  """
171
+ # Allow TypeVar as type parameter
172
+ if isinstance(item, TypeVar):
173
+ # Check if TypeVar is bound to Resource or its subclass
174
+ if item.__bound__ is not None and (
175
+ item.__bound__ is Resource
176
+ or (isclass(item.__bound__) and issubclass(item.__bound__, Resource))
177
+ ):
178
+ return super().__class_getitem__(item)
179
+ else:
180
+ raise TypeError(
181
+ f"PatchOp TypeVar must be bound to Resource or its subclass, got {item}. "
182
+ "Example: T = TypeVar('T', bound=Resource)"
183
+ )
184
+
171
185
  # Check if type parameter is a concrete Resource subclass (not Resource itself)
172
186
  if item is Resource:
173
187
  raise TypeError(
@@ -176,7 +190,7 @@ class PatchOp(Message, Generic[T]):
176
190
  )
177
191
  if not (isclass(item) and issubclass(item, Resource) and item is not Resource):
178
192
  raise TypeError(
179
- f"PatchOp type parameter must be a concrete Resource subclass, got {item}. "
193
+ f"PatchOp type parameter must be a concrete Resource subclass or TypeVar, got {item}. "
180
194
  "Use PatchOp[User], PatchOp[Group], etc."
181
195
  )
182
196
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scim2-models
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Summary: SCIM2 models serialization and validation with pydantic
5
5
  Project-URL: documentation, https://scim2-models.readthedocs.io
6
6
  Project-URL: repository, https://github.com/python-scim/scim2-models
@@ -14,7 +14,7 @@ scim2_models/messages/bulk.py,sha256=snPB722V_Msg1JBFcaTeEW_sa-jt-KHv6fh071NoKCg
14
14
  scim2_models/messages/error.py,sha256=_IHUoFwl-QJiICIcRkhaXf_9C7RXgiX7TL_26QXDo2c,6304
15
15
  scim2_models/messages/list_response.py,sha256=B-XELBTks6I45pKheAS5Go9x5IDKhrLJWsqC8y3G00s,2400
16
16
  scim2_models/messages/message.py,sha256=sjo_iFMJelZkssvA4O5xTqIt-urDxUbSP6N_WsnZ63Y,4081
17
- scim2_models/messages/patch_op.py,sha256=yM13Jtk9c1dJJ3ci9dE5kwXqruFb1Lm0rrIs6nct3YE,19050
17
+ scim2_models/messages/patch_op.py,sha256=yT_5gDcXWeSOdxvpYrdHh5nD2uD-B9kdfQ5qjC-JUkY,19726
18
18
  scim2_models/messages/search_request.py,sha256=BDTDzvtfCuFZDFsZBHl8ys8Te02jLuvGaTNipBQByrM,4632
19
19
  scim2_models/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  scim2_models/resources/enterprise_user.py,sha256=TVa5aS-eLHcDkwyr58hZYsRKk0AwjUaUaSFhU51mn5E,1806
@@ -24,7 +24,7 @@ scim2_models/resources/resource_type.py,sha256=scLqbD3HX3fXT2JOXY9OUVnZz7i5ty2lx
24
24
  scim2_models/resources/schema.py,sha256=KBqDRr2sgLrqL8UYWon-uxBzIA0118srJ8tXobs950E,10659
25
25
  scim2_models/resources/service_provider_config.py,sha256=6xJ182T-1szEQnN5Zb1cTdQCgTYIFi4XKygbvDlTKTM,5446
26
26
  scim2_models/resources/user.py,sha256=ErOghhilUF7fipwDRqARyLwJhbntQx4GJG3u2sZNJXs,10664
27
- scim2_models-0.4.0.dist-info/METADATA,sha256=PNXZC9wPGqbZqpDMQUh6WcRhyLy1EFmchdVorOH1dgc,16288
28
- scim2_models-0.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
29
- scim2_models-0.4.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
30
- scim2_models-0.4.0.dist-info/RECORD,,
27
+ scim2_models-0.4.1.dist-info/METADATA,sha256=zu1Txl8FZcnVF6WYYkBl5g7O1rvfcnaG1Dk987DtIRM,16288
28
+ scim2_models-0.4.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
29
+ scim2_models-0.4.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
30
+ scim2_models-0.4.1.dist-info/RECORD,,