(buf: TextIO, name: str, clslevel: bool = False)
| 199 | require_intermediate = set(use_intermediate_variable) |
| 200 | |
| 201 | def instrument(buf: TextIO, name: str, clslevel: bool = False) -> None: |
| 202 | fn = getattr(target_cls, name) |
| 203 | |
| 204 | overloads = _grab_overloads(fn) |
| 205 | |
| 206 | for overload in overloads: |
| 207 | buf.write(overload) |
| 208 | |
| 209 | spec = compat.inspect_getfullargspec(fn) |
| 210 | |
| 211 | iscoroutine = inspect.iscoroutinefunction(fn) |
| 212 | |
| 213 | if spec.defaults or spec.kwonlydefaults: |
| 214 | elem = list(spec) |
| 215 | |
| 216 | if spec.defaults: |
| 217 | new_defaults = tuple( |
| 218 | ( |
| 219 | _repr_sym("util.EMPTY_DICT") |
| 220 | if df is util.EMPTY_DICT |
| 221 | else df |
| 222 | ) |
| 223 | for df in spec.defaults |
| 224 | ) |
| 225 | elem[3] = new_defaults |
| 226 | |
| 227 | if spec.kwonlydefaults: |
| 228 | new_kwonlydefaults = { |
| 229 | name: ( |
| 230 | _repr_sym("util.EMPTY_DICT") |
| 231 | if df is util.EMPTY_DICT |
| 232 | else df |
| 233 | ) |
| 234 | for name, df in spec.kwonlydefaults.items() |
| 235 | } |
| 236 | elem[5] = new_kwonlydefaults |
| 237 | |
| 238 | spec = compat.FullArgSpec(*elem) |
| 239 | |
| 240 | caller_argspec = format_argspec_plus(spec, grouped=False) |
| 241 | |
| 242 | metadata = { |
| 243 | "name": fn.__name__, |
| 244 | "async": "async " if iscoroutine else "", |
| 245 | "await": "await " if iscoroutine else "", |
| 246 | "apply_pos_proxied": caller_argspec["apply_pos_proxied"], |
| 247 | "target_cls_name": target_cls.__name__, |
| 248 | "apply_kw_proxied": caller_argspec["apply_kw_proxied"], |
| 249 | "grouped_args": caller_argspec["grouped_args"], |
| 250 | "self_arg": caller_argspec["self_arg"], |
| 251 | "doc": textwrap.indent( |
| 252 | inject_docstring_text( |
| 253 | fn.__doc__, |
| 254 | textwrap.indent( |
| 255 | ".. container:: class_bases\n\n" |
| 256 | f" Proxied for the {target_cls_sphinx_name} " |
| 257 | "class on \n" |
| 258 | f" behalf of the {proxy_cls_sphinx_name} " |
no test coverage detected