-
-
Notifications
You must be signed in to change notification settings - Fork 307
Closed
pylint-dev/pylint
#4522Labels
Description
Steps to reproduce
- 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. - 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 = valueCurrent 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.