forked from VimPlug/jedi
Reduce noise in signatures of compiled params (#1564)
* Remove "typing." prefix from compiled signature param
* Don't print default "None" for Optional params
* Don't remove 'typing.' prefix if symbol doesn't come from typing module
* Revert "Don't print default "None" for Optional params"
This reverts commit 8db334d9bb.
* Make sure "typing." doesn't appear in the middle
* Make sure only "typing." prefix is removed and not it's entries in the middle
* Use inspect.formatannotation() to create an annotation string
* Update AUTHORS.txt
* Add test for compiled param annotation string
* Replace Optional in test with other typing facilities
in order for test to be forward-compatible with 3.9
* Add an empty string fallback for Python 2
* Move _annotation_to_str back to original position
This commit is contained in:
committed by
GitHub
parent
be7a1346ec
commit
e1c0d2c501
@@ -102,3 +102,14 @@ def test_signature():
|
||||
|
||||
s, = jedi.Interpreter('some_signature', [locals()]).goto()
|
||||
assert s.docstring() == 'some_signature(*, bar=1)'
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info[0:2] < (3, 5), reason="Typing was introduced in Python 3.5")
|
||||
def test_compiled_signature_annotation_string():
|
||||
import typing
|
||||
def func(x: typing.Type, y: typing.Union[typing.Type, int]): pass
|
||||
func.__name__ = 'not_func'
|
||||
|
||||
s, = jedi.Interpreter('func()', [locals()]).get_signatures(1, 5)
|
||||
assert s.params[0].description == 'param x: Type'
|
||||
assert s.params[1].description == 'param y: Union[Type, int]'
|
||||
|
||||
Reference in New Issue
Block a user