Skip to content

Commit 2afbcb2

Browse files
MicaelJarniachynek
andauthored
Remove mutable default arg in function example (#944)
* Remove mutable default arg in function example Removed mutable default arg, replaced with `None`. https://docs.quantifiedcode.com/python-anti-patterns/correctness/mutable_default_value_as_argument.html Replaced `dict()` with `{}`. https://stackoverflow.com/questions/8424942/creating-a-new-dictionary-in-python * Wrong import * Undo last commit My bad. Co-authored-by: Hynek Schlawack <hs@ox.cx>
1 parent f376db2 commit 2afbcb2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

docs/extending.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ Here are some tips for effective use of metadata:
176176
>>>
177177
>>> def typed(
178178
... cls, default=NOTHING, validator=None, repr=True,
179-
... eq=True, order=None, hash=None, init=True, metadata={},
179+
... eq=True, order=None, hash=None, init=True, metadata=None,
180180
... converter=None
181181
... ):
182-
... metadata = dict() if not metadata else metadata
182+
... metadata = metadata or {}
183183
... metadata[MY_TYPE_METADATA] = cls
184184
... return field(
185185
... default=default, validator=validator, repr=repr,

0 commit comments

Comments
 (0)