mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Fix potential AttributeError in get_defintion_start_position/get_defintion_end_position, see #1584
This commit is contained in:
@@ -238,6 +238,8 @@ class BaseName(object):
|
||||
|
||||
:rtype: Optional[Tuple[int, int]]
|
||||
"""
|
||||
if self._name.tree_name is None:
|
||||
return None
|
||||
definition = self._name.tree_name.get_definition()
|
||||
if definition is None:
|
||||
return self._name.start_pos
|
||||
@@ -250,10 +252,10 @@ class BaseName(object):
|
||||
|
||||
:rtype: Optional[Tuple[int, int]]
|
||||
"""
|
||||
if self._name.tree_name is None:
|
||||
return None
|
||||
definition = self._name.tree_name.get_definition()
|
||||
if definition is None:
|
||||
if self._name.tree_name is None:
|
||||
return None
|
||||
return self._name.tree_name.end_pos
|
||||
if self.type in ("function", "class"):
|
||||
last_leaf = definition.get_last_leaf()
|
||||
|
||||
Reference in New Issue
Block a user