Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
here-abarany opened this issue Jul 11, 2024 · 2 comments · Fixed by #2468
Closed
Assignees
Milestone

Comments

@here-abarany
Copy link

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

@here-abarany
Copy link
Author

here-abarany commented Jul 11, 2024

For now I can work around the issue without explicitly pinning the package by excluding the buggy version in requirements.txt. (astroid!=3.2.3)

@jacobtylerwalls
Copy link
Member

jacobtylerwalls commented Jul 11, 2024

Thanks for the report. Just a heads up that the fix might turn out to be in pylint, so it's too early to know if the pin/skip you suggest will be the one you eventually desire.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants