Move is_side_effect to Definition and correct bugs

This commit is contained in:
Dave Halter
2020-02-04 20:12:24 +01:00
parent 6313934d94
commit 670d6e8639
2 changed files with 17 additions and 14 deletions

View File

@@ -523,16 +523,6 @@ class BaseDefinition(object):
"""
return self._name.infer().get_type_hint()
def is_side_effect(self):
"""
Checks if a name is defined as ``self.foo = 3``. In case of self, this
function would return False, for foo it would return True.
"""
tree_name = self._name.tree_name
if tree_name is None:
return False
return tree_name.parent.type == 'trailer'
class Completion(BaseDefinition):
"""
@@ -717,6 +707,16 @@ class Definition(BaseDefinition):
else:
return self._name.tree_name.is_definition()
def is_side_effect(self):
"""
Checks if a name is defined as ``self.foo = 3``. In case of self, this
function would return False, for foo it would return True.
"""
tree_name = self._name.tree_name
if tree_name is None:
return False
return tree_name.is_definition() and tree_name.parent.type == 'trailer'
def __eq__(self, other):
return self._name.start_pos == other._name.start_pos \
and self.module_path == other.module_path \