This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
Properties/Fields return the setter implementation #2049
Open
Description
Environment data
- Language Server version: XXX
- OS and version: Windows 10
- Python version (& distribution if applicable, e.g. Anaconda): Anaconda Python 3.7
Code Snippet / Additional Information
class MySubClass():
def __init__(self, a, b):
self._a = a
self._b = b
@property
def a(self) -> int:
return self._a
@a.setter
def a(self, value: int):
self._a = value
@property
def b(self) -> str:
return self._b
@b.setter
def b(self, value: str):
self._b = value
class MyClass():
def __init__(self, arg1: MySubClass, arg2: MySubClass):
self.prop1 = arg1
self._prop2 = arg2
@property
def prop2(self) -> MySubClass:
return self._prop2
@prop2.setter
def prop2(self, value: MySubClass):
self._prop2 = value
my_sub_object_a = MySubClass(1, "a")
my_sub_object_b = MySubClass(2, "b")
my_object: MyClass = MyClass(my_sub_object_a, my_sub_object_b)
Behaviour
prop1 is correctly inferred as a value of type MySubClass, the autocompletion has the members of MySubClass available.
prop2 is inferred as a method with the latest implementation (i.e. setter), as the setter method has no return there is no autocompletion on prop2
Jedi
In comparison Jedi has the following behaviour:
prop2 is still recognised as a method but has a return type of MySubClass
even though autocompletion still completes prop2 as a method by removing the parenthesis the field of prop2 are inferred
Apologies if this is a duplicate
Metadata
Metadata
Assignees
Labels
No labels