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 / input / func_typecheck_callfunc_assigment.py @ 745
History | View | Annotate | Download (1.46 KB)
1 |
|
---|---|
2 |
"""check assignment to function call where the function doesn't return
|
3 |
|
4 |
'E1111': ('Assigning to function call which doesn\'t return',
|
5 |
'Used when an assignment is done on a function call but the \
|
6 |
infered function doesn\'t return anything.'),
|
7 |
'W1111': ('Assigning to function call which only returns None',
|
8 |
'Used when an assignment is done on a function call but the \
|
9 |
infered function returns nothing but None.'),
|
10 |
|
11 |
"""
|
12 |
from __future__ import generators, print_function |
13 |
|
14 |
#pylint: disable=redefined-variable-type
|
15 |
|
16 |
def func_no_return(): |
17 |
"""function without return"""
|
18 |
print('dougloup')
|
19 |
|
20 |
A = func_no_return() |
21 |
|
22 |
|
23 |
def func_return_none(): |
24 |
"""function returning none"""
|
25 |
print('dougloup')
|
26 |
return None |
27 |
|
28 |
A = func_return_none() |
29 |
|
30 |
|
31 |
def func_implicit_return_none(): |
32 |
"""Function returning None from bare return statement."""
|
33 |
return
|
34 |
|
35 |
A = func_implicit_return_none() |
36 |
|
37 |
|
38 |
def func_return_none_and_smth(): |
39 |
"""function returning none and something else"""
|
40 |
print('dougloup')
|
41 |
if 2 or 3: |
42 |
return None |
43 |
return 3 |
44 |
|
45 |
A = func_return_none_and_smth() |
46 |
|
47 |
def generator(): |
48 |
"""no problemo"""
|
49 |
yield 2 |
50 |
|
51 |
A = generator() |
52 |
|
53 |
class Abstract(object): |
54 |
"""bla bla"""
|
55 |
|
56 |
def abstract_method(self): |
57 |
"""use to return something in concrete implementation"""
|
58 |
raise NotImplementedError |
59 |
|
60 |
def use_abstract(self): |
61 |
"""should not issue E1111"""
|
62 |
var = self.abstract_method()
|
63 |
print(var) |