Skip to content

Commit

Permalink
[FIX] server: ensure type alias ref is a class or type alias itself t…
Browse files Browse the repository at this point in the history
…o display name
  • Loading branch information
fda-odoo committed Dec 21, 2023
1 parent 4f1aa5d commit 722a1a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions server/core/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ def get_paths(self):
return self.parent.get_paths()
return []

def is_type_alias(self):
return self.eval and not self.eval.instance and not isinstance(self, ImportSymbol)

class RootSymbol(Symbol):

def add_symbol(self, symbol):
Expand Down
7 changes: 4 additions & 3 deletions server/features/hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@ def build_block_1(symbol, type, infered_type):

type_ref, _ = symbol.follow_ref(context, stop_on_type=True)
type_str = "Any"
if type_ref != symbol: #if the symbol is evaluated to something else than itself
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
type_str = type_ref.name
#override type_str if the effective_sym is built by a __get__ and our symbol is an instance
if factory and effective_sym: #take factory value only on instance symbols
type_str = effective_sym.follow_ref({}, stop_on_type=True)[0].name
type = str(symbol.type).lower()
if symbol.eval and not symbol.eval.instance and not isinstance(symbol, ImportSymbol):
if symbol.is_type_alias():
type = "type alias"
type_alias_ref = type_ref.next_ref()[0]
if type_alias_ref != type_ref:
if type_alias_ref and type_alias_ref != type_ref:
type_alias_ref = type_alias_ref.follow_ref({}, stop_on_type=True)[0]
type_str = type_alias_ref.name
if symbol.type == SymType.FUNCTION:
if symbol.is_property:
Expand Down

0 comments on commit 722a1a3

Please sign in to comment.