|
1 | 1 | # pylint: disable=too-few-public-methods,missing-docstring
|
2 |
| -# pylint: disable=unused-private-member |
3 |
| -# pylint: disable=import-error |
4 | 2 | """check method hiding ancestor attribute
|
5 | 3 | """
|
6 |
| -import functools as ft |
7 |
| -import something_else as functools |
8 |
| - |
9 |
| - |
10 |
| -class Abcd: |
11 |
| - """dummy""" |
12 |
| - |
13 |
| - def __init__(self): |
14 |
| - self.abcd = 1 |
15 |
| - |
16 |
| - |
17 |
| -class Cdef(Abcd): |
18 |
| - """dummy""" |
19 |
| - |
20 |
| - def abcd(self): # [method-hidden] |
21 |
| - """test""" |
22 |
| - print(self) |
23 |
| - |
24 |
| - |
25 |
| -class AbcdMixin: |
26 |
| - def abcd(self): |
27 |
| - pass |
28 |
| - |
29 |
| - |
30 |
| -class Dabc(AbcdMixin, Abcd): |
31 |
| - def abcd(self): |
32 |
| - pass |
33 |
| - |
34 |
| - |
35 |
| -class CustomProperty: |
36 |
| - """dummy""" |
37 |
| - |
38 |
| - def __init__(self, _): |
39 |
| - pass |
40 |
| - |
41 |
| - def __get__(self, obj, __): |
42 |
| - if not obj: |
43 |
| - return self |
44 |
| - return 5 |
45 |
| - |
46 |
| - def __set__(self, _, __): |
47 |
| - pass |
48 |
| - |
49 |
| - |
50 |
| -class Ddef: |
51 |
| - """dummy""" |
52 |
| - |
53 |
| - def __init__(self): |
54 |
| - self.five = "five" |
55 |
| - |
56 |
| - @CustomProperty |
57 |
| - def five(self): |
58 |
| - """Always 5.""" |
59 |
| - return self |
60 |
| - |
61 |
| - |
62 |
| -def my_decorator(*args, **kwargs): |
63 |
| - return CustomProperty(*args, **kwargs) |
64 |
| - |
65 |
| - |
66 |
| -class Foo: |
67 |
| - def __init__(self): |
68 |
| - self._bar = 42 |
69 |
| - self._baz = 84 |
70 |
| - |
71 |
| - @my_decorator |
72 |
| - def method(self): # E0202 |
73 |
| - return self._baz |
74 |
| - |
75 |
| - @method.setter |
76 |
| - def method(self, value): |
77 |
| - self._baz = value |
78 |
| - |
79 |
| - def do_something_with_baz(self, value): |
80 |
| - self.method = value |
81 |
| - |
82 |
| - |
83 |
| -class One: |
84 |
| - def __init__(self, one=None): |
85 |
| - if one is not None: |
86 |
| - self.one = one |
87 |
| - |
88 |
| - def one(self): # [method-hidden] |
89 |
| - pass |
90 |
| - |
91 |
| - |
92 |
| -class Two(One): |
93 |
| - def one(self): |
94 |
| - pass |
95 |
| - |
96 |
| - |
97 |
| -try: |
98 |
| - import unknown as js |
99 |
| -except ImportError: |
100 |
| - import json as js |
101 |
| - |
102 |
| - |
103 |
| -class JsonEncoder(js.JSONEncoder): |
104 |
| - # pylint: disable=useless-super-delegation,super-with-arguments |
105 |
| - def default(self, o): |
106 |
| - return super(JsonEncoder, self).default(o) |
| 4 | +import something_else as functools # pylint: disable=import-error |
107 | 5 |
|
108 | 6 |
|
109 | 7 | class Parent:
|
110 | 8 | def __init__(self):
|
111 | 9 | self._protected = None
|
112 |
| - self._protected_two = None |
113 |
| - self._protected_three = None |
114 | 10 |
|
115 | 11 |
|
116 | 12 | class Child(Parent):
|
117 |
| - def _protected(self): # [method-hidden] |
118 |
| - pass |
119 |
| - |
120 |
| - |
121 |
| -class CachedChild(Parent): |
122 |
| - @ft.cached_property |
123 |
| - def _protected(self): |
124 |
| - pass |
125 |
| - |
126 |
| - @functools.cached_property |
127 |
| - def _protected_two(self): |
128 |
| - pass |
129 |
| - |
130 | 13 | @functools().cached_property
|
131 |
| - def _protected_three(self): |
132 |
| - pass |
133 |
| - |
134 |
| - |
135 |
| -class ParentTwo: |
136 |
| - def __init__(self): |
137 |
| - self.__private = None |
138 |
| - |
139 |
| - |
140 |
| -class ChildTwo(ParentTwo): |
141 |
| - def __private(self): |
| 14 | + def _protected(self): |
| 15 | + # This test case is only valid for python3.9 and above |
142 | 16 | pass
|
0 commit comments