a PÍ£_¦ã@sNdZddlmZmZmZddlmZmZmZgd¢Z dd„Z edfd d „Z dS) z Commonly useful converters. é)Úabsolute_importÚdivisionÚprint_functioné)ÚNOTHINGÚFactoryÚpipe)rÚoptionalÚdefault_if_nonecs‡fdd„}|S)z÷ A converter that allows an attribute to be optional. An optional attribute is one which can be set to ``None``. :param callable converter: the converter that is used for non-``None`` values. .. versionadded:: 17.1.0 cs|dur dSˆ|ƒS©N©©Úval©Ú converterr ú3/usr/lib/python3.9/site-packages/attr/converters.pyÚoptional_convertersz$optional..optional_converterr )rrr rrr s r Ncsvˆtur|durtdƒ‚ˆtur0|dur0tdƒ‚|dur@t|ƒ‰tˆtƒrfˆjrXtdƒ‚‡fdd„}n ‡fdd„}|S)a› A converter that allows to replace ``None`` values by *default* or the result of *factory*. :param default: Value to be used if ``None`` is passed. Passing an instance of `attr.Factory` is supported, however the ``takes_self`` option is *not*. :param callable factory: A callable that takes not parameters whose result is used if ``None`` is passed. :raises TypeError: If **neither** *default* or *factory* is passed. :raises TypeError: If **both** *default* and *factory* are passed. :raises ValueError: If an instance of `attr.Factory` is passed with ``takes_self=True``. .. versionadded:: 18.2.0 Nz(Must pass either `default` or `factory`.z5Must pass either `default` or `factory` but not both.z1`takes_self` is not supported by default_if_none.cs|dur |Sˆ ¡Sr )Úfactoryr ©Údefaultr rÚdefault_if_none_converterGsz2default_if_none..default_if_none_convertercs|dur |SˆSr r r rr rrOs)rÚ TypeErrorrÚ isinstanceZ takes_selfÚ ValueError)rrrr rrr $s ÿ ÿ r ) Ú__doc__Z __future__rrrÚ_makerrrÚ__all__r r r r r rÚs