Skip to content

Commit 989d2d7

Browse files
bibajzTinche
authored andcommitted
Make final code example in usage.rst standalone executable
1 parent 9dd127a commit 989d2d7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

docs/usage.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,15 @@ As the final step, we can combine all of this into two hook factories:
216216
.. code-block:: python
217217
218218
from attr import has, fields
219+
from cattr import Converter
219220
from cattr.gen import make_dict_unstructure_fn, make_dict_structure_fn, override
220221
222+
converter = Converter()
223+
224+
def to_camel_case(snake_str: str) -> str:
225+
components = snake_str.split("_")
226+
return components[0] + "".join(x.title() for x in components[1:])
227+
221228
def to_camel_case_unstructure(cls):
222229
return make_dict_unstructure_fn(
223230
cls,

0 commit comments

Comments
 (0)