Skip to content
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
@SoggyBottomBoy

Description

@SoggyBottomBoy

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.

image
image

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

image
image

Jedi

In comparison Jedi has the following behaviour:
prop2 is still recognised as a method but has a return type of MySubClass

image

even though autocompletion still completes prop2 as a method by removing the parenthesis the field of prop2 are inferred

image

Apologies if this is a duplicate

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions