Skip to content

Commit 722a1a3

Browse files
committed
[FIX] server: ensure type alias ref is a class or type alias itself to display name
1 parent 4f1aa5d commit 722a1a3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

server/core/symbol.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,9 @@ def get_paths(self):
534534
return self.parent.get_paths()
535535
return []
536536

537+
def is_type_alias(self):
538+
return self.eval and not self.eval.instance and not isinstance(self, ImportSymbol)
539+
537540
class RootSymbol(Symbol):
538541

539542
def add_symbol(self, symbol):

server/features/hover.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,17 @@ def build_block_1(symbol, type, infered_type):
4545

4646
type_ref, _ = symbol.follow_ref(context, stop_on_type=True)
4747
type_str = "Any"
48-
if type_ref != symbol: #if the symbol is evaluated to something else than itself
48+
if type_ref != symbol and (type_ref.type != SymType.VARIABLE or type_ref.is_type_alias()): #if the symbol is evaluated to something else than itself
4949
type_str = type_ref.name
5050
#override type_str if the effective_sym is built by a __get__ and our symbol is an instance
5151
if factory and effective_sym: #take factory value only on instance symbols
5252
type_str = effective_sym.follow_ref({}, stop_on_type=True)[0].name
5353
type = str(symbol.type).lower()
54-
if symbol.eval and not symbol.eval.instance and not isinstance(symbol, ImportSymbol):
54+
if symbol.is_type_alias():
5555
type = "type alias"
5656
type_alias_ref = type_ref.next_ref()[0]
57-
if type_alias_ref != type_ref:
57+
if type_alias_ref and type_alias_ref != type_ref:
58+
type_alias_ref = type_alias_ref.follow_ref({}, stop_on_type=True)[0]
5859
type_str = type_alias_ref.name
5960
if symbol.type == SymType.FUNCTION:
6061
if symbol.is_property:

0 commit comments

Comments
 (0)