Show More
@@ -1,253 +1,234 b'' | |||||
1 | $ cat > correct.py <<EOF |
|
1 | $ cat > correct.py <<EOF | |
2 | > def toto(arg1, arg2): |
|
2 | > def toto(arg1, arg2): | |
3 | > del arg2 |
|
3 | > del arg2 | |
4 | > return (5 + 6, 9) |
|
4 | > return (5 + 6, 9) | |
5 | > EOF |
|
5 | > EOF | |
6 | $ cat > wrong.py <<EOF |
|
6 | $ cat > wrong.py <<EOF | |
7 | > def toto( arg1, arg2): |
|
7 | > def toto( arg1, arg2): | |
8 | > del(arg2) |
|
8 | > del(arg2) | |
9 | > return ( 5+6, 9) |
|
9 | > return ( 5+6, 9) | |
10 | > EOF |
|
10 | > EOF | |
11 | $ cat > quote.py <<EOF |
|
11 | $ cat > quote.py <<EOF | |
12 | > # let's use quote in comments |
|
12 | > # let's use quote in comments | |
13 | > (''' ( 4x5 ) |
|
13 | > (''' ( 4x5 ) | |
14 | > but """\\''' and finally''', |
|
14 | > but """\\''' and finally''', | |
15 | > """let's fool checkpatch""", '1+2', |
|
15 | > """let's fool checkpatch""", '1+2', | |
16 | > '"""', 42+1, """and |
|
16 | > '"""', 42+1, """and | |
17 | > ( 4-1 ) """, "( 1+1 )\" and ") |
|
17 | > ( 4-1 ) """, "( 1+1 )\" and ") | |
18 | > a, '\\\\\\\\', "\\\\\\" x-2", "c-1" |
|
18 | > a, '\\\\\\\\', "\\\\\\" x-2", "c-1" | |
19 | > EOF |
|
19 | > EOF | |
20 | $ cat > non-py24.py <<EOF |
|
|||
21 | > # try/except/finally block does not exist in Python 2.4 |
|
|||
22 | > try: |
|
|||
23 | > pass |
|
|||
24 | > except StandardError, inst: |
|
|||
25 | > pass |
|
|||
26 | > finally: |
|
|||
27 | > pass |
|
|||
28 | > |
|
|||
29 | > # nested try/finally+try/except is allowed |
|
|||
30 | > try: |
|
|||
31 | > try: |
|
|||
32 | > pass |
|
|||
33 | > except StandardError, inst: |
|
|||
34 | > pass |
|
|||
35 | > finally: |
|
|||
36 | > pass |
|
|||
37 | > |
|
|||
38 | > EOF |
|
|||
39 | $ cat > classstyle.py <<EOF |
|
20 | $ cat > classstyle.py <<EOF | |
40 | > class newstyle_class(object): |
|
21 | > class newstyle_class(object): | |
41 | > pass |
|
22 | > pass | |
42 | > |
|
23 | > | |
43 | > class oldstyle_class: |
|
24 | > class oldstyle_class: | |
44 | > pass |
|
25 | > pass | |
45 | > |
|
26 | > | |
46 | > class empty(): |
|
27 | > class empty(): | |
47 | > pass |
|
28 | > pass | |
48 | > |
|
29 | > | |
49 | > no_class = 1: |
|
30 | > no_class = 1: | |
50 | > pass |
|
31 | > pass | |
51 | > EOF |
|
32 | > EOF | |
52 | $ check_code="$TESTDIR"/../contrib/check-code.py |
|
33 | $ check_code="$TESTDIR"/../contrib/check-code.py | |
53 |
$ "$check_code" ./wrong.py ./correct.py ./quote.py ./ |
|
34 | $ "$check_code" ./wrong.py ./correct.py ./quote.py ./classstyle.py | |
54 | ./wrong.py:1: |
|
35 | ./wrong.py:1: | |
55 | > def toto( arg1, arg2): |
|
36 | > def toto( arg1, arg2): | |
56 | gratuitous whitespace in () or [] |
|
37 | gratuitous whitespace in () or [] | |
57 | ./wrong.py:2: |
|
38 | ./wrong.py:2: | |
58 | > del(arg2) |
|
39 | > del(arg2) | |
59 | Python keyword is not a function |
|
40 | Python keyword is not a function | |
60 | ./wrong.py:3: |
|
41 | ./wrong.py:3: | |
61 | > return ( 5+6, 9) |
|
42 | > return ( 5+6, 9) | |
62 | gratuitous whitespace in () or [] |
|
43 | gratuitous whitespace in () or [] | |
63 | missing whitespace in expression |
|
44 | missing whitespace in expression | |
64 | ./quote.py:5: |
|
45 | ./quote.py:5: | |
65 | > '"""', 42+1, """and |
|
46 | > '"""', 42+1, """and | |
66 | missing whitespace in expression |
|
47 | missing whitespace in expression | |
67 | ./classstyle.py:4: |
|
48 | ./classstyle.py:4: | |
68 | > class oldstyle_class: |
|
49 | > class oldstyle_class: | |
69 | old-style class, use class foo(object) |
|
50 | old-style class, use class foo(object) | |
70 | ./classstyle.py:7: |
|
51 | ./classstyle.py:7: | |
71 | > class empty(): |
|
52 | > class empty(): | |
72 | class foo() creates old style object, use class foo(object) |
|
53 | class foo() creates old style object, use class foo(object) | |
73 | [1] |
|
54 | [1] | |
74 | $ cat > python3-compat.py << EOF |
|
55 | $ cat > python3-compat.py << EOF | |
75 | > foo <> bar |
|
56 | > foo <> bar | |
76 | > reduce(lambda a, b: a + b, [1, 2, 3, 4]) |
|
57 | > reduce(lambda a, b: a + b, [1, 2, 3, 4]) | |
77 | > dict(key=value) |
|
58 | > dict(key=value) | |
78 | > EOF |
|
59 | > EOF | |
79 | $ "$check_code" python3-compat.py |
|
60 | $ "$check_code" python3-compat.py | |
80 | python3-compat.py:1: |
|
61 | python3-compat.py:1: | |
81 | > foo <> bar |
|
62 | > foo <> bar | |
82 | <> operator is not available in Python 3+, use != |
|
63 | <> operator is not available in Python 3+, use != | |
83 | python3-compat.py:2: |
|
64 | python3-compat.py:2: | |
84 | > reduce(lambda a, b: a + b, [1, 2, 3, 4]) |
|
65 | > reduce(lambda a, b: a + b, [1, 2, 3, 4]) | |
85 | reduce is not available in Python 3+ |
|
66 | reduce is not available in Python 3+ | |
86 | python3-compat.py:3: |
|
67 | python3-compat.py:3: | |
87 | > dict(key=value) |
|
68 | > dict(key=value) | |
88 | dict() is different in Py2 and 3 and is slower than {} |
|
69 | dict() is different in Py2 and 3 and is slower than {} | |
89 | [1] |
|
70 | [1] | |
90 |
|
71 | |||
91 | $ cat > is-op.py <<EOF |
|
72 | $ cat > is-op.py <<EOF | |
92 | > # is-operator comparing number or string literal |
|
73 | > # is-operator comparing number or string literal | |
93 | > x = None |
|
74 | > x = None | |
94 | > y = x is 'foo' |
|
75 | > y = x is 'foo' | |
95 | > y = x is "foo" |
|
76 | > y = x is "foo" | |
96 | > y = x is 5346 |
|
77 | > y = x is 5346 | |
97 | > y = x is -6 |
|
78 | > y = x is -6 | |
98 | > y = x is not 'foo' |
|
79 | > y = x is not 'foo' | |
99 | > y = x is not "foo" |
|
80 | > y = x is not "foo" | |
100 | > y = x is not 5346 |
|
81 | > y = x is not 5346 | |
101 | > y = x is not -6 |
|
82 | > y = x is not -6 | |
102 | > EOF |
|
83 | > EOF | |
103 |
|
84 | |||
104 | $ "$check_code" ./is-op.py |
|
85 | $ "$check_code" ./is-op.py | |
105 | ./is-op.py:3: |
|
86 | ./is-op.py:3: | |
106 | > y = x is 'foo' |
|
87 | > y = x is 'foo' | |
107 | object comparison with literal |
|
88 | object comparison with literal | |
108 | ./is-op.py:4: |
|
89 | ./is-op.py:4: | |
109 | > y = x is "foo" |
|
90 | > y = x is "foo" | |
110 | object comparison with literal |
|
91 | object comparison with literal | |
111 | ./is-op.py:5: |
|
92 | ./is-op.py:5: | |
112 | > y = x is 5346 |
|
93 | > y = x is 5346 | |
113 | object comparison with literal |
|
94 | object comparison with literal | |
114 | ./is-op.py:6: |
|
95 | ./is-op.py:6: | |
115 | > y = x is -6 |
|
96 | > y = x is -6 | |
116 | object comparison with literal |
|
97 | object comparison with literal | |
117 | ./is-op.py:7: |
|
98 | ./is-op.py:7: | |
118 | > y = x is not 'foo' |
|
99 | > y = x is not 'foo' | |
119 | object comparison with literal |
|
100 | object comparison with literal | |
120 | ./is-op.py:8: |
|
101 | ./is-op.py:8: | |
121 | > y = x is not "foo" |
|
102 | > y = x is not "foo" | |
122 | object comparison with literal |
|
103 | object comparison with literal | |
123 | ./is-op.py:9: |
|
104 | ./is-op.py:9: | |
124 | > y = x is not 5346 |
|
105 | > y = x is not 5346 | |
125 | object comparison with literal |
|
106 | object comparison with literal | |
126 | ./is-op.py:10: |
|
107 | ./is-op.py:10: | |
127 | > y = x is not -6 |
|
108 | > y = x is not -6 | |
128 | object comparison with literal |
|
109 | object comparison with literal | |
129 | [1] |
|
110 | [1] | |
130 |
|
111 | |||
131 | $ cat > for-nolineno.py <<EOF |
|
112 | $ cat > for-nolineno.py <<EOF | |
132 | > except: |
|
113 | > except: | |
133 | > EOF |
|
114 | > EOF | |
134 | $ "$check_code" for-nolineno.py --nolineno |
|
115 | $ "$check_code" for-nolineno.py --nolineno | |
135 | for-nolineno.py:0: |
|
116 | for-nolineno.py:0: | |
136 | > except: |
|
117 | > except: | |
137 | naked except clause |
|
118 | naked except clause | |
138 | [1] |
|
119 | [1] | |
139 |
|
120 | |||
140 | $ cat > warning.t <<EOF |
|
121 | $ cat > warning.t <<EOF | |
141 | > $ function warnonly { |
|
122 | > $ function warnonly { | |
142 | > > } |
|
123 | > > } | |
143 | > $ diff -N aaa |
|
124 | > $ diff -N aaa | |
144 | > $ function onwarn {} |
|
125 | > $ function onwarn {} | |
145 | > EOF |
|
126 | > EOF | |
146 | $ "$check_code" warning.t |
|
127 | $ "$check_code" warning.t | |
147 | $ "$check_code" --warn warning.t |
|
128 | $ "$check_code" --warn warning.t | |
148 | warning.t:1: |
|
129 | warning.t:1: | |
149 | > $ function warnonly { |
|
130 | > $ function warnonly { | |
150 | warning: don't use 'function', use old style |
|
131 | warning: don't use 'function', use old style | |
151 | warning.t:3: |
|
132 | warning.t:3: | |
152 | > $ diff -N aaa |
|
133 | > $ diff -N aaa | |
153 | warning: don't use 'diff -N' |
|
134 | warning: don't use 'diff -N' | |
154 | warning.t:4: |
|
135 | warning.t:4: | |
155 | > $ function onwarn {} |
|
136 | > $ function onwarn {} | |
156 | warning: don't use 'function', use old style |
|
137 | warning: don't use 'function', use old style | |
157 | [1] |
|
138 | [1] | |
158 | $ cat > raise-format.py <<EOF |
|
139 | $ cat > raise-format.py <<EOF | |
159 | > raise SomeException, message |
|
140 | > raise SomeException, message | |
160 | > # this next line is okay |
|
141 | > # this next line is okay | |
161 | > raise SomeException(arg1, arg2) |
|
142 | > raise SomeException(arg1, arg2) | |
162 | > EOF |
|
143 | > EOF | |
163 | $ "$check_code" not-existing.py raise-format.py |
|
144 | $ "$check_code" not-existing.py raise-format.py | |
164 | Skipping*not-existing.py* (glob) |
|
145 | Skipping*not-existing.py* (glob) | |
165 | raise-format.py:1: |
|
146 | raise-format.py:1: | |
166 | > raise SomeException, message |
|
147 | > raise SomeException, message | |
167 | don't use old-style two-argument raise, use Exception(message) |
|
148 | don't use old-style two-argument raise, use Exception(message) | |
168 | [1] |
|
149 | [1] | |
169 |
|
150 | |||
170 | $ cat > rst.py <<EOF |
|
151 | $ cat > rst.py <<EOF | |
171 | > """problematic rst text |
|
152 | > """problematic rst text | |
172 | > |
|
153 | > | |
173 | > .. note:: |
|
154 | > .. note:: | |
174 | > wrong |
|
155 | > wrong | |
175 | > """ |
|
156 | > """ | |
176 | > |
|
157 | > | |
177 | > ''' |
|
158 | > ''' | |
178 | > |
|
159 | > | |
179 | > .. note:: |
|
160 | > .. note:: | |
180 | > |
|
161 | > | |
181 | > valid |
|
162 | > valid | |
182 | > |
|
163 | > | |
183 | > new text |
|
164 | > new text | |
184 | > |
|
165 | > | |
185 | > .. note:: |
|
166 | > .. note:: | |
186 | > |
|
167 | > | |
187 | > also valid |
|
168 | > also valid | |
188 | > ''' |
|
169 | > ''' | |
189 | > |
|
170 | > | |
190 | > """mixed |
|
171 | > """mixed | |
191 | > |
|
172 | > | |
192 | > .. note:: |
|
173 | > .. note:: | |
193 | > |
|
174 | > | |
194 | > good |
|
175 | > good | |
195 | > |
|
176 | > | |
196 | > .. note:: |
|
177 | > .. note:: | |
197 | > plus bad |
|
178 | > plus bad | |
198 | > """ |
|
179 | > """ | |
199 | > EOF |
|
180 | > EOF | |
200 | $ $check_code -w rst.py |
|
181 | $ $check_code -w rst.py | |
201 | rst.py:3: |
|
182 | rst.py:3: | |
202 | > .. note:: |
|
183 | > .. note:: | |
203 | warning: add two newlines after '.. note::' |
|
184 | warning: add two newlines after '.. note::' | |
204 | rst.py:26: |
|
185 | rst.py:26: | |
205 | > .. note:: |
|
186 | > .. note:: | |
206 | warning: add two newlines after '.. note::' |
|
187 | warning: add two newlines after '.. note::' | |
207 | [1] |
|
188 | [1] | |
208 |
|
189 | |||
209 | $ cat > ./map-inside-gettext.py <<EOF |
|
190 | $ cat > ./map-inside-gettext.py <<EOF | |
210 | > print _("map inside gettext %s" % v) |
|
191 | > print _("map inside gettext %s" % v) | |
211 | > |
|
192 | > | |
212 | > print _("concatenating " " by " " space %s" % v) |
|
193 | > print _("concatenating " " by " " space %s" % v) | |
213 | > print _("concatenating " + " by " + " '+' %s" % v) |
|
194 | > print _("concatenating " + " by " + " '+' %s" % v) | |
214 | > |
|
195 | > | |
215 | > print _("mapping operation in different line %s" |
|
196 | > print _("mapping operation in different line %s" | |
216 | > % v) |
|
197 | > % v) | |
217 | > |
|
198 | > | |
218 | > print _( |
|
199 | > print _( | |
219 | > "leading spaces inside of '(' %s" % v) |
|
200 | > "leading spaces inside of '(' %s" % v) | |
220 | > EOF |
|
201 | > EOF | |
221 | $ "$check_code" ./map-inside-gettext.py |
|
202 | $ "$check_code" ./map-inside-gettext.py | |
222 | ./map-inside-gettext.py:1: |
|
203 | ./map-inside-gettext.py:1: | |
223 | > print _("map inside gettext %s" % v) |
|
204 | > print _("map inside gettext %s" % v) | |
224 | don't use % inside _() |
|
205 | don't use % inside _() | |
225 | ./map-inside-gettext.py:3: |
|
206 | ./map-inside-gettext.py:3: | |
226 | > print _("concatenating " " by " " space %s" % v) |
|
207 | > print _("concatenating " " by " " space %s" % v) | |
227 | don't use % inside _() |
|
208 | don't use % inside _() | |
228 | ./map-inside-gettext.py:4: |
|
209 | ./map-inside-gettext.py:4: | |
229 | > print _("concatenating " + " by " + " '+' %s" % v) |
|
210 | > print _("concatenating " + " by " + " '+' %s" % v) | |
230 | don't use % inside _() |
|
211 | don't use % inside _() | |
231 | ./map-inside-gettext.py:6: |
|
212 | ./map-inside-gettext.py:6: | |
232 | > print _("mapping operation in different line %s" |
|
213 | > print _("mapping operation in different line %s" | |
233 | don't use % inside _() |
|
214 | don't use % inside _() | |
234 | ./map-inside-gettext.py:9: |
|
215 | ./map-inside-gettext.py:9: | |
235 | > print _( |
|
216 | > print _( | |
236 | don't use % inside _() |
|
217 | don't use % inside _() | |
237 | [1] |
|
218 | [1] | |
238 |
|
219 | |||
239 | web templates |
|
220 | web templates | |
240 |
|
221 | |||
241 | $ mkdir -p mercurial/templates |
|
222 | $ mkdir -p mercurial/templates | |
242 | $ cat > mercurial/templates/example.tmpl <<EOF |
|
223 | $ cat > mercurial/templates/example.tmpl <<EOF | |
243 | > {desc} |
|
224 | > {desc} | |
244 | > {desc|escape} |
|
225 | > {desc|escape} | |
245 | > {desc|firstline} |
|
226 | > {desc|firstline} | |
246 | > {desc|websub} |
|
227 | > {desc|websub} | |
247 | > EOF |
|
228 | > EOF | |
248 |
|
229 | |||
249 | $ "$check_code" --warnings mercurial/templates/example.tmpl |
|
230 | $ "$check_code" --warnings mercurial/templates/example.tmpl | |
250 | mercurial/templates/example.tmpl:2: |
|
231 | mercurial/templates/example.tmpl:2: | |
251 | > {desc|escape} |
|
232 | > {desc|escape} | |
252 | warning: follow desc keyword with either firstline or websub |
|
233 | warning: follow desc keyword with either firstline or websub | |
253 | [1] |
|
234 | [1] |
General Comments 0
You need to be logged in to leave comments.
Login now