gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.app / org.gvsig.scripting.app.mainplugin / src / main / resources-plugin / scripting / lib / pylint / test / functional / abstract_method_py2.py @ 745
History | View | Annotate | Download (1.94 KB)
1 |
"""Test abstract-method warning."""
|
---|---|
2 |
from __future__ import print_function |
3 |
|
4 |
# pylint: disable=missing-docstring, no-init, no-self-use
|
5 |
# pylint: disable=too-few-public-methods
|
6 |
import abc |
7 |
|
8 |
class Abstract(object): |
9 |
def aaaa(self): |
10 |
"""should be overridden in concrete class"""
|
11 |
raise NotImplementedError() |
12 |
|
13 |
def bbbb(self): |
14 |
"""should be overridden in concrete class"""
|
15 |
raise NotImplementedError() |
16 |
|
17 |
|
18 |
class AbstractB(Abstract): |
19 |
"""Abstract class.
|
20 |
|
21 |
this class is checking that it does not output an error msg for
|
22 |
unimplemeted methods in abstract classes
|
23 |
"""
|
24 |
def cccc(self): |
25 |
"""should be overridden in concrete class"""
|
26 |
raise NotImplementedError() |
27 |
|
28 |
class Concret(Abstract): # [abstract-method] |
29 |
"""Concrete class"""
|
30 |
|
31 |
def aaaa(self): |
32 |
"""overidden form Abstract"""
|
33 |
|
34 |
|
35 |
class Structure(object): |
36 |
__metaclass__ = abc.ABCMeta |
37 |
|
38 |
@abc.abstractmethod
|
39 |
def __iter__(self): |
40 |
pass
|
41 |
@abc.abstractmethod
|
42 |
def __len__(self): |
43 |
pass
|
44 |
@abc.abstractmethod
|
45 |
def __contains__(self, _): |
46 |
pass
|
47 |
@abc.abstractmethod
|
48 |
def __hash__(self): |
49 |
pass
|
50 |
|
51 |
|
52 |
# +1: [abstract-method, abstract-method, abstract-method]
|
53 |
class Container(Structure): |
54 |
def __contains__(self, _): |
55 |
pass
|
56 |
|
57 |
|
58 |
# +1: [abstract-method, abstract-method, abstract-method]
|
59 |
class Sizable(Structure): |
60 |
def __len__(self): |
61 |
pass
|
62 |
|
63 |
|
64 |
# +1: [abstract-method, abstract-method, abstract-method]
|
65 |
class Hashable(Structure): |
66 |
__hash__ = 42
|
67 |
|
68 |
|
69 |
# +1: [abstract-method, abstract-method, abstract-method]
|
70 |
class Iterator(Structure): |
71 |
def keys(self): |
72 |
return iter([1, 2, 3]) |
73 |
|
74 |
__iter__ = keys |
75 |
|
76 |
|
77 |
class AbstractSizable(Structure): |
78 |
@abc.abstractmethod
|
79 |
def length(self): |
80 |
pass
|
81 |
__len__ = length |
82 |
|
83 |
|
84 |
class GoodComplexMRO(Container, Iterator, Sizable, Hashable): |
85 |
pass
|
86 |
|
87 |
|
88 |
# +1: [abstract-method, abstract-method, abstract-method]
|
89 |
class BadComplexMro(Container, Iterator, AbstractSizable): |
90 |
pass
|