From 7cd89cff6e4a4ac930903f2832a6b4805de51977 Mon Sep 17 00:00:00 2001 From: muffinmad Date: Tue, 12 May 2020 23:14:32 +0300 Subject: [PATCH 1/4] Return 'class' as BaseName.type of _PseudoTreeNameClass (fix #1578) --- jedi/inference/gradual/base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jedi/inference/gradual/base.py b/jedi/inference/gradual/base.py index 70cfa447..f323dc67 100644 --- a/jedi/inference/gradual/base.py +++ b/jedi/inference/gradual/base.py @@ -306,6 +306,8 @@ class _PseudoTreeNameClass(Value): this class. Essentially this class makes it possible to goto that `Tuple` name, without affecting anything else negatively. """ + api_type = u'class' + def __init__(self, parent_context, tree_name): super(_PseudoTreeNameClass, self).__init__( parent_context.inference_state, From 7ccee7d8fc8abea99c8eef244eaf8739162fab65 Mon Sep 17 00:00:00 2001 From: muffinmad Date: Tue, 12 May 2020 23:28:46 +0300 Subject: [PATCH 2/4] Add test _PseudoTreeNameClass.type == 'class' --- test/test_api/test_classes.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test_api/test_classes.py b/test/test_api/test_classes.py index 17265293..8e4d935e 100644 --- a/test/test_api/test_classes.py +++ b/test/test_api/test_classes.py @@ -599,3 +599,7 @@ def test_get_type_hint(Script, code, expected, skip_pre_python36): code = 'from typing import *\n' + code d, = Script(code).goto() assert d.get_type_hint() == expected + + +def test_pseudotreenameclass_type(Script): + assert Script('from typing import Any\n').get_names()[0].type == 'class' From ce8473ee635a551e048f3264f6a51b0b1873169c Mon Sep 17 00:00:00 2001 From: muffinmad Date: Tue, 12 May 2020 23:34:28 +0300 Subject: [PATCH 3/4] Add author's name to AUTHORS.txt --- AUTHORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 8c3df84f..6e881b7e 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -59,6 +59,7 @@ Code Contributors - Ryan Clary (@mrclary) - Max Mäusezahl (@mmaeusezahl) - Vladislav Serebrennikov (@endilll) +- Andrii Kolomoiets (@muffinmad) And a few more "anonymous" contributors. From 16e2b86bcf03d547ff33d43077d76268e67a2bad Mon Sep 17 00:00:00 2001 From: muffinmad Date: Wed, 13 May 2020 01:18:47 +0300 Subject: [PATCH 4/4] Fix test --- test/test_api/test_signatures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_api/test_signatures.py b/test/test_api/test_signatures.py index a7525954..40cbf03d 100644 --- a/test/test_api/test_signatures.py +++ b/test/test_api/test_signatures.py @@ -13,7 +13,7 @@ _tuple_code = 'from typing import Tuple\ndef f(x: Tuple[int]): ...\nf' ('from typing import List\ndef f(x: List[int]): ...\nf', ['instance list'], True), ('from typing import List\ndef f(x: List[int]): ...\nf', ['class list'], False), (_tuple_code, ['instance tuple'], True), - (_tuple_code, ['Tuple: _SpecialForm = ...'], False), + (_tuple_code, ['class Tuple'], False), ('x=str\ndef f(p: x): ...\nx=int\nf', ['instance int'], True), ('def f(*args, **kwargs): ...\nf', [None, None], False),