summaryrefslogtreecommitdiff
path: root/tests/functional/p/protected_access.py
blob: 209f571c446d6b5155b2725447d8b4516b6806b8 (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
40
41
42
43
"""Tests for protected_access"""
# pylint: disable=missing-class-docstring, too-few-public-methods, pointless-statement
# pylint: disable=missing-function-docstring, invalid-metaclass, no-member
# pylint: disable=no-self-argument, undefined-variable, unused-variable

# Test that exclude-protected can be used to exclude names from protected-access warning
class Protected:
    def __init__(self):
        self._meta = 42
        self._manager = 24
        self._teta = 29


OBJ = Protected()
OBJ._meta
OBJ._manager
OBJ._teta  # [protected-access]


# Make sure protect-access doesn't raise an exception Uninferable attributes
class MC:
    @property
    def nargs(self):
        return 1 if self._nargs else 2


class Application(metaclass=MC):
    def __no_special__(cls):
        nargs = obj._nargs  # [protected-access]


class Light:
    @property
    def _light_internal(self) -> None:
        return None

    @staticmethod
    def func(light) -> None:
        print(light._light_internal)  # [protected-access]


def func(light: Light) -> None:
    print(light._light_internal)  # [protected-access]