MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / check_compatible_str

Function check_compatible_str

tools/check_api_compatible.py:91–109  ·  view source on GitHub ↗
(old_api_spec_str, new_api_spec_str)

Source from the content-addressed store, hash-verified

89
90
91def check_compatible_str(old_api_spec_str, new_api_spec_str):
92 patArgSpec = re.compile(
93 r'args=(.*), varargs=.*defaults=(None|\((.*)\)), kwonlyargs=.*'
94 )
95 mo_o = patArgSpec.search(old_api_spec_str)
96 mo_n = patArgSpec.search(new_api_spec_str)
97 if not (mo_o and mo_n):
98 # error
99 logger.warning("old_api_spec_str: %s", old_api_spec_str)
100 logger.warning("new_api_spec_str: %s", new_api_spec_str)
101 return False
102
103 args_o = eval(mo_o.group(1))
104 args_n = eval(mo_n.group(1))
105 defaults_o = mo_o.group(2) if mo_o.group(3) is None else mo_o.group(3)
106 defaults_n = mo_n.group(2) if mo_n.group(3) is None else mo_n.group(3)
107 defaults_o = defaults_o.split(', ') if defaults_o else []
108 defaults_n = defaults_n.split(', ') if defaults_n else []
109 return _check_compatible(args_o, args_n, defaults_o, defaults_n)
110
111
112def read_argspec_from_file(specfile):

Callers 6

test_args_addedMethod · 0.90
test_args_reducedMethod · 0.90

Calls 6

evalFunction · 0.85
_check_compatibleFunction · 0.85
compileMethod · 0.45
searchMethod · 0.45
groupMethod · 0.45
splitMethod · 0.45

Tested by 5

test_args_addedMethod · 0.72
test_args_reducedMethod · 0.72