Skip to content

Commit

Permalink
Make final code example in usage.rst standalone executable
Browse files Browse the repository at this point in the history
  • Loading branch information
bibajz authored and Tinche committed Jan 25, 2022
1 parent 9dd127a commit 989d2d7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,15 @@ As the final step, we can combine all of this into two hook factories:
.. code-block:: python
from attr import has, fields
from cattr import Converter
from cattr.gen import make_dict_unstructure_fn, make_dict_structure_fn, override
converter = Converter()
def to_camel_case(snake_str: str) -> str:
components = snake_str.split("_")
return components[0] + "".join(x.title() for x in components[1:])
def to_camel_case_unstructure(cls):
return make_dict_unstructure_fn(
cls,
Expand Down

0 comments on commit 989d2d7

Please sign in to comment.