summaryrefslogtreecommitdiff
path: root/tests/functional/r/redefined/redefined_slots.py
blob: 28f05fbfd487e3e9aca0a6ce9e438a2b8ffa2ac9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Checks that a subclass does not redefine a slot which has been defined in a parent class."""

# pylint: disable=too-few-public-methods, invalid-slots-object

from collections import deque


class Base:
    """Class defining the `a`, `b` & `deque.__name__` slots"""
    __slots__ = ("a", "b", deque.__name__)


class Subclass1(Base):
    """Redefining the `a` & `deque.__name__` slots & adding the `d` & `e` slots"""
    __slots__ = ("a", deque.__name__, "d", "e")  # [redefined-slots-in-subclass]


class Subclass2(Base):
    """Adding the `f`, `g` & `h` slots"""
    __slots__ = ("f", "g", "h")


class Base2:
    """Class defining the `i`, `j` & `k` slots"""
    __slots__ = ("i", "j", "k")


class Subclass3(Base, Base2):
    """Adding the `l`, `m`, `n` slots
       Redefining the `a`, `b`, & `c` slot already defined in `Base`
       Redefining the `i`, `j`, `k` slot already defined in `Base2`
    """
    __slots__ = ("a", "b", "c", "i", "j", "k", "l", "m", "n")  # [redefined-slots-in-subclass]


# https://github.com/PyCQA/pylint/issues/6100
class MyClass:
    """No crash when the type of the slot is not a Const or a str"""
    __slots__ = [str]