Skip to content

Pylint checks against incorrect type with properties that have a getter and setter #2467

@here-abarany

Description

@here-abarany

Steps to reproduce

  1. Install pylint 3.2.5 with astroid 3.2.3
  2. Set up a Python script with the following code:
    class Point:
       def __init__(self, x: float, y: float):
           self._x = x
           self._y = y
    
       @property
       def x(self) -> float:
           return self._x
    
       @x.setter
       def x(self, x: float):
           self._x = x
    
       @property
       def y(self) -> float:
           return self._y
    
       @y.setter
       def y(self, y: float):
           self._y = y
    
    test = Point(1.2, 3.4)
    value_neg = -test.x
  3. Run pylint

Current behavior

The following error is emitted: E1130: bad operand type for unary -: Point (invalid-unary-operand-type)

Expected behavior

pylint reports no errors

python -c "from astroid import __pkginfo__; print(__pkginfo__.version)" output

3.2.3

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions