MCPcopy
hub / github.com/LazyAGI/LazyLLM / _scan_proxy_members

Function _scan_proxy_members

lazyllm/cpp.py:94–134  ·  view source on GitHub ↗

Scan exported impl members and collect same-name methods/properties for proxying.

(py_cls: type, impl_cls: type)

Source from the content-addressed store, hash-verified

92
93
94def _scan_proxy_members(py_cls: type, impl_cls: type):
95 '''Scan exported impl members and collect same-name methods/properties for proxying.'''
96 proxy_methods = []
97 proxy_attrs = []
98
99 for name, member in impl_cls.__dict__.items():
100 if name.startswith('__'):
101 continue
102
103 if isinstance(member, property):
104 proxy_attrs.append(name)
105 continue
106
107 if not callable(member):
108 continue
109 if name not in py_cls.__dict__:
110 continue
111
112 py_member = py_cls.__dict__[name]
113 if not callable(py_member):
114 continue
115
116 # Dynamic validation: if both signatures are available, require identical
117 # parameter names; otherwise skip signature validation.
118 try:
119 py_sig = _normalize_param_names(py_member)
120 except (TypeError, ValueError):
121 py_sig = None
122 try:
123 impl_sig = _normalize_param_names(member)
124 except (TypeError, ValueError):
125 impl_sig = None
126 if py_sig is not None and impl_sig is not None and py_sig != impl_sig:
127 raise TypeError(
128 f'Signature mismatch for {py_cls.__name__}.{name}: '
129 f'python params={py_sig}, cpp params={impl_sig}'
130 )
131
132 proxy_methods.append(name)
133
134 return tuple(proxy_methods), tuple(proxy_attrs)
135
136
137def cpp_class(py_class: Optional[_C] = None, *, cpp_class_name: Optional[str] = None):

Callers 1

_decorateFunction · 0.85

Calls 3

_normalize_param_namesFunction · 0.85
appendMethod · 0.80
itemsMethod · 0.45

Tested by

no test coverage detected