blob: 1814f34459d5a082152c044aef5472ca0f9d865f (
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
44
45
46
47
48
49
50
51
52
53
54
55
|
"""Check that instantiating a class with
`abc.ABCMeta` as metaclass fails if it defines
abstract methods.
"""
# pylint: disable=too-few-public-methods, missing-docstring, abstract-class-not-used, no-init
__revision__ = 0
import abc
class GoodClass(object, metaclass=abc.ABCMeta):
pass
class SecondGoodClass(object, metaclass=abc.ABCMeta):
def test(self):
""" do nothing. """
pass
class ThirdGoodClass(object, metaclass=abc.ABCMeta):
""" This should not raise the warning. """
def test(self):
raise NotImplementedError()
class FourthGoodClass(abc.ABC):
""" Neither this. """
def test(self):
pass
class BadClass(object, metaclass=abc.ABCMeta):
@abc.abstractmethod
def test(self):
""" do nothing. """
pass
class SecondBadClass(object, metaclass=abc.ABCMeta):
@property
@abc.abstractmethod
def test(self):
""" do nothing. """
class ThirdBadClass(abc.ABC):
@abc.abstractmethod
def test(self):
pass
def main():
""" do nothing """
GoodClass()
SecondGoodClass()
ThirdGoodClass()
FourthGoodClass()
BadClass()
SecondBadClass()
ThirdBadClass()
|