Skip to content

Commit

Permalink
Literal[b"abc"] docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lubaskinc0de committed Aug 31, 2024
1 parent 62a3d49 commit 9429a79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changelog/fragments/318.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for bytes inside literal ``Literal[b"abc"]``
5 changes: 3 additions & 2 deletions docs/loading-and-dumping/specific-types-behavior.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,13 @@ Literal
Loader accepts only values listed in ``Literal``.
If ``strict_coercion`` is enabled, the loader will distinguish equal ``bool`` and ``int`` instances,
otherwise, they will be considered as same values.
``Enum`` instances will be loaded via its loaders. Enum loaders have a higher priority over others, that is, they will be applied first.
``Enum`` instances will be loaded via its loaders. ``bytes`` instances (e.g ``b"abc"``) will be loaded via its loaders as well.
Enum loaders have a higher priority over others, that is, they will be applied first.

If the input value could be interpreted as several ``Literal`` members, the result will be undefined.

Dumper will return value without any processing excluding ``Enum`` instances,
they will be processed via the corresponding dumper.
they will be processed via the corresponding dumper. ``bytes`` instances also will be processed via the corresponding dumper.

Be careful when you use a ``0``, ``1``, ``False`` and ``True`` as ``Literal`` members.
Due to type hint caching ``Literal[0, 1]`` sometimes returns ``Literal[False, True]``.
Expand Down

0 comments on commit 9429a79

Please sign in to comment.