MCPcopy Create free account
hub / github.com/ipython/ipython / _source_contains_docstring

Method _source_contains_docstring

IPython/core/oinspect.py:908–922  ·  view source on GitHub ↗

Check whether the source *src* contains the docstring *doc*. This is is helper function to skip displaying the docstring if the source already contains it, avoiding repetition of information.

(src, doc)

Source from the content-addressed store, hash-verified

906
907 @staticmethod
908 def _source_contains_docstring(src, doc):
909 """
910 Check whether the source *src* contains the docstring *doc*.
911
912 This is is helper function to skip displaying the docstring if the
913 source already contains it, avoiding repetition of information.
914 """
915 try:
916 def_node, = ast.parse(dedent(src)).body
917 return ast.get_docstring(def_node) == doc
918 except Exception:
919 # The source can become invalid or even non-existent (because it
920 # is re-fetched from the source file) so the above code fail in
921 # arbitrary ways.
922 return False
923
924 def psearch(self,pattern,ns_table,ns_search=[],
925 ignore_case=False,show_all=False, *, list_types=False):

Callers 1

_infoMethod · 0.95

Calls 2

dedentFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected