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 / newstyle_properties.py @ 745
History | View | Annotate | Download (1.11 KB)
1 |
# pylint: disable=too-few-public-methods
|
---|---|
2 |
"""Test properties on old style classes and property.setter/deleter usage"""
|
3 |
|
4 |
|
5 |
def getter(self): |
6 |
"""interesting"""
|
7 |
return self |
8 |
|
9 |
class CorrectClass(object): |
10 |
"""correct usage"""
|
11 |
method = property(getter, doc='hop') |
12 |
|
13 |
class OldStyleClass: # <3.0:[old-style-class] |
14 |
"""bad usage"""
|
15 |
method = property(getter, doc='hop') # <3.0:[property-on-old-class] |
16 |
|
17 |
def __init__(self): |
18 |
pass
|
19 |
|
20 |
|
21 |
def decorator(func): |
22 |
"""Redefining decorator."""
|
23 |
def wrapped(self): |
24 |
"""Wrapper function."""
|
25 |
return func(self) |
26 |
return wrapped
|
27 |
|
28 |
|
29 |
class SomeClass(object): |
30 |
"""another docstring"""
|
31 |
|
32 |
def __init__(self): |
33 |
self._prop = None |
34 |
|
35 |
@property
|
36 |
def prop(self): |
37 |
"""I'm the 'prop' property."""
|
38 |
return self._prop |
39 |
|
40 |
@prop.setter
|
41 |
def prop(self, value): |
42 |
"""I'm the 'prop' property."""
|
43 |
self._prop = value
|
44 |
|
45 |
@prop.deleter
|
46 |
def prop(self): |
47 |
"""I'm the 'prop' property."""
|
48 |
del self._prop |
49 |
|
50 |
@decorator
|
51 |
def noregr(self): |
52 |
"""Just a normal method with a decorator."""
|
53 |
return self.prop |