o ו`ß ã@sndZddlmZmZmZddlmZddlmZm Z m Z es&ddl Z ddl Z gd¢Z dd „Zedfd d „ZdS) z Commonly useful converters. é)Úabsolute_importÚdivisionÚprint_functioné)ÚPY2)ÚNOTHINGÚFactoryÚpipeN)r ÚoptionalÚdefault_if_nonec sœ‡fdd„}tsLd}zt ˆ¡}Wn ttfyYnw|rLt|j ¡ƒ}|r<|djtj j ur.optional_converterNrrÚreturn)rÚinspectÚ signatureÚ ValueErrorÚ TypeErrorÚlistÚ parametersÚvaluesÚ annotationÚ ParameterÚemptyÚtypingÚOptionalÚ__annotations__Úreturn_annotationÚ Signature)rrÚsigÚparamsr rrr s& ÿ ÿ ÿr csxˆtur |dur tdƒ‚ˆtur|durtdƒ‚|dur t|ƒ‰tˆtƒr4ˆjr,tdƒ‚‡fdd„}|S‡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 no 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_converterasz2default_if_none..default_if_none_convertercs|dur|SˆSr r rr'r rr)is)rrrÚ isinstanceÚ takes_selfr)r(r&r)r r'rr >s"ÿ ÿ  úr )Ú__doc__Ú __future__rrrÚ_compatrÚ_makerrr rrÚ__all__r r r r r rÚs '