MCPcopy
hub / github.com/python-attrs/attrs / _fmt_converter_call

Method _fmt_converter_call

src/attr/_make.py:3150–3165  ·  view source on GitHub ↗

Return a string that calls the converter for an attribute name *attr_name* and the value in variable named *value_var* according to `self.takes_self` and `self.takes_field`.

(self, attr_name: str, value_var: str)

Source from the content-addressed store, hash-verified

3148 return f"__attr_converter_{attr_name}"
3149
3150 def _fmt_converter_call(self, attr_name: str, value_var: str) -> str:
3151 """
3152 Return a string that calls the converter for an attribute name
3153 *attr_name* and the value in variable named *value_var* according to
3154 `self.takes_self` and `self.takes_field`.
3155 """
3156 if not (self.takes_self or self.takes_field):
3157 return f"{self._get_global_name(attr_name)}({value_var})"
3158
3159 if self.takes_self and self.takes_field:
3160 return f"{self._get_global_name(attr_name)}({value_var}, self, attr_dict['{attr_name}'])"
3161
3162 if self.takes_self:
3163 return f"{self._get_global_name(attr_name)}({value_var}, self)"
3164
3165 return f"{self._get_global_name(attr_name)}({value_var}, attr_dict['{attr_name}'])"
3166
3167 def __getstate__(self):
3168 """

Callers 4

_setattr_with_converterFunction · 0.80
_assign_with_converterFunction · 0.80

Calls 1

_get_global_nameMethod · 0.95

Tested by 1