MCPcopy Create free account
hub / github.com/dask/dask / _derived_from

Function _derived_from

dask/utils.py:899–961  ·  view source on GitHub ↗

Helper function for derived_from to ease testing

(
    cls, method, ua_args=None, extra="", skipblocks=0, inconsistencies=None
)

Source from the content-addressed store, hash-verified

897
898
899def _derived_from(
900 cls, method, ua_args=None, extra="", skipblocks=0, inconsistencies=None
901):
902 """Helper function for derived_from to ease testing"""
903 ua_args = ua_args or []
904
905 # do not use wraps here, as it hides keyword arguments displayed
906 # in the doc
907 original_method = getattr(cls, method.__name__)
908
909 doc = getattr(original_method, "__doc__", None)
910
911 if isinstance(original_method, property):
912 # some things like SeriesGroupBy.unique are generated.
913 original_method = original_method.fget
914 if not doc:
915 doc = getattr(original_method, "__doc__", None)
916
917 if isinstance(original_method, functools.cached_property):
918 original_method = original_method.func
919 if not doc:
920 doc = getattr(original_method, "__doc__", None)
921
922 if doc is None:
923 doc = ""
924
925 # pandas DataFrame/Series sometimes override methods without setting __doc__
926 if not doc and cls.__name__ in {"DataFrame", "Series"}:
927 for obj in cls.mro():
928 obj_method = getattr(obj, method.__name__, None)
929 if obj_method is not None and obj_method.__doc__:
930 doc = obj_method.__doc__
931 break
932
933 # Insert disclaimer that this is a copied docstring
934 if doc:
935 doc = ignore_warning(
936 doc,
937 cls,
938 method.__name__,
939 extra=extra,
940 skipblocks=skipblocks,
941 inconsistencies=inconsistencies,
942 )
943 elif extra:
944 doc += extra.rstrip("\n") + "\n\n"
945
946 # Mark unsupported arguments
947 try:
948 method_args = get_named_args(method)
949 original_args = get_named_args(original_method)
950 not_supported = [m for m in original_args if m not in method_args]
951 except ValueError:
952 not_supported = []
953 if len(ua_args) > 0:
954 not_supported.extend(ua_args)
955 if len(not_supported) > 0:
956 doc = unsupported_arguments(doc, not_supported)

Callers 1

wrapperFunction · 0.85

Calls 5

ignore_warningFunction · 0.85
get_named_argsFunction · 0.85
unsupported_argumentsFunction · 0.85
skip_doctestFunction · 0.85
extra_titlesFunction · 0.85

Tested by

no test coverage detected