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

Function ignore_warning

dask/utils.py:843–881  ·  view source on GitHub ↗

Expand docstring by adding disclaimer and extra text

(doc, cls, name, extra="", skipblocks=0, inconsistencies=None)

Source from the content-addressed store, hash-verified

841
842
843def ignore_warning(doc, cls, name, extra="", skipblocks=0, inconsistencies=None):
844 """Expand docstring by adding disclaimer and extra text"""
845 import inspect
846
847 if inspect.isclass(cls):
848 l1 = "This docstring was copied from {}.{}.{}.\n\n".format(
849 cls.__module__,
850 cls.__name__,
851 name,
852 )
853 else:
854 l1 = f"This docstring was copied from {cls.__name__}.{name}.\n\n"
855 l2 = "Some inconsistencies with the Dask version may exist."
856
857 i = doc.find("\n\n")
858 if i != -1:
859 # Insert our warning
860 head = doc[: i + 2]
861 tail = doc[i + 2 :]
862 while skipblocks > 0:
863 i = tail.find("\n\n")
864 head = tail[: i + 2]
865 tail = tail[i + 2 :]
866 skipblocks -= 1
867 # Indentation of next line
868 indent = re.match(r"\s*", tail).group(0)
869 # Insert the warning, indented, with a blank line before and after
870 if extra:
871 more = [indent, extra.rstrip("\n") + "\n\n"]
872 else:
873 more = []
874 if inconsistencies is not None:
875 l3 = f"Known inconsistencies: \n {inconsistencies}"
876 bits = [head, indent, l1, l2, "\n\n", l3, "\n\n"] + more + [tail]
877 else:
878 bits = [head, indent, l1, indent, l2, "\n\n"] + more + [tail]
879 doc = "".join(bits)
880
881 return doc
882
883
884def unsupported_arguments(doc, args):

Callers 1

_derived_fromFunction · 0.85

Calls 2

matchMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected