(cls, pd_cls, attr, min_version=None)
| 23 | |
| 24 | |
| 25 | def _bind_property(cls, pd_cls, attr, min_version=None): |
| 26 | def func(self): |
| 27 | return self._property_map(attr) |
| 28 | |
| 29 | func.__name__ = attr |
| 30 | func.__qualname__ = f"{cls.__name__}.{attr}" |
| 31 | try: |
| 32 | # Attempt to determine the method we are wrapping |
| 33 | original_prop = getattr(pd_cls, attr) |
| 34 | if isinstance(original_prop, property): |
| 35 | method = original_prop.fget |
| 36 | elif isinstance(original_prop, functools.cached_property): |
| 37 | method = original_prop.func |
| 38 | else: |
| 39 | method = original_prop |
| 40 | func.__wrapped__ = method |
| 41 | except Exception: |
| 42 | # If we can't then no matter, the function still works. |
| 43 | pass |
| 44 | setattr(cls, attr, property(derived_from(pd_cls, version=min_version)(func))) |
| 45 | |
| 46 | |
| 47 | def maybe_wrap_pandas(obj, x): |
no test coverage detected