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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
"""Test abstract-method warning."""
from __future__ import print_function
# pylint: disable=missing-docstring, no-init, no-self-use
# pylint: disable=too-few-public-methods, useless-object-inheritance
import abc
class Abstract(object):
def aaaa(self):
"""should be overridden in concrete class"""
raise NotImplementedError()
def bbbb(self):
"""should be overridden in concrete class"""
raise NotImplementedError()
class AbstractB(Abstract):
"""Abstract class.
this class is checking that it does not output an error msg for
unimplemeted methods in abstract classes
"""
def cccc(self):
"""should be overridden in concrete class"""
raise NotImplementedError()
class Concrete(Abstract): # [abstract-method]
"""Concrete class"""
def aaaa(self):
"""overidden form Abstract"""
class Structure(object):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __iter__(self):
pass
@abc.abstractmethod
def __len__(self):
pass
@abc.abstractmethod
def __contains__(self, _):
pass
@abc.abstractmethod
def __hash__(self):
pass
# +1: [abstract-method, abstract-method, abstract-method]
class Container(Structure):
def __contains__(self, _):
pass
# +1: [abstract-method, abstract-method, abstract-method]
class Sizable(Structure):
def __len__(self):
pass
# +1: [abstract-method, abstract-method, abstract-method]
class Hashable(Structure):
__hash__ = 42
# +1: [abstract-method, abstract-method, abstract-method]
class Iterator(Structure):
def keys(self):
return iter([1, 2, 3])
__iter__ = keys
class AbstractSizable(Structure):
@abc.abstractmethod
def length(self):
pass
__len__ = length
class GoodComplexMRO(Container, Iterator, Sizable, Hashable):
pass
# +1: [abstract-method, abstract-method, abstract-method]
class BadComplexMro(Container, Iterator, AbstractSizable):
pass
|