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

Slots and Generics handling broken since 2.5.3 #999

Closed
svenpanne opened this issue May 25, 2021 · 1 comment · Fixed by pylint-dev/pylint#4522
Closed

Slots and Generics handling broken since 2.5.3 #999

svenpanne opened this issue May 25, 2021 · 1 comment · Fixed by pylint-dev/pylint#4522

Comments

@svenpanne
Copy link

Steps to reproduce

  1. Build a venv with pylint 2.7.4 and astroid 2.5.3, e.g. via pipenv install pylint==2.7.4 astroid==2.5.3.
  2. Run pylint on the following file via e.g. pipenv run pylint --disable=all --enable=assigning-non-slot broken.py:
from typing import Generic, TypeVar

T = TypeVar("T")


class Base(Generic[T]):
    __slots__ = ()


class Foo(Base[T]):
    __slots__ = ['_value']

    def __init__(self, value: T):
        # Triggers assigning-non-slot (Assigning to attribute '_value' not defined
        # in class slots), works when using Generic[T] directly as a base class.
        self._value = value

Current behavior

The steps above incorrectly trigger the assigning-non-slot check.

Expected behavior

No complaints from pylint. If you go back to astroid 2.5.2, the above works. If Foo directly inherits from Generic[T], the above works, too.

Bisecting shows that the commit cd0f896 introduced the regression. Therefore, every astroid >= 2.5.3 is buggy, as is every pylint >= 2.8.0.

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

As already mentioned above, the bug is present in every release containing the above commit, i.e. from 2.5.3 onwards.

@hippo91
Copy link
Contributor

hippo91 commented May 27, 2021

@svenpanne thanks for the report.

LarsMichelsen pushed a commit to Checkmk/checkmk that referenced this issue Sep 2, 2021
The upstream issue was fixed:
pylint-dev/astroid#999

our pylint will be pinned to version 2.9.6 for some time

Change-Id: Ie70ff7b13ceef6ba8990e6b7a29cbdb2568f5d06
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.

2 participants