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_py3.py @ 745
History | View | Annotate | Download (1.93 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, metaclass=abc.ABCMeta): |
36 |
@abc.abstractmethod
|
37 |
def __iter__(self): |
38 |
pass
|
39 |
@abc.abstractmethod
|
40 |
def __len__(self): |
41 |
pass
|
42 |
@abc.abstractmethod
|
43 |
def __contains__(self, _): |
44 |
pass
|
45 |
@abc.abstractmethod
|
46 |
def __hash__(self): |
47 |
pass
|
48 |
|
49 |
|
50 |
# +1: [abstract-method, abstract-method, abstract-method]
|
51 |
class Container(Structure): |
52 |
def __contains__(self, _): |
53 |
pass
|
54 |
|
55 |
|
56 |
# +1: [abstract-method, abstract-method, abstract-method]
|
57 |
class Sizable(Structure): |
58 |
def __len__(self): |
59 |
pass
|
60 |
|
61 |
|
62 |
# +1: [abstract-method, abstract-method, abstract-method]
|
63 |
class Hashable(Structure): |
64 |
__hash__ = 42
|
65 |
|
66 |
|
67 |
# +1: [abstract-method, abstract-method, abstract-method]
|
68 |
class Iterator(Structure): |
69 |
def keys(self): |
70 |
return iter([1, 2, 3]) |
71 |
|
72 |
__iter__ = keys |
73 |
|
74 |
|
75 |
class AbstractSizable(Structure): |
76 |
@abc.abstractmethod
|
77 |
def length(self): |
78 |
pass
|
79 |
__len__ = length |
80 |
|
81 |
|
82 |
class GoodComplexMRO(Container, Iterator, Sizable, Hashable): |
83 |
pass
|
84 |
|
85 |
|
86 |
# +1: [abstract-method, abstract-method, abstract-method]
|
87 |
class BadComplexMro(Container, Iterator, AbstractSizable): |
88 |
pass
|