mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +08:00
inspect.signature throws weird errors sometimes, just make it a bit simpler
Fixes #1031
This commit is contained in:
@@ -399,7 +399,13 @@ class DirectObjectAccess(object):
|
|||||||
or obj.__new__ != object.__new__)):
|
or obj.__new__ != object.__new__)):
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
|
try:
|
||||||
signature = inspect.signature(obj)
|
signature = inspect.signature(obj)
|
||||||
|
except (RuntimeError, TypeError):
|
||||||
|
# Reading the code of the function in Python 3.6 implies there are
|
||||||
|
# at least these errors that might occur if something is wrong with
|
||||||
|
# the signature. In that case we just want a simple escape for now.
|
||||||
|
raise ValueError
|
||||||
return [
|
return [
|
||||||
SignatureParam(
|
SignatureParam(
|
||||||
name=p.name,
|
name=p.name,
|
||||||
|
|||||||
@@ -164,6 +164,15 @@ def test_completion_params(Script):
|
|||||||
assert [p.name for p in c.params] == ['s', 'sep']
|
assert [p.name for p in c.params] == ['s', 'sep']
|
||||||
|
|
||||||
|
|
||||||
|
def test_hashlib_params(Script, environment):
|
||||||
|
if environment.version_info < (3,):
|
||||||
|
pytest.skip()
|
||||||
|
|
||||||
|
script = Script(source='from hashlib import ', line=1, column=20)
|
||||||
|
c = script.completions()
|
||||||
|
assert c[2].params
|
||||||
|
|
||||||
|
|
||||||
def test_signature_params(Script):
|
def test_signature_params(Script):
|
||||||
def check(defs):
|
def check(defs):
|
||||||
params = defs[0].params
|
params = defs[0].params
|
||||||
|
|||||||
Reference in New Issue
Block a user