MCPcopy Index your code
hub / github.com/prompt-toolkit/ptpython / get_signatures_using_jedi

Function get_signatures_using_jedi

src/ptpython/signatures.py:163–195  ·  view source on GitHub ↗
(
    document: Document, locals: dict[str, Any], globals: dict[str, Any]
)

Source from the content-addressed store, hash-verified

161
162
163def get_signatures_using_jedi(
164 document: Document, locals: dict[str, Any], globals: dict[str, Any]
165) -> list[Signature]:
166 script = get_jedi_script_from_document(document, locals, globals)
167
168 # Show signatures in help text.
169 if not script:
170 return []
171
172 try:
173 signatures = script.get_signatures()
174 except ValueError:
175 # e.g. in case of an invalid \\x escape.
176 signatures = []
177 except Exception:
178 # Sometimes we still get an exception (TypeError), because
179 # of probably bugs in jedi. We can silence them.
180 # See: https://github.com/davidhalter/jedi/issues/492
181 signatures = []
182 else:
183 # Try to access the params attribute just once. For Jedi
184 # signatures containing the keyword-only argument star,
185 # this will crash when retrieving it the first time with
186 # AttributeError. Every following time it works.
187 # See: https://github.com/jonathanslenders/ptpython/issues/47
188 # https://github.com/davidhalter/jedi/issues/598
189 try:
190 if signatures:
191 signatures[0].params
192 except AttributeError:
193 pass
194
195 return [Signature.from_jedi_signature(sig) for sig in signatures]
196
197
198def get_signatures_using_eval(

Callers 1

Calls 2

from_jedi_signatureMethod · 0.80

Tested by

no test coverage detected