MCPcopy Index your code
hub / github.com/rocky/python-uncompyle6 / is_docstring

Function is_docstring

uncompyle6/semantics/transform.py:28–57  ·  view source on GitHub ↗
(node, version, co_consts)

Source from the content-addressed store, hash-verified

26
27
28def is_docstring(node, version, co_consts):
29 if node == "sstmt":
30 node = node[0]
31 # TODO: the test below on 2.7 succeeds for
32 # class OldClass:
33 # __doc__ = DocDescr()
34 # which produces:
35 #
36 # assign (2)
37 # 0. expr
38 # call (2)
39 # 0. expr
40 # L. 16 6 LOAD_DEREF 0 'DocDescr'
41 # 1. 9 CALL_FUNCTION_0 0 None
42 # 1. store
43 #
44 # See Python 2.7 test_descr.py
45
46 # If ASSIGN_DOC_STRING doesn't work we need something like the below
47 # but more elaborate to address the above.
48
49 # try:
50 # return node.kind == "assign" and node[1][0].pattr == "__doc__"
51 # except:
52 # return False
53 if version <= (2, 7):
54 doc_load = "LOAD_CONST"
55 else:
56 doc_load = "LOAD_STR"
57 return node == ASSIGN_DOC_STRING(co_consts[0], doc_load)
58
59
60def is_not_docstring(call_stmt_node) -> bool:

Callers 2

build_classMethod · 0.90
transformMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected