Skip to content

Commit 08382ca

Browse files
committed
doc: minor documentation fixes
1 parent 3cb571f commit 08382ca

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

doc/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ the `bugtracker <https://github.com/python-scim/scim2-models/issues>`_.
1414
Unit tests
1515
----------
1616

17-
To run the tests, you just can run `uv run pytest` and/or `tox` to test all the supported python environments.
17+
To run the tests, you just can run ``uv run pytest`` and/or ``tox`` to test all the supported python environments.
1818
Everything must be green before patches get merged.
1919

2020
The test coverage is 100%, patches won't be accepted if not entirely covered. You can check the

doc/guides/flask.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ responses.
6262
:start-after: # -- error-handlers-start --
6363
:end-before: # -- error-handlers-end --
6464

65-
If :meth:`~scim2_models.Resource.model_validate`, Flask routes the
65+
If :meth:`~scim2_models.Resource.model_validate` fails, Flask routes the
6666
:class:`~pydantic.ValidationError` to ``handle_validation_error`` and the client receives a
6767
SCIM :class:`~scim2_models.Error` response.
6868
``handle_scim_error`` catches any :class:`~scim2_models.SCIMException` (uniqueness, mutability, …)

doc/tutorial.rst

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Use Pydantic's :func:`~scim2_models.BaseModel.model_validate` method to parse an
5959
Model serialization
6060
===================
6161

62-
Pydantic :func:`~scim2_models.BaseModel.model_dump` method have been tuned to produce valid SCIM2 payloads.
62+
Pydantic :func:`~scim2_models.BaseModel.model_dump` method has been tuned to produce valid SCIM2 payloads.
6363

6464
.. code-block:: python
6565
:emphasize-lines: 16
@@ -99,7 +99,7 @@ Contexts
9999
========
100100

101101
The SCIM specifications detail some :class:`~scim2_models.Mutability` and :class:`~scim2_models.Returned` parameters for model attributes.
102-
Depending on the context, they will indicate that attributes should be present, absent, be ignored.
102+
Depending on the context, they will indicate that attributes should be present, absent, or ignored.
103103

104104
For instance, attributes marked as :attr:`~scim2_models.Mutability.read_only` should not be sent by SCIM clients on resource creation requests.
105105
By passing the right :class:`~scim2_models.Context` to the :meth:`~scim2_models.BaseModel.model_dump` method, only the expected fields will be dumped for this context:
@@ -117,11 +117,11 @@ fields with unexpected values will raise :class:`~pydantic.ValidationError`:
117117
.. code-block:: python
118118
:caption: Server validating a resource creation request payload
119119
120-
>>> from scim2_models import User, Context
120+
>>> from scim2_models import User, Context, Error
121121
>>> from pydantic import ValidationError
122122
>>> try:
123123
... obj = User.model_validate(payload, scim_ctx=Context.RESOURCE_CREATION_REQUEST)
124-
... except pydantic.ValidationError:
124+
... except ValidationError:
125125
... obj = Error(...)
126126
127127
Context annotations
@@ -210,7 +210,7 @@ Attributes inclusions and exclusions
210210
====================================
211211

212212
In some situations it might be needed to exclude, or only include a given set of attributes when serializing a model.
213-
This happens for instance when servers build response payloads for clients requesting only a sub-set the model attributes.
213+
This happens for instance when servers build response payloads for clients requesting only a subset of the model attributes.
214214
As defined in :rfc:`RFC7644 §3.9 <7644#section-3.9>`, :code:`attributes` and :code:`excluded_attributes` parameters can
215215
be passed to :meth:`~scim2_models.BaseModel.model_dump`.
216216
The expected attribute notation is the one detailed on :rfc:`RFC7644 §3.10 <7644#section-3.10>`,
@@ -222,23 +222,22 @@ like :code:`urn:ietf:params:scim:schemas:core:2.0:User:userName`, or :code:`user
222222
>>> from scim2_models import User, Context
223223
>>> user = User(user_name="bjensen@example.com", display_name="bjensen")
224224
>>> payload = user.model_dump(
225-
... scim_ctx=Context.RESOURCE_QUERY_REQUEST,
225+
... scim_ctx=Context.RESOURCE_QUERY_RESPONSE,
226226
... excluded_attributes=["displayName"]
227227
... )
228228
>>> assert payload == {
229229
... "schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
230230
... "userName": "bjensen@example.com",
231-
... "displayName": "bjensen",
232231
... }
233232
234233
Values read from :attr:`~scim2_models.SearchRequest.attributes` and :attr:`~scim2_models.SearchRequest.excluded_attributes` in :class:`~scim2_models.SearchRequest` objects can directly be used in :meth:`~scim2_models.BaseModel.model_dump`.
235234

236-
Attribute inclusions and exclusions interact with attributes :class:`~scim2_models.Returned`, in the server response :class:`Contexts <scim2_models.Context>`:
235+
Attributes inclusions and exclusions interact with attributes :class:`~scim2_models.Returned`, in the server response :class:`Contexts <scim2_models.Context>`:
237236

238237
- attributes annotated with :attr:`~scim2_models.Returned.always` will always be dumped;
239238
- attributes annotated with :attr:`~scim2_models.Returned.never` will never be dumped;
240239
- attributes annotated with :attr:`~scim2_models.Returned.default` will be dumped unless being explicitly excluded;
241-
- attributes annotated with :attr:`~scim2_models.Returned.request` will be not dumped unless being explicitly included.
240+
- attributes annotated with :attr:`~scim2_models.Returned.request` will not be dumped unless being explicitly included.
242241

243242
Typed ListResponse
244243
==================
@@ -403,7 +402,7 @@ Use :meth:`Error.from_validation_error <scim2_models.Error.from_validation_error
403402
>>> from scim2_models.base import Context
404403
405404
>>> try:
406-
... User.model_validate({"userName": None}, context={"scim": Context.RESOURCE_CREATION_REQUEST})
405+
... User.model_validate({"userName": None}, scim_ctx=Context.RESOURCE_CREATION_REQUEST)
407406
... except ValidationError as exc:
408407
... error = Error.from_validation_error(exc.errors()[0])
409408
>>> error.scim_type
@@ -427,7 +426,7 @@ The exhaustive list of exceptions is available in the :class:`reference <scim2_m
427426
Custom models
428427
=============
429428

430-
You can write your own model and use it the same way than the other scim2-models models.
429+
You can write your own model and use it the same way as the other scim2-models models.
431430
Just inherit from :class:`~scim2_models.Resource` for your main resource, or :class:`~scim2_models.Extension` for extensions.
432431
Use :class:`~scim2_models.ComplexAttribute` as base class for complex attributes:
433432

@@ -464,8 +463,11 @@ If unset the default values will be :attr:`~scim2_models.Mutability.read_write`
464463
There is a dedicated type for :rfc:`RFC7643 §2.3.7 <7643#section-2.3.7>` :class:`~scim2_models.Reference`
465464
that can take type parameters to represent :rfc:`RFC7643 §7 'referenceTypes'<7643#section-7>`:
466465

466+
.. code-block:: python
467+
468+
>>> from scim2_models import Reference
467469
>>> class PetOwner(Resource):
468-
... pet: Reference["Pet"]
470+
... pet: Optional[Reference["Pet"]]
469471
470472
:class:`~scim2_models.Reference` has two special type parameters :class:`~scim2_models.External` and :class:`~scim2_models.URI` that matches :rfc:`RFC7643 §7 <7643#section-7>` external and URI reference types.
471473

@@ -541,7 +543,7 @@ with the :meth:`Resource.from_schema <scim2_models.Resource.from_schema>` and :m
541543
Group = Resource.from_schema(schema)
542544
my_group = Group(display_name="This is my group")
543545
544-
Client applications can use this to dynamically discover server resources by browsing the `/Schemas` endpoint.
546+
Client applications can use this to dynamically discover server resources by browsing the ``/Schemas`` endpoint.
545547

546548
.. tip::
547549

@@ -550,7 +552,7 @@ Client applications can use this to dynamically discover server resources by bro
550552

551553
.. toggle::
552554

553-
.. literalinclude :: ../samples/rfc7643-8.7.1-schema-group.json
555+
.. literalinclude:: ../samples/rfc7643-8.7.1-schema-group.json
554556
:language: json
555557
:caption: schema-group.json
556558

@@ -566,7 +568,6 @@ modified.
566568
.. doctest::
567569

568570
>>> from scim2_models import User, Context
569-
>>> from scim2_models.exceptions import MutabilityException
570571
>>> existing = User(user_name="bjensen")
571572
>>> replacement = User.model_validate(
572573
... {"userName": "bjensen"},
@@ -581,7 +582,7 @@ Patch operations
581582
================
582583

583584
:class:`~scim2_models.PatchOp` allows you to apply patch operations to modify SCIM resources.
584-
The :meth:`~scim2_models.PatchOp.patch` method applies operations in sequence and returns whether the resource was modified. The return code is a boolean indicating whether the object have been modified by the operations.
585+
The :meth:`~scim2_models.PatchOp.patch` method applies operations in sequence and returns whether the resource was modified. The return code is a boolean indicating whether the object has been modified by the operations.
585586

586587
.. note::
587588
:class:`~scim2_models.PatchOp` takes a type parameter that should be the class of the resource

0 commit comments

Comments
 (0)