diff --git a/jedi/api/classes.py b/jedi/api/classes.py index 68f2efb2..7d506d3f 100644 --- a/jedi/api/classes.py +++ b/jedi/api/classes.py @@ -231,8 +231,7 @@ class BaseName(object): return None return start_pos[1] - @property - def definition_start_position(self): + def get_definition_start_position(self): """ The (row, column) of the start of the definition range. Rows start with 1, columns start with 0. @@ -244,8 +243,7 @@ class BaseName(object): return self._name.start_pos return definition.start_pos - @property - def definition_end_position(self): + def get_definition_end_position(self): """ The (row, column) of the end of the definition range. Rows start with 1, columns start with 0. diff --git a/test/test_api/test_classes.py b/test/test_api/test_classes.py index 38d7b503..24cf7f36 100644 --- a/test/test_api/test_classes.py +++ b/test/test_api/test_classes.py @@ -604,6 +604,7 @@ def test_get_type_hint(Script, code, expected, skip_pre_python36): def test_pseudotreenameclass_type(Script): assert Script('from typing import Any\n').get_names()[0].type == 'class' + def test_definition_start_end_position(Script): '''Tests for definition_start_position and definition_end_position''' code = '\n'.join([ @@ -624,17 +625,17 @@ def test_definition_start_end_position(Script): assert len(names) == 5 a_func, var1, AClass, hello, func_var = names - assert a_func.definition_start_position == (1, 0) - assert a_func.definition_end_position == (2, 16) + assert a_func.get_definition_start_position() == (1, 0) + assert a_func.get_definition_end_position() == (2, 16) - assert var1.definition_start_position == (4, 0) - assert var1.definition_end_position == (4, 9) + assert var1.get_definition_start_position() == (4, 0) + assert var1.get_definition_end_position() == (4, 9) - assert AClass.definition_start_position == (6, 0) - assert AClass.definition_end_position == (11, 23) + assert AClass.get_definition_start_position() == (6, 0) + assert AClass.get_definition_end_position() == (11, 23) - assert hello.definition_start_position == (9, 4) - assert hello.definition_end_position == (11, 23) + assert hello.get_definition_start_position() == (9, 4) + assert hello.get_definition_end_position() == (11, 23) - assert func_var.definition_start_position == (10, 8) - assert func_var.definition_end_position == (10, 20) + assert func_var.get_definition_start_position() == (10, 8) + assert func_var.get_definition_end_position() == (10, 20)