12 from PyQt5.QtCore import QCoreApplication |
12 from PyQt5.QtCore import QCoreApplication |
13 |
13 |
14 _simplifyMessages = { |
14 _simplifyMessages = { |
15 "Y101": QCoreApplication.translate( |
15 "Y101": QCoreApplication.translate( |
16 "SimplifyChecker", |
16 "SimplifyChecker", |
17 """Multiple "isinstance()" calls which can be merged into a single """ |
17 '''Multiple "isinstance()" calls which can be merged into a single ''' |
18 """call for variable '{0}'"""), |
18 '''call for variable "{0}"'''), |
19 "Y102": QCoreApplication.translate( |
19 "Y102": QCoreApplication.translate( |
20 "SimplifyChecker", |
20 "SimplifyChecker", |
21 """Use a single if-statement instead of nested if-statements"""), |
21 '''Use a single if-statement instead of nested if-statements'''), |
22 "Y103": QCoreApplication.translate( |
22 "Y103": QCoreApplication.translate( |
23 "SimplifyChecker", |
23 "SimplifyChecker", |
24 """Return the condition "{0}" directly"""), |
24 '''Return the condition "{0}" directly'''), |
25 "Y104": QCoreApplication.translate( |
25 "Y104": QCoreApplication.translate( |
26 "SimplifyChecker", |
26 "SimplifyChecker", |
27 """Use "yield from {0}" """), |
27 '''Use "yield from {0}"'''), |
28 "Y105": QCoreApplication.translate( |
28 "Y105": QCoreApplication.translate( |
29 "SimplifyChecker", |
29 "SimplifyChecker", |
30 """Use "with contextlib.suppress({0}):" """), |
30 '''Use "with contextlib.suppress({0}):"'''), |
31 "Y106": QCoreApplication.translate( |
31 "Y106": QCoreApplication.translate( |
32 "SimplifyChecker", |
32 "SimplifyChecker", |
33 """Handle error-cases first"""), |
33 '''Handle error-cases first'''), |
34 "Y107": QCoreApplication.translate( |
34 "Y107": QCoreApplication.translate( |
35 "SimplifyChecker", |
35 "SimplifyChecker", |
36 """Don't use return in try/except and finally"""), |
36 '''Don't use return in try/except and finally'''), |
37 "Y108": QCoreApplication.translate( |
37 "Y108": QCoreApplication.translate( |
38 "SimplifyChecker", |
38 "SimplifyChecker", |
39 """Use ternary operator "{0} = {1} if {2} else {3}" """ |
39 '''Use ternary operator "{0} = {1} if {2} else {3}"''' |
40 """instead of if-else-block"""), |
40 '''instead of if-else-block'''), |
41 "Y109": QCoreApplication.translate( |
41 "Y109": QCoreApplication.translate( |
42 "SimplifyChecker", |
42 "SimplifyChecker", |
43 """Use "{0} in {1}" instead of "{2}" """), |
43 '''Use "{0} in {1}" instead of "{2}"'''), |
44 "Y110": QCoreApplication.translate( |
44 "Y110": QCoreApplication.translate( |
45 "SimplifyChecker", |
45 "SimplifyChecker", |
46 """Use "return any({0} for {1} in {2})" """), |
46 '''Use "return any({0} for {1} in {2})"'''), |
47 "Y111": QCoreApplication.translate( |
47 "Y111": QCoreApplication.translate( |
48 "SimplifyChecker", |
48 "SimplifyChecker", |
49 """Use "return all({0} for {1} in {2})" """), |
49 '''Use "return all({0} for {1} in {2})"'''), |
50 "Y112": QCoreApplication.translate( |
50 "Y112": QCoreApplication.translate( |
51 "SimplifyChecker", |
51 "SimplifyChecker", |
52 """Use "{0}" instead of "{1}" """), |
52 '''Use "{0}" instead of "{1}"'''), |
|
53 "Y113": QCoreApplication.translate( |
|
54 "SimplifyChecker", |
|
55 '''Use enumerate instead of "{0}"'''), |
|
56 "Y114": QCoreApplication.translate( |
|
57 "SimplifyChecker", |
|
58 '''Use logical or ("({0}) or ({1})") and a single body'''), |
|
59 "Y115": QCoreApplication.translate( |
|
60 "SimplifyChecker", |
|
61 '''Use context handler for opening files'''), |
|
62 "Y116": QCoreApplication.translate( |
|
63 "SimplifyChecker", |
|
64 '''Use a dictionary lookup instead of 3+ if/elif-statements: ''' |
|
65 '''return {0}'''), |
53 } |
66 } |
54 |
67 |
55 _simplifyMessagesSampleArgs = { |
68 _simplifyMessagesSampleArgs = { |
56 "Y101": ["foo"], |
69 "Y101": ["foo"], |
57 "Y103": ["foo != bar"], |
70 "Y103": ["foo != bar"], |
58 "Y104": ["iterable"], |
71 "Y104": ["iterable"], |
59 "Y105": ["Exception"], |
72 "Y105": ["Exception"], |
60 "Y108": ["foo", "bar", "condition", "baz"], |
73 "Y108": ["foo", "bar", "condition", "baz"], |
61 "Y109": ["foo", "[1, 2]", "foo == 1 or foo == 2"], |
74 "Y109": ["foo", "[1, 42]", "foo == 1 or foo == 42"], |
62 "Y110": ["check", "foo", "iterable"], |
75 "Y110": ["check", "foo", "iterable"], |
63 "Y111": ["check", "foo", "iterable"], |
76 "Y111": ["check", "foo", "iterable"], |
64 "Y112": ["FOO", "foo"], |
77 "Y112": ["FOO", "foo"], |
|
78 "Y113": ["foo"], |
|
79 "Y114": ["foo > 42", "bar < 42"], |
|
80 "Y116": ["mapping.get(foo, 42)"] |
65 } |
81 } |