converters
Commonly useful converters.
default_if_none(default=NOTHING, factory=None)
default_if_none(default: _T) -> _ConverterType
default_if_none(*, factory: Callable[[], _T]) -> _ConverterType
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
Source code in client/ayon_fusion/vendor/attr/converters.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
optional(converter)
A converter that allows an attribute to be optional. An optional attribute is one which can be set to None
.
Type annotations will be inferred from the wrapped converter's, if it has any.
:param callable converter: the converter that is used for non-None
values.
.. versionadded:: 17.1.0
Source code in client/ayon_fusion/vendor/attr/converters.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
pipe(*converters)
A converter that composes multiple converters into one.
When called on a value, it runs all wrapped converters, returning the last value.
Type annotations will be inferred from the wrapped converters', if they have any.
:param callables converters: Arbitrary number of converters.
.. versionadded:: 20.1.0
Source code in client/ayon_fusion/vendor/attr/_make.py
2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 |
|