11 |
11 |
12 from PyQt6.QtCore import QCoreApplication |
12 from PyQt6.QtCore import QCoreApplication |
13 |
13 |
14 _miscellaneousMessages = { |
14 _miscellaneousMessages = { |
15 ## Coding line |
15 ## Coding line |
16 "M101": QCoreApplication.translate( |
16 "M-101": QCoreApplication.translate( |
17 "MiscellaneousChecker", |
17 "MiscellaneousChecker", |
18 "coding magic comment not found", |
18 "coding magic comment not found", |
19 ), |
19 ), |
20 "M102": QCoreApplication.translate( |
20 "M-102": QCoreApplication.translate( |
21 "MiscellaneousChecker", |
21 "MiscellaneousChecker", |
22 "unknown encoding ({0}) found in coding magic comment", |
22 "unknown encoding ({0}) found in coding magic comment", |
23 ), |
23 ), |
24 ## Copyright |
24 ## Copyright |
25 "M111": QCoreApplication.translate( |
25 "M-111": QCoreApplication.translate( |
26 "MiscellaneousChecker", |
26 "MiscellaneousChecker", |
27 "copyright notice not present", |
27 "copyright notice not present", |
28 ), |
28 ), |
29 "M112": QCoreApplication.translate( |
29 "M-112": QCoreApplication.translate( |
30 "MiscellaneousChecker", |
30 "MiscellaneousChecker", |
31 "copyright notice contains invalid author", |
31 "copyright notice contains invalid author", |
32 ), |
32 ), |
33 ## Shadowed Builtins |
33 ## Shadowed Builtins |
34 "M131": QCoreApplication.translate( |
34 "M-131": QCoreApplication.translate( |
35 "MiscellaneousChecker", |
35 "MiscellaneousChecker", |
36 '"{0}" is a Python builtin and is being shadowed; ' |
36 '"{0}" is a Python builtin and is being shadowed; ' |
37 "consider renaming the variable", |
37 "consider renaming the variable", |
38 ), |
38 ), |
39 "M132": QCoreApplication.translate( |
39 "M-132": QCoreApplication.translate( |
40 "MiscellaneousChecker", |
40 "MiscellaneousChecker", |
41 '"{0}" is used as an argument and thus shadows a ' |
41 '"{0}" is used as an argument and thus shadows a ' |
42 "Python builtin; consider renaming the argument", |
42 "Python builtin; consider renaming the argument", |
43 ), |
43 ), |
44 ## Comprehensions |
44 ## Comprehensions |
45 "M180": QCoreApplication.translate( |
45 "M-180": QCoreApplication.translate( |
46 "MiscellaneousChecker", |
46 "MiscellaneousChecker", |
47 "unnecessary generator - rewrite as a list comprehension", |
47 "unnecessary generator - rewrite as a list comprehension", |
48 ), |
48 ), |
49 "M181": QCoreApplication.translate( |
49 "M-181": QCoreApplication.translate( |
50 "MiscellaneousChecker", |
50 "MiscellaneousChecker", |
51 "unnecessary generator - rewrite as a set comprehension", |
51 "unnecessary generator - rewrite as a set comprehension", |
52 ), |
52 ), |
53 "M182": QCoreApplication.translate( |
53 "M-182": QCoreApplication.translate( |
54 "MiscellaneousChecker", |
54 "MiscellaneousChecker", |
55 "unnecessary generator - rewrite as a dict comprehension", |
55 "unnecessary generator - rewrite as a dict comprehension", |
56 ), |
56 ), |
57 "M183": QCoreApplication.translate( |
57 "M-183": QCoreApplication.translate( |
58 "MiscellaneousChecker", |
58 "MiscellaneousChecker", |
59 "unnecessary list comprehension - rewrite as a set comprehension", |
59 "unnecessary list comprehension - rewrite as a set comprehension", |
60 ), |
60 ), |
61 "M184": QCoreApplication.translate( |
61 "M-184": QCoreApplication.translate( |
62 "MiscellaneousChecker", |
62 "MiscellaneousChecker", |
63 "unnecessary list comprehension - rewrite as a dict comprehension", |
63 "unnecessary list comprehension - rewrite as a dict comprehension", |
64 ), |
64 ), |
65 "M185": QCoreApplication.translate( |
65 "M-185": QCoreApplication.translate( |
66 "MiscellaneousChecker", |
66 "MiscellaneousChecker", |
67 "unnecessary {0} literal - rewrite as a {1} literal", |
67 "unnecessary {0} literal - rewrite as a {1} literal", |
68 ), |
68 ), |
69 "M186": QCoreApplication.translate( |
69 "M-186": QCoreApplication.translate( |
70 "MiscellaneousChecker", |
70 "MiscellaneousChecker", |
71 "unnecessary {0} literal - rewrite as a {1} literal", |
71 "unnecessary {0} literal - rewrite as a {1} literal", |
72 ), |
72 ), |
73 "M188": QCoreApplication.translate( |
73 "M-188": QCoreApplication.translate( |
74 "MiscellaneousChecker", |
74 "MiscellaneousChecker", |
75 "unnecessary {0} call - rewrite as a literal", |
75 "unnecessary {0} call - rewrite as a literal", |
76 ), |
76 ), |
77 "M189a": QCoreApplication.translate( |
77 "M-189a": QCoreApplication.translate( |
78 "MiscellaneousChecker", |
78 "MiscellaneousChecker", |
79 "unnecessary {0} passed to tuple() - remove the outer call to {1}()", |
79 "unnecessary {0} passed to tuple() - remove the outer call to {1}()", |
80 ), |
80 ), |
81 "M189b": QCoreApplication.translate( |
81 "M-189b": QCoreApplication.translate( |
82 "MiscellaneousChecker", |
82 "MiscellaneousChecker", |
83 "unnecessary {0} passed to tuple() - rewrite as a {1} literal", |
83 "unnecessary {0} passed to tuple() - rewrite as a {1} literal", |
84 ), |
84 ), |
85 "M190a": QCoreApplication.translate( |
85 "M-190a": QCoreApplication.translate( |
86 "MiscellaneousChecker", |
86 "MiscellaneousChecker", |
87 "unnecessary {0} passed to list() - remove the outer call to {1}()", |
87 "unnecessary {0} passed to list() - remove the outer call to {1}()", |
88 ), |
88 ), |
89 "M190b": QCoreApplication.translate( |
89 "M-190b": QCoreApplication.translate( |
90 "MiscellaneousChecker", |
90 "MiscellaneousChecker", |
91 "unnecessary {0} passed to list() - rewrite as a {1} literal", |
91 "unnecessary {0} passed to list() - rewrite as a {1} literal", |
92 ), |
92 ), |
93 "M191": QCoreApplication.translate( |
93 "M-191": QCoreApplication.translate( |
94 "MiscellaneousChecker", |
94 "MiscellaneousChecker", |
95 "unnecessary list call - remove the outer call to list()", |
95 "unnecessary list call - remove the outer call to list()", |
96 ), |
96 ), |
97 "M193a": QCoreApplication.translate( |
97 "M-193a": QCoreApplication.translate( |
98 "MiscellaneousChecker", |
98 "MiscellaneousChecker", |
99 "unnecessary {0} call around {1}() - toggle reverse argument to sorted()", |
99 "unnecessary {0} call around {1}() - toggle reverse argument to sorted()", |
100 ), |
100 ), |
101 "M193b": QCoreApplication.translate( |
101 "M-193b": QCoreApplication.translate( |
102 "MiscellaneousChecker", |
102 "MiscellaneousChecker", |
103 "unnecessary {0} call around {1}() - use sorted(..., reverse={2!r})", |
103 "unnecessary {0} call around {1}() - use sorted(..., reverse={2!r})", |
104 ), |
104 ), |
105 "M193c": QCoreApplication.translate( |
105 "M-193c": QCoreApplication.translate( |
106 "MiscellaneousChecker", |
106 "MiscellaneousChecker", |
107 "unnecessary {0} call around {1}()", |
107 "unnecessary {0} call around {1}()", |
108 ), |
108 ), |
109 "M194": QCoreApplication.translate( |
109 "M-194": QCoreApplication.translate( |
110 "MiscellaneousChecker", |
110 "MiscellaneousChecker", |
111 "unnecessary {0} call within {1}()", |
111 "unnecessary {0} call within {1}()", |
112 ), |
112 ), |
113 "M195": QCoreApplication.translate( |
113 "M-195": QCoreApplication.translate( |
114 "MiscellaneousChecker", |
114 "MiscellaneousChecker", |
115 "unnecessary subscript reversal of iterable within {0}()", |
115 "unnecessary subscript reversal of iterable within {0}()", |
116 ), |
116 ), |
117 "M196": QCoreApplication.translate( |
117 "M-196": QCoreApplication.translate( |
118 "MiscellaneousChecker", |
118 "MiscellaneousChecker", |
119 "unnecessary {0} comprehension - rewrite using {0}()", |
119 "unnecessary {0} comprehension - rewrite using {0}()", |
120 ), |
120 ), |
121 "M197": QCoreApplication.translate( |
121 "M-197": QCoreApplication.translate( |
122 "MiscellaneousChecker", |
122 "MiscellaneousChecker", |
123 "unnecessary use of map - use a {0} instead", |
123 "unnecessary use of map - use a {0} instead", |
124 ), |
124 ), |
125 "M198": QCoreApplication.translate( |
125 "M-198": QCoreApplication.translate( |
126 "MiscellaneousChecker", |
126 "MiscellaneousChecker", |
127 "unnecessary {0} passed to dict() - remove the outer call to dict()", |
127 "unnecessary {0} passed to dict() - remove the outer call to dict()", |
128 ), |
128 ), |
129 "M199": QCoreApplication.translate( |
129 "M-199": QCoreApplication.translate( |
130 "MiscellaneousChecker", |
130 "MiscellaneousChecker", |
131 "unnecessary list comprehension passed to {0}() prevents short-circuiting" |
131 "unnecessary list comprehension passed to {0}() prevents short-circuiting" |
132 " - rewrite as a generator", |
132 " - rewrite as a generator", |
133 ), |
133 ), |
134 "M200": QCoreApplication.translate( |
134 "M-200": QCoreApplication.translate( |
135 "MiscellaneousChecker", |
135 "MiscellaneousChecker", |
136 "unnecessary {0} comprehension - rewrite using dict.fromkeys()", |
136 "unnecessary {0} comprehension - rewrite using dict.fromkeys()", |
137 ), |
137 ), |
138 ## Dictionaries with sorted keys |
138 ## Dictionaries with sorted keys |
139 "M251": QCoreApplication.translate( |
139 "M-251": QCoreApplication.translate( |
140 "MiscellaneousChecker", |
140 "MiscellaneousChecker", |
141 "sort keys - '{0}' should be before '{1}'", |
141 "sort keys - '{0}' should be before '{1}'", |
142 ), |
142 ), |
143 ## Property |
143 ## Property |
144 "M260": QCoreApplication.translate( |
144 "M-260": QCoreApplication.translate( |
145 "MiscellaneousChecker", |
145 "MiscellaneousChecker", |
146 "the number of arguments for property getter method is wrong" |
146 "the number of arguments for property getter method is wrong" |
147 " (should be 1 instead of {0})", |
147 " (should be 1 instead of {0})", |
148 ), |
148 ), |
149 "M261": QCoreApplication.translate( |
149 "M-261": QCoreApplication.translate( |
150 "MiscellaneousChecker", |
150 "MiscellaneousChecker", |
151 "the number of arguments for property setter method is wrong" |
151 "the number of arguments for property setter method is wrong" |
152 " (should be 2 instead of {0})", |
152 " (should be 2 instead of {0})", |
153 ), |
153 ), |
154 "M262": QCoreApplication.translate( |
154 "M-262": QCoreApplication.translate( |
155 "MiscellaneousChecker", |
155 "MiscellaneousChecker", |
156 "the number of arguments for property deleter method is wrong" |
156 "the number of arguments for property deleter method is wrong" |
157 " (should be 1 instead of {0})", |
157 " (should be 1 instead of {0})", |
158 ), |
158 ), |
159 "M263": QCoreApplication.translate( |
159 "M-263": QCoreApplication.translate( |
160 "MiscellaneousChecker", |
160 "MiscellaneousChecker", |
161 "the name of the setter method is wrong (should be '{0}' instead of '{1}')", |
161 "the name of the setter method is wrong (should be '{0}' instead of '{1}')", |
162 ), |
162 ), |
163 "M264": QCoreApplication.translate( |
163 "M-264": QCoreApplication.translate( |
164 "MiscellaneousChecker", |
164 "MiscellaneousChecker", |
165 "the name of the deleter method is wrong (should be '{0}' instead of '{1}')", |
165 "the name of the deleter method is wrong (should be '{0}' instead of '{1}')", |
166 ), |
166 ), |
167 "M265": QCoreApplication.translate( |
167 "M-265": QCoreApplication.translate( |
168 "MiscellaneousChecker", |
168 "MiscellaneousChecker", |
169 "the name of the setter decorator is wrong (should be '{0}' instead of '{1}')", |
169 "the name of the setter decorator is wrong (should be '{0}' instead of '{1}')", |
170 ), |
170 ), |
171 "M266": QCoreApplication.translate( |
171 "M-266": QCoreApplication.translate( |
172 "MiscellaneousChecker", |
172 "MiscellaneousChecker", |
173 "the name of the deleter decorator is wrong (should be '{0}' instead of '{1}')", |
173 "the name of the deleter decorator is wrong (should be '{0}' instead of '{1}')", |
174 ), |
174 ), |
175 "M267": QCoreApplication.translate( |
175 "M-267": QCoreApplication.translate( |
176 "MiscellaneousChecker", |
176 "MiscellaneousChecker", |
177 "multiple decorators were used to declare property '{0}'", |
177 "multiple decorators were used to declare property '{0}'", |
178 ), |
178 ), |
179 ## Naive datetime usage |
179 ## Naive datetime usage |
180 "M301": QCoreApplication.translate( |
180 "M-301": QCoreApplication.translate( |
181 "MiscellaneousChecker", |
181 "MiscellaneousChecker", |
182 "use of 'datetime.datetime()' without 'tzinfo' argument should be avoided", |
182 "use of 'datetime.datetime()' without 'tzinfo' argument should be avoided", |
183 ), |
183 ), |
184 "M302": QCoreApplication.translate( |
184 "M-302": QCoreApplication.translate( |
185 "MiscellaneousChecker", |
185 "MiscellaneousChecker", |
186 "use of 'datetime.datetime.today()' should be avoided.\n" |
186 "use of 'datetime.datetime.today()' should be avoided.\n" |
187 "Use 'datetime.datetime.now(tz=)' instead.", |
187 "Use 'datetime.datetime.now(tz=)' instead.", |
188 ), |
188 ), |
189 "M303": QCoreApplication.translate( |
189 "M-303": QCoreApplication.translate( |
190 "MiscellaneousChecker", |
190 "MiscellaneousChecker", |
191 "use of 'datetime.datetime.utcnow()' should be avoided.\n" |
191 "use of 'datetime.datetime.utcnow()' should be avoided.\n" |
192 "Use 'datetime.datetime.now(tz=datetime.timezone.utc)' instead.", |
192 "Use 'datetime.datetime.now(tz=datetime.timezone.utc)' instead.", |
193 ), |
193 ), |
194 "M304": QCoreApplication.translate( |
194 "M-304": QCoreApplication.translate( |
195 "MiscellaneousChecker", |
195 "MiscellaneousChecker", |
196 "use of 'datetime.datetime.utcfromtimestamp()' should be avoided.\n" |
196 "use of 'datetime.datetime.utcfromtimestamp()' should be avoided.\n" |
197 "Use 'datetime.datetime.fromtimestamp(..., tz=datetime.timezone.utc)' instead.", |
197 "Use 'datetime.datetime.fromtimestamp(..., tz=datetime.timezone.utc)' instead.", |
198 ), |
198 ), |
199 "M305": QCoreApplication.translate( |
199 "M-305": QCoreApplication.translate( |
200 "MiscellaneousChecker", |
200 "MiscellaneousChecker", |
201 "use of 'datetime.datetime.now()' without 'tz' argument should be avoided", |
201 "use of 'datetime.datetime.now()' without 'tz' argument should be avoided", |
202 ), |
202 ), |
203 "M306": QCoreApplication.translate( |
203 "M-306": QCoreApplication.translate( |
204 "MiscellaneousChecker", |
204 "MiscellaneousChecker", |
205 "use of 'datetime.datetime.fromtimestamp()' without 'tz' argument" |
205 "use of 'datetime.datetime.fromtimestamp()' without 'tz' argument" |
206 " should be avoided", |
206 " should be avoided", |
207 ), |
207 ), |
208 "M307": QCoreApplication.translate( |
208 "M-307": QCoreApplication.translate( |
209 "MiscellaneousChecker", |
209 "MiscellaneousChecker", |
210 "use of 'datetime.datetime.strptime()' should be followed by" |
210 "use of 'datetime.datetime.strptime()' should be followed by" |
211 " '.replace(tzinfo=)'", |
211 " '.replace(tzinfo=)'", |
212 ), |
212 ), |
213 "M308": QCoreApplication.translate( |
213 "M-308": QCoreApplication.translate( |
214 "MiscellaneousChecker", |
214 "MiscellaneousChecker", |
215 "use of 'datetime.datetime.fromordinal()' should be avoided", |
215 "use of 'datetime.datetime.fromordinal()' should be avoided", |
216 ), |
216 ), |
217 "M311": QCoreApplication.translate( |
217 "M-311": QCoreApplication.translate( |
218 "MiscellaneousChecker", |
218 "MiscellaneousChecker", |
219 "use of 'datetime.date()' should be avoided.\n" |
219 "use of 'datetime.date()' should be avoided.\n" |
220 "Use 'datetime.datetime(, tzinfo=).date()' instead.", |
220 "Use 'datetime.datetime(, tzinfo=).date()' instead.", |
221 ), |
221 ), |
222 "M312": QCoreApplication.translate( |
222 "M-312": QCoreApplication.translate( |
223 "MiscellaneousChecker", |
223 "MiscellaneousChecker", |
224 "use of 'datetime.date.today()' should be avoided.\n" |
224 "use of 'datetime.date.today()' should be avoided.\n" |
225 "Use 'datetime.datetime.now(tz=).date()' instead.", |
225 "Use 'datetime.datetime.now(tz=).date()' instead.", |
226 ), |
226 ), |
227 "M313": QCoreApplication.translate( |
227 "M-313": QCoreApplication.translate( |
228 "MiscellaneousChecker", |
228 "MiscellaneousChecker", |
229 "use of 'datetime.date.fromtimestamp()' should be avoided.\n" |
229 "use of 'datetime.date.fromtimestamp()' should be avoided.\n" |
230 "Use 'datetime.datetime.fromtimestamp(tz=).date()' instead.", |
230 "Use 'datetime.datetime.fromtimestamp(tz=).date()' instead.", |
231 ), |
231 ), |
232 "M314": QCoreApplication.translate( |
232 "M-314": QCoreApplication.translate( |
233 "MiscellaneousChecker", |
233 "MiscellaneousChecker", |
234 "use of 'datetime.date.fromordinal()' should be avoided", |
234 "use of 'datetime.date.fromordinal()' should be avoided", |
235 ), |
235 ), |
236 "M315": QCoreApplication.translate( |
236 "M-315": QCoreApplication.translate( |
237 "MiscellaneousChecker", |
237 "MiscellaneousChecker", |
238 "use of 'datetime.date.fromisoformat()' should be avoided", |
238 "use of 'datetime.date.fromisoformat()' should be avoided", |
239 ), |
239 ), |
240 "M321": QCoreApplication.translate( |
240 "M-321": QCoreApplication.translate( |
241 "MiscellaneousChecker", |
241 "MiscellaneousChecker", |
242 "use of 'datetime.time()' without 'tzinfo' argument should be avoided", |
242 "use of 'datetime.time()' without 'tzinfo' argument should be avoided", |
243 ), |
243 ), |
244 ## sys.version and sys.version_info usage |
244 ## sys.version and sys.version_info usage |
245 "M401": QCoreApplication.translate( |
245 "M-401": QCoreApplication.translate( |
246 "MiscellaneousChecker", |
246 "MiscellaneousChecker", |
247 "'sys.version[:3]' referenced (Python 3.10), use 'sys.version_info'", |
247 "'sys.version[:3]' referenced (Python 3.10), use 'sys.version_info'", |
248 ), |
248 ), |
249 "M402": QCoreApplication.translate( |
249 "M-402": QCoreApplication.translate( |
250 "MiscellaneousChecker", |
250 "MiscellaneousChecker", |
251 "'sys.version[2]' referenced (Python 3.10), use 'sys.version_info'", |
251 "'sys.version[2]' referenced (Python 3.10), use 'sys.version_info'", |
252 ), |
252 ), |
253 "M403": QCoreApplication.translate( |
253 "M-403": QCoreApplication.translate( |
254 "MiscellaneousChecker", |
254 "MiscellaneousChecker", |
255 "'sys.version' compared to string (Python 3.10), use 'sys.version_info'", |
255 "'sys.version' compared to string (Python 3.10), use 'sys.version_info'", |
256 ), |
256 ), |
257 "M411": QCoreApplication.translate( |
257 "M-411": QCoreApplication.translate( |
258 "MiscellaneousChecker", |
258 "MiscellaneousChecker", |
259 "'sys.version_info[0] == 3' referenced (Python 4), use '>='", |
259 "'sys.version_info[0] == 3' referenced (Python 4), use '>='", |
260 ), |
260 ), |
261 "M412": QCoreApplication.translate( |
261 "M-412": QCoreApplication.translate( |
262 "MiscellaneousChecker", |
262 "MiscellaneousChecker", |
263 "'six.PY3' referenced (Python 4), use 'not six.PY2'", |
263 "'six.PY3' referenced (Python 4), use 'not six.PY2'", |
264 ), |
264 ), |
265 "M413": QCoreApplication.translate( |
265 "M-413": QCoreApplication.translate( |
266 "MiscellaneousChecker", |
266 "MiscellaneousChecker", |
267 "'sys.version_info[1]' compared to integer (Python 4)," |
267 "'sys.version_info[1]' compared to integer (Python 4)," |
268 " compare 'sys.version_info' to tuple", |
268 " compare 'sys.version_info' to tuple", |
269 ), |
269 ), |
270 "M414": QCoreApplication.translate( |
270 "M-414": QCoreApplication.translate( |
271 "MiscellaneousChecker", |
271 "MiscellaneousChecker", |
272 "'sys.version_info.minor' compared to integer (Python 4)," |
272 "'sys.version_info.minor' compared to integer (Python 4)," |
273 " compare 'sys.version_info' to tuple", |
273 " compare 'sys.version_info' to tuple", |
274 ), |
274 ), |
275 "M421": QCoreApplication.translate( |
275 "M-421": QCoreApplication.translate( |
276 "MiscellaneousChecker", |
276 "MiscellaneousChecker", |
277 "'sys.version[0]' referenced (Python 10), use 'sys.version_info'", |
277 "'sys.version[0]' referenced (Python 10), use 'sys.version_info'", |
278 ), |
278 ), |
279 "M422": QCoreApplication.translate( |
279 "M-422": QCoreApplication.translate( |
280 "MiscellaneousChecker", |
280 "MiscellaneousChecker", |
281 "'sys.version' compared to string (Python 10), use 'sys.version_info'", |
281 "'sys.version' compared to string (Python 10), use 'sys.version_info'", |
282 ), |
282 ), |
283 "M423": QCoreApplication.translate( |
283 "M-423": QCoreApplication.translate( |
284 "MiscellaneousChecker", |
284 "MiscellaneousChecker", |
285 "'sys.version[:1]' referenced (Python 10), use 'sys.version_info'", |
285 "'sys.version[:1]' referenced (Python 10), use 'sys.version_info'", |
286 ), |
286 ), |
287 ## Bugbear |
287 ## Bugbear |
288 "M501": QCoreApplication.translate( |
288 "M-501": QCoreApplication.translate( |
289 "MiscellaneousChecker", |
289 "MiscellaneousChecker", |
290 "Do not use bare 'except:', it also catches unexpected events like memory" |
290 "Do not use bare 'except:', it also catches unexpected events like memory" |
291 " errors, interrupts, system exit, and so on. Prefer excepting specific" |
291 " errors, interrupts, system exit, and so on. Prefer excepting specific" |
292 " exceptions. If you're sure what you're doing, be explicit and write" |
292 " exceptions. If you're sure what you're doing, be explicit and write" |
293 " 'except BaseException:'.", |
293 " 'except BaseException:'.", |
294 ), |
294 ), |
295 "M502": QCoreApplication.translate( |
295 "M-502": QCoreApplication.translate( |
296 "MiscellaneousChecker", |
296 "MiscellaneousChecker", |
297 "Python does not support the unary prefix increment", |
297 "Python does not support the unary prefix increment", |
298 ), |
298 ), |
299 "M503": QCoreApplication.translate( |
299 "M-503": QCoreApplication.translate( |
300 "MiscellaneousChecker", |
300 "MiscellaneousChecker", |
301 "assigning to 'os.environ' does not clear the environment -" |
301 "assigning to 'os.environ' does not clear the environment -" |
302 " use 'os.environ.clear()'", |
302 " use 'os.environ.clear()'", |
303 ), |
303 ), |
304 "M504": QCoreApplication.translate( |
304 "M-504": QCoreApplication.translate( |
305 "MiscellaneousChecker", |
305 "MiscellaneousChecker", |
306 """using 'hasattr(x, "__call__")' to test if 'x' is callable is""" |
306 """using 'hasattr(x, "__call__")' to test if 'x' is callable is""" |
307 """ unreliable. Use 'callable(x)' for consistent results.""", |
307 """ unreliable. Use 'callable(x)' for consistent results.""", |
308 ), |
308 ), |
309 "M505": QCoreApplication.translate( |
309 "M-505": QCoreApplication.translate( |
310 "MiscellaneousChecker", |
310 "MiscellaneousChecker", |
311 "using .strip() with multi-character strings is misleading. Use .replace()," |
311 "using .strip() with multi-character strings is misleading. Use .replace()," |
312 " .removeprefix(), .removesuffix(), or regular expressions to remove string" |
312 " .removeprefix(), .removesuffix(), or regular expressions to remove string" |
313 " fragments.", |
313 " fragments.", |
314 ), |
314 ), |
315 "M506": QCoreApplication.translate( |
315 "M-506": QCoreApplication.translate( |
316 "MiscellaneousChecker", |
316 "MiscellaneousChecker", |
317 "Do not use mutable data structures for argument defaults. They are created" |
317 "Do not use mutable data structures for argument defaults. They are created" |
318 " during function definition time. All calls to the function reuse this one" |
318 " during function definition time. All calls to the function reuse this one" |
319 " instance of that data structure, persisting changes between them.", |
319 " instance of that data structure, persisting changes between them.", |
320 ), |
320 ), |
321 "M507": QCoreApplication.translate( |
321 "M-507": QCoreApplication.translate( |
322 "MiscellaneousChecker", |
322 "MiscellaneousChecker", |
323 "loop control variable {0} not used within the loop body -" |
323 "loop control variable {0} not used within the loop body -" |
324 " start the name with an underscore", |
324 " start the name with an underscore", |
325 ), |
325 ), |
326 "M508": QCoreApplication.translate( |
326 "M-508": QCoreApplication.translate( |
327 "MiscellaneousChecker", |
327 "MiscellaneousChecker", |
328 "Do not perform function calls in argument defaults. The call is performed" |
328 "Do not perform function calls in argument defaults. The call is performed" |
329 " only once at function definition time. All calls to your function will reuse" |
329 " only once at function definition time. All calls to your function will reuse" |
330 " the result of that definition-time function call. If this is intended," |
330 " the result of that definition-time function call. If this is intended," |
331 " assign the function call to a module-level variable and use that variable as" |
331 " assign the function call to a module-level variable and use that variable as" |
332 " a default value.", |
332 " a default value.", |
333 ), |
333 ), |
334 "M509": QCoreApplication.translate( |
334 "M-509": QCoreApplication.translate( |
335 "MiscellaneousChecker", |
335 "MiscellaneousChecker", |
336 "do not call getattr with a constant attribute value", |
336 "do not call getattr with a constant attribute value", |
337 ), |
337 ), |
338 "M510": QCoreApplication.translate( |
338 "M-510": QCoreApplication.translate( |
339 "MiscellaneousChecker", |
339 "MiscellaneousChecker", |
340 "do not call setattr with a constant attribute value", |
340 "do not call setattr with a constant attribute value", |
341 ), |
341 ), |
342 "M511": QCoreApplication.translate( |
342 "M-511": QCoreApplication.translate( |
343 "MiscellaneousChecker", |
343 "MiscellaneousChecker", |
344 "do not call assert False since python -O removes these calls", |
344 "do not call assert False since python -O removes these calls", |
345 ), |
345 ), |
346 "M512": QCoreApplication.translate( |
346 "M-512": QCoreApplication.translate( |
347 "MiscellaneousChecker", |
347 "MiscellaneousChecker", |
348 "return/continue/break inside finally blocks cause exceptions to be silenced." |
348 "return/continue/break inside finally blocks cause exceptions to be silenced." |
349 " Exceptions should be silenced in except{0} blocks. Control statements can be" |
349 " Exceptions should be silenced in except{0} blocks. Control statements can be" |
350 " moved outside the finally block.", |
350 " moved outside the finally block.", |
351 ), |
351 ), |
352 "M513": QCoreApplication.translate( |
352 "M-513": QCoreApplication.translate( |
353 "MiscellaneousChecker", |
353 "MiscellaneousChecker", |
354 "A length-one tuple literal is redundant. Write 'except{1} {0}:' instead of" |
354 "A length-one tuple literal is redundant. Write 'except{1} {0}:' instead of" |
355 " 'except{1} ({0},):'.", |
355 " 'except{1} ({0},):'.", |
356 ), |
356 ), |
357 "M514": QCoreApplication.translate( |
357 "M-514": QCoreApplication.translate( |
358 "MiscellaneousChecker", |
358 "MiscellaneousChecker", |
359 "Redundant exception types in 'except{3} ({0}){1}:'. Write 'except{3} {2}{1}:'," |
359 "Redundant exception types in 'except{3} ({0}){1}:'. Write 'except{3} {2}{1}:'," |
360 " which catches exactly the same exceptions.", |
360 " which catches exactly the same exceptions.", |
361 ), |
361 ), |
362 "M515": QCoreApplication.translate( |
362 "M-515": QCoreApplication.translate( |
363 "MiscellaneousChecker", |
363 "MiscellaneousChecker", |
364 "Result of comparison is not used. This line doesn't do anything. Did you" |
364 "Result of comparison is not used. This line doesn't do anything. Did you" |
365 " intend to prepend it with assert?", |
365 " intend to prepend it with assert?", |
366 ), |
366 ), |
367 "M516": QCoreApplication.translate( |
367 "M-516": QCoreApplication.translate( |
368 "MiscellaneousChecker", |
368 "MiscellaneousChecker", |
369 "Cannot raise a literal. Did you intend to return it or raise an Exception?", |
369 "Cannot raise a literal. Did you intend to return it or raise an Exception?", |
370 ), |
370 ), |
371 "M517": QCoreApplication.translate( |
371 "M-517": QCoreApplication.translate( |
372 "MiscellaneousChecker", |
372 "MiscellaneousChecker", |
373 "'assertRaises(Exception)' and 'pytest.raises(Exception)' should " |
373 "'assertRaises(Exception)' and 'pytest.raises(Exception)' should " |
374 "be considered evil. They can lead to your test passing even if the " |
374 "be considered evil. They can lead to your test passing even if the " |
375 "code being tested is never executed due to a typo. Assert for a more " |
375 "code being tested is never executed due to a typo. Assert for a more " |
376 "specific exception (builtin or custom), or use 'assertRaisesRegex' " |
376 "specific exception (builtin or custom), or use 'assertRaisesRegex' " |
377 "(if using 'assertRaises'), or add the 'match' keyword argument (if " |
377 "(if using 'assertRaises'), or add the 'match' keyword argument (if " |
378 "using 'pytest.raises'), or use the context manager form with a target.", |
378 "using 'pytest.raises'), or use the context manager form with a target.", |
379 ), |
379 ), |
380 "M518": QCoreApplication.translate( |
380 "M-518": QCoreApplication.translate( |
381 "MiscellaneousChecker", |
381 "MiscellaneousChecker", |
382 "Found useless {0} expression. Consider either assigning it to a variable or" |
382 "Found useless {0} expression. Consider either assigning it to a variable or" |
383 " removing it.", |
383 " removing it.", |
384 ), |
384 ), |
385 "M519": QCoreApplication.translate( |
385 "M-519": QCoreApplication.translate( |
386 "MiscellaneousChecker", |
386 "MiscellaneousChecker", |
387 "Use of 'functools.lru_cache' or 'functools.cache' on methods can lead to" |
387 "Use of 'functools.lru_cache' or 'functools.cache' on methods can lead to" |
388 " memory leaks. The cache may retain instance references, preventing garbage" |
388 " memory leaks. The cache may retain instance references, preventing garbage" |
389 " collection.", |
389 " collection.", |
390 ), |
390 ), |
391 "M520": QCoreApplication.translate( |
391 "M-520": QCoreApplication.translate( |
392 "MiscellaneousChecker", |
392 "MiscellaneousChecker", |
393 "Found for loop that reassigns the iterable it is iterating with each" |
393 "Found for loop that reassigns the iterable it is iterating with each" |
394 " iterable value.", |
394 " iterable value.", |
395 ), |
395 ), |
396 "M521": QCoreApplication.translate( |
396 "M-521": QCoreApplication.translate( |
397 "MiscellaneousChecker", |
397 "MiscellaneousChecker", |
398 "f-string used as docstring. This will be interpreted by python as a joined" |
398 "f-string used as docstring. This will be interpreted by python as a joined" |
399 " string rather than a docstring.", |
399 " string rather than a docstring.", |
400 ), |
400 ), |
401 "M522": QCoreApplication.translate( |
401 "M-522": QCoreApplication.translate( |
402 "MiscellaneousChecker", |
402 "MiscellaneousChecker", |
403 "No arguments passed to 'contextlib.suppress'. No exceptions will be" |
403 "No arguments passed to 'contextlib.suppress'. No exceptions will be" |
404 " suppressed and therefore this context manager is redundant.", |
404 " suppressed and therefore this context manager is redundant.", |
405 ), |
405 ), |
406 "M523": QCoreApplication.translate( |
406 "M-523": QCoreApplication.translate( |
407 "MiscellaneousChecker", |
407 "MiscellaneousChecker", |
408 "Function definition does not bind loop variable '{0}'.", |
408 "Function definition does not bind loop variable '{0}'.", |
409 ), |
409 ), |
410 "M524": QCoreApplication.translate( |
410 "M-524": QCoreApplication.translate( |
411 "MiscellaneousChecker", |
411 "MiscellaneousChecker", |
412 "{0} is an abstract base class, but none of the methods it defines are" |
412 "{0} is an abstract base class, but none of the methods it defines are" |
413 " abstract. This is not necessarily an error, but you might have forgotten to" |
413 " abstract. This is not necessarily an error, but you might have forgotten to" |
414 " add the @abstractmethod decorator, potentially in conjunction with" |
414 " add the @abstractmethod decorator, potentially in conjunction with" |
415 " @classmethod, @property and/or @staticmethod.", |
415 " @classmethod, @property and/or @staticmethod.", |
416 ), |
416 ), |
417 "M525": QCoreApplication.translate( |
417 "M-525": QCoreApplication.translate( |
418 "MiscellaneousChecker", |
418 "MiscellaneousChecker", |
419 "Exception '{0}' has been caught multiple times. Only the first except{1} will" |
419 "Exception '{0}' has been caught multiple times. Only the first except{1} will" |
420 " be considered and all other except{1} catches can be safely removed.", |
420 " be considered and all other except{1} catches can be safely removed.", |
421 ), |
421 ), |
422 "M526": QCoreApplication.translate( |
422 "M-526": QCoreApplication.translate( |
423 "MiscellaneousChecker", |
423 "MiscellaneousChecker", |
424 "Star-arg unpacking after a keyword argument is strongly discouraged," |
424 "Star-arg unpacking after a keyword argument is strongly discouraged," |
425 " because it only works when the keyword parameter is declared after all" |
425 " because it only works when the keyword parameter is declared after all" |
426 " parameters supplied by the unpacked sequence, and this change of ordering can" |
426 " parameters supplied by the unpacked sequence, and this change of ordering can" |
427 " surprise and mislead readers.", |
427 " surprise and mislead readers.", |
428 ), |
428 ), |
429 "M527": QCoreApplication.translate( |
429 "M-527": QCoreApplication.translate( |
430 "MiscellaneousChecker", |
430 "MiscellaneousChecker", |
431 "{0} is an empty method in an abstract base class, but has no abstract" |
431 "{0} is an empty method in an abstract base class, but has no abstract" |
432 " decorator. Consider adding @abstractmethod.", |
432 " decorator. Consider adding @abstractmethod.", |
433 ), |
433 ), |
434 "M528": QCoreApplication.translate( |
434 "M-528": QCoreApplication.translate( |
435 "MiscellaneousChecker", |
435 "MiscellaneousChecker", |
436 "No explicit stacklevel argument found. The warn method from the" |
436 "No explicit stacklevel argument found. The warn method from the" |
437 " warnings module uses a stacklevel of 1 by default. This will only show a" |
437 " warnings module uses a stacklevel of 1 by default. This will only show a" |
438 " stack trace for the line on which the warn method is called." |
438 " stack trace for the line on which the warn method is called." |
439 " It is therefore recommended to use a stacklevel of 2 or" |
439 " It is therefore recommended to use a stacklevel of 2 or" |
440 " greater to provide more information to the user.", |
440 " greater to provide more information to the user.", |
441 ), |
441 ), |
442 "M529": QCoreApplication.translate( |
442 "M-529": QCoreApplication.translate( |
443 "MiscellaneousChecker", |
443 "MiscellaneousChecker", |
444 "Using 'except{0} ():' with an empty tuple does not handle/catch " |
444 "Using 'except{0} ():' with an empty tuple does not handle/catch " |
445 "anything. Add exceptions to handle.", |
445 "anything. Add exceptions to handle.", |
446 ), |
446 ), |
447 "M530": QCoreApplication.translate( |
447 "M-530": QCoreApplication.translate( |
448 "MiscellaneousChecker", |
448 "MiscellaneousChecker", |
449 "Except handlers should only be names of exception classes", |
449 "Except handlers should only be names of exception classes", |
450 ), |
450 ), |
451 "M531": QCoreApplication.translate( |
451 "M-531": QCoreApplication.translate( |
452 "MiscellaneousChecker", |
452 "MiscellaneousChecker", |
453 "Using the generator returned from 'itertools.groupby()' more than once" |
453 "Using the generator returned from 'itertools.groupby()' more than once" |
454 " will do nothing on the second usage. Save the result to a list, if the" |
454 " will do nothing on the second usage. Save the result to a list, if the" |
455 " result is needed multiple times.", |
455 " result is needed multiple times.", |
456 ), |
456 ), |
457 "M532": QCoreApplication.translate( |
457 "M-532": QCoreApplication.translate( |
458 "MiscellaneousChecker", |
458 "MiscellaneousChecker", |
459 "Possible unintentional type annotation (using ':'). Did you mean to" |
459 "Possible unintentional type annotation (using ':'). Did you mean to" |
460 " assign (using '=')?", |
460 " assign (using '=')?", |
461 ), |
461 ), |
462 "M533": QCoreApplication.translate( |
462 "M-533": QCoreApplication.translate( |
463 "MiscellaneousChecker", |
463 "MiscellaneousChecker", |
464 "Set should not contain duplicate item '{0}'. Duplicate items will be replaced" |
464 "Set should not contain duplicate item '{0}'. Duplicate items will be replaced" |
465 " with a single item at runtime.", |
465 " with a single item at runtime.", |
466 ), |
466 ), |
467 "M534": QCoreApplication.translate( |
467 "M-534": QCoreApplication.translate( |
468 "MiscellaneousChecker", |
468 "MiscellaneousChecker", |
469 "re.{0} should get '{1}' and 'flags' passed as keyword arguments to avoid" |
469 "re.{0} should get '{1}' and 'flags' passed as keyword arguments to avoid" |
470 " confusion due to unintuitive argument positions.", |
470 " confusion due to unintuitive argument positions.", |
471 ), |
471 ), |
472 "M535": QCoreApplication.translate( |
472 "M-535": QCoreApplication.translate( |
473 "MiscellaneousChecker", |
473 "MiscellaneousChecker", |
474 "Static key in dict comprehension: {0!r}.", |
474 "Static key in dict comprehension: {0!r}.", |
475 ), |
475 ), |
476 "M536": QCoreApplication.translate( |
476 "M-536": QCoreApplication.translate( |
477 "MiscellaneousChecker", |
477 "MiscellaneousChecker", |
478 "Don't except 'BaseException' unless you plan to re-raise it.", |
478 "Don't except 'BaseException' unless you plan to re-raise it.", |
479 ), |
479 ), |
480 "M537": QCoreApplication.translate( |
480 "M-537": QCoreApplication.translate( |
481 "MiscellaneousChecker", |
481 "MiscellaneousChecker", |
482 "Class '__init__' methods must not return or yield any values.", |
482 "Class '__init__' methods must not return or yield any values.", |
483 ), |
483 ), |
484 "M539": QCoreApplication.translate( |
484 "M-539": QCoreApplication.translate( |
485 "MiscellaneousChecker", |
485 "MiscellaneousChecker", |
486 "ContextVar with mutable literal or function call as default. This is only" |
486 "ContextVar with mutable literal or function call as default. This is only" |
487 " evaluated once, and all subsequent calls to `.get()` will return the same" |
487 " evaluated once, and all subsequent calls to `.get()` will return the same" |
488 " instance of the default.", |
488 " instance of the default.", |
489 ), |
489 ), |
490 "M540": QCoreApplication.translate( |
490 "M-540": QCoreApplication.translate( |
491 "MiscellaneousChecker", |
491 "MiscellaneousChecker", |
492 "Exception with added note not used. Did you forget to raise it?", |
492 "Exception with added note not used. Did you forget to raise it?", |
493 ), |
493 ), |
494 "M541": QCoreApplication.translate( |
494 "M-541": QCoreApplication.translate( |
495 "MiscellaneousChecker", |
495 "MiscellaneousChecker", |
496 "Repeated key-value pair in dictionary literal.", |
496 "Repeated key-value pair in dictionary literal.", |
497 ), |
497 ), |
498 ## Bugbear, opininonated |
498 ## Bugbear, opininonated |
499 "M569": QCoreApplication.translate( |
499 "M-569": QCoreApplication.translate( |
500 "MiscellaneousChecker", |
500 "MiscellaneousChecker", |
501 "Editing a loop's mutable iterable often leads to unexpected results/bugs.", |
501 "Editing a loop's mutable iterable often leads to unexpected results/bugs.", |
502 ), |
502 ), |
503 ## Bugbear++ |
503 ## Bugbear++ |
504 "M581": QCoreApplication.translate( |
504 "M-581": QCoreApplication.translate( |
505 "MiscellaneousChecker", |
505 "MiscellaneousChecker", |
506 "unncessary f-string", |
506 "unncessary f-string", |
507 ), |
507 ), |
508 "M582": QCoreApplication.translate( |
508 "M-582": QCoreApplication.translate( |
509 "MiscellaneousChecker", |
509 "MiscellaneousChecker", |
510 "cannot use 'self.__class__' as first argument of 'super()' call", |
510 "cannot use 'self.__class__' as first argument of 'super()' call", |
511 ), |
511 ), |
512 ## Format Strings |
512 ## Format Strings |
513 "M601": QCoreApplication.translate( |
513 "M-601": QCoreApplication.translate( |
514 "MiscellaneousChecker", |
514 "MiscellaneousChecker", |
515 "found {0} formatter", |
515 "found {0} formatter", |
516 ), |
516 ), |
517 "M611": QCoreApplication.translate( |
517 "M-611": QCoreApplication.translate( |
518 "MiscellaneousChecker", |
518 "MiscellaneousChecker", |
519 "format string does contain unindexed parameters", |
519 "format string does contain unindexed parameters", |
520 ), |
520 ), |
521 "M612": QCoreApplication.translate( |
521 "M-612": QCoreApplication.translate( |
522 "MiscellaneousChecker", |
522 "MiscellaneousChecker", |
523 "docstring does contain unindexed parameters", |
523 "docstring does contain unindexed parameters", |
524 ), |
524 ), |
525 "M613": QCoreApplication.translate( |
525 "M-613": QCoreApplication.translate( |
526 "MiscellaneousChecker", |
526 "MiscellaneousChecker", |
527 "other string does contain unindexed parameters", |
527 "other string does contain unindexed parameters", |
528 ), |
528 ), |
529 "M621": QCoreApplication.translate( |
529 "M-621": QCoreApplication.translate( |
530 "MiscellaneousChecker", |
530 "MiscellaneousChecker", |
531 "format call uses too large index ({0})", |
531 "format call uses too large index ({0})", |
532 ), |
532 ), |
533 "M622": QCoreApplication.translate( |
533 "M-622": QCoreApplication.translate( |
534 "MiscellaneousChecker", |
534 "MiscellaneousChecker", |
535 "format call uses missing keyword ({0})", |
535 "format call uses missing keyword ({0})", |
536 ), |
536 ), |
537 "M623": QCoreApplication.translate( |
537 "M-623": QCoreApplication.translate( |
538 "MiscellaneousChecker", |
538 "MiscellaneousChecker", |
539 "format call uses keyword arguments but no named entries", |
539 "format call uses keyword arguments but no named entries", |
540 ), |
540 ), |
541 "M624": QCoreApplication.translate( |
541 "M-624": QCoreApplication.translate( |
542 "MiscellaneousChecker", |
542 "MiscellaneousChecker", |
543 "format call uses variable arguments but no numbered entries", |
543 "format call uses variable arguments but no numbered entries", |
544 ), |
544 ), |
545 "M625": QCoreApplication.translate( |
545 "M-625": QCoreApplication.translate( |
546 "MiscellaneousChecker", |
546 "MiscellaneousChecker", |
547 "format call uses implicit and explicit indexes together", |
547 "format call uses implicit and explicit indexes together", |
548 ), |
548 ), |
549 "M631": QCoreApplication.translate( |
549 "M-631": QCoreApplication.translate( |
550 "MiscellaneousChecker", |
550 "MiscellaneousChecker", |
551 "format call provides unused index ({0})", |
551 "format call provides unused index ({0})", |
552 ), |
552 ), |
553 "M632": QCoreApplication.translate( |
553 "M-632": QCoreApplication.translate( |
554 "MiscellaneousChecker", |
554 "MiscellaneousChecker", |
555 "format call provides unused keyword ({0})", |
555 "format call provides unused keyword ({0})", |
556 ), |
556 ), |
557 ## Future statements |
557 ## Future statements |
558 "M701": QCoreApplication.translate( |
558 "M-701": QCoreApplication.translate( |
559 "MiscellaneousChecker", |
559 "MiscellaneousChecker", |
560 "expected these __future__ imports: {0}; but only got: {1}", |
560 "expected these __future__ imports: {0}; but only got: {1}", |
561 ), |
561 ), |
562 "M702": QCoreApplication.translate( |
562 "M-702": QCoreApplication.translate( |
563 "MiscellaneousChecker", |
563 "MiscellaneousChecker", |
564 "expected these __future__ imports: {0}; but got none", |
564 "expected these __future__ imports: {0}; but got none", |
565 ), |
565 ), |
566 ## Gettext |
566 ## Gettext |
567 "M711": QCoreApplication.translate( |
567 "M-711": QCoreApplication.translate( |
568 "MiscellaneousChecker", |
568 "MiscellaneousChecker", |
569 "gettext import with alias _ found: {0}", |
569 "gettext import with alias _ found: {0}", |
570 ), |
570 ), |
571 ##~ print() statements |
571 ##~ print() statements |
572 "M801": QCoreApplication.translate( |
572 "M-801": QCoreApplication.translate( |
573 "MiscellaneousChecker", |
573 "MiscellaneousChecker", |
574 "print statement found", |
574 "print statement found", |
575 ), |
575 ), |
576 ## one element tuple |
576 ## one element tuple |
577 "M811": QCoreApplication.translate( |
577 "M-811": QCoreApplication.translate( |
578 "MiscellaneousChecker", |
578 "MiscellaneousChecker", |
579 "one element tuple found", |
579 "one element tuple found", |
580 ), |
580 ), |
581 ## Mutable Defaults |
581 ## Mutable Defaults |
582 "M821": QCoreApplication.translate( |
582 "M-821": QCoreApplication.translate( |
583 "MiscellaneousChecker", |
583 "MiscellaneousChecker", |
584 "mutable default argument of type {0}", |
584 "mutable default argument of type {0}", |
585 ), |
585 ), |
586 "M822": QCoreApplication.translate( |
586 "M-822": QCoreApplication.translate( |
587 "MiscellaneousChecker", |
587 "MiscellaneousChecker", |
588 "mutable default argument of type {0}", |
588 "mutable default argument of type {0}", |
589 ), |
589 ), |
590 "M823": QCoreApplication.translate( |
590 "M-823": QCoreApplication.translate( |
591 "MiscellaneousChecker", |
591 "MiscellaneousChecker", |
592 "mutable default argument of function call '{0}'", |
592 "mutable default argument of function call '{0}'", |
593 ), |
593 ), |
594 ##~ return statements |
594 ##~ return statements |
595 "M831": QCoreApplication.translate( |
595 "M-831": QCoreApplication.translate( |
596 "MiscellaneousChecker", |
596 "MiscellaneousChecker", |
597 "None should not be added at any return if function has no return" |
597 "None should not be added at any return if function has no return" |
598 " value except None", |
598 " value except None", |
599 ), |
599 ), |
600 "M832": QCoreApplication.translate( |
600 "M-832": QCoreApplication.translate( |
601 "MiscellaneousChecker", |
601 "MiscellaneousChecker", |
602 "an explicit value at every return should be added if function has" |
602 "an explicit value at every return should be added if function has" |
603 " a return value except None", |
603 " a return value except None", |
604 ), |
604 ), |
605 "M833": QCoreApplication.translate( |
605 "M-833": QCoreApplication.translate( |
606 "MiscellaneousChecker", |
606 "MiscellaneousChecker", |
607 "an explicit return at the end of the function should be added if" |
607 "an explicit return at the end of the function should be added if" |
608 " it has a return value except None", |
608 " it has a return value except None", |
609 ), |
609 ), |
610 "M834": QCoreApplication.translate( |
610 "M-834": QCoreApplication.translate( |
611 "MiscellaneousChecker", |
611 "MiscellaneousChecker", |
612 "a value should not be assigned to a variable if it will be used as a" |
612 "a value should not be assigned to a variable if it will be used as a" |
613 " return value only", |
613 " return value only", |
614 ), |
614 ), |
615 ## line continuation |
615 ## line continuation |
616 "M841": QCoreApplication.translate( |
616 "M-841": QCoreApplication.translate( |
617 "MiscellaneousChecker", |
617 "MiscellaneousChecker", |
618 "prefer implied line continuation inside parentheses, " |
618 "prefer implied line continuation inside parentheses, " |
619 "brackets and braces as opposed to a backslash", |
619 "brackets and braces as opposed to a backslash", |
620 ), |
620 ), |
621 ## implicitly concatenated strings |
621 ## implicitly concatenated strings |
622 "M851": QCoreApplication.translate( |
622 "M-851": QCoreApplication.translate( |
623 "MiscellaneousChecker", |
623 "MiscellaneousChecker", |
624 "implicitly concatenated string or bytes literals on one line", |
624 "implicitly concatenated string or bytes literals on one line", |
625 ), |
625 ), |
626 "M852": QCoreApplication.translate( |
626 "M-852": QCoreApplication.translate( |
627 "MiscellaneousChecker", |
627 "MiscellaneousChecker", |
628 "implicitly concatenated string or bytes literals over continuation line", |
628 "implicitly concatenated string or bytes literals over continuation line", |
629 ), |
629 ), |
630 "M853": QCoreApplication.translate( |
630 "M-853": QCoreApplication.translate( |
631 "MiscellaneousChecker", |
631 "MiscellaneousChecker", |
632 "explicitly concatenated string or bytes should be implicitly concatenated", |
632 "explicitly concatenated string or bytes should be implicitly concatenated", |
633 ), |
633 ), |
634 ## commented code |
634 ## commented code |
635 "M891": QCoreApplication.translate( |
635 "M-891": QCoreApplication.translate( |
636 "MiscellaneousChecker", |
636 "MiscellaneousChecker", |
637 "commented code lines should be removed", |
637 "commented code lines should be removed", |
638 ), |
638 ), |
639 ## structural pattern matching |
639 ## structural pattern matching |
640 "M901": QCoreApplication.translate( |
640 "M-901": QCoreApplication.translate( |
641 "MiscellaneousChecker", |
641 "MiscellaneousChecker", |
642 "matching a default value should raise a `ValueError` exception", |
642 "matching a default value should raise a `ValueError` exception", |
643 ), |
643 ), |
644 "M902": QCoreApplication.translate( |
644 "M-902": QCoreApplication.translate( |
645 "MiscellaneousChecker", |
645 "MiscellaneousChecker", |
646 "matching a default value should not contain a `return` statement before " |
646 "matching a default value should not contain a `return` statement before " |
647 "raising a `ValueError` exception", |
647 "raising a `ValueError` exception", |
648 ), |
648 ), |
649 } |
649 } |
650 |
650 |
651 _miscellaneousMessagesSampleArgs = { |
651 _miscellaneousMessagesSampleArgs = { |
652 ## Coding line |
652 ## Coding line |
653 "M102": ["enc42"], |
653 "M-102": ["enc42"], |
654 ## Shadowed Builtins |
654 ## Shadowed Builtins |
655 "M131": ["list"], |
655 "M-131": ["list"], |
656 "M132": ["list"], |
656 "M-132": ["list"], |
657 ## Comprehensions |
657 ## Comprehensions |
658 "M185": ["list", "set"], |
658 "M-185": ["list", "set"], |
659 "M186": ["list", "dict"], |
659 "M-186": ["list", "dict"], |
660 "M188": ["list"], |
660 "M-188": ["list"], |
661 "M189a": ["tuple", "tuple"], |
661 "M-189a": ["tuple", "tuple"], |
662 "M189b": ["list", "tuple"], |
662 "M-189b": ["list", "tuple"], |
663 "M190a": ["list", "list"], |
663 "M-190a": ["list", "list"], |
664 "M190b": ["tuple", "list"], |
664 "M-190b": ["tuple", "list"], |
665 "M193a": ["reversed", "sorted"], |
665 "M-193a": ["reversed", "sorted"], |
666 "M193b": ["reversed", "sorted", "True"], |
666 "M-193b": ["reversed", "sorted", "True"], |
667 "M193c": ["list", "sorted"], |
667 "M-193c": ["list", "sorted"], |
668 "M194": ["list", "sorted"], |
668 "M-194": ["list", "sorted"], |
669 "M195": ["sorted"], |
669 "M-195": ["sorted"], |
670 "M196": ["list"], |
670 "M-196": ["list"], |
671 "M197": ["list"], |
671 "M-197": ["list"], |
672 "M198": ["dict comprehension"], |
672 "M-198": ["dict comprehension"], |
673 "M199": ["any"], |
673 "M-199": ["any"], |
674 "M200": ["dict"], |
674 "M-200": ["dict"], |
675 ## Dictionaries with sorted keys |
675 ## Dictionaries with sorted keys |
676 "M251": ["bar", "foo"], |
676 "M-251": ["bar", "foo"], |
677 ## Property |
677 ## Property |
678 "M260": [2], |
678 "M-260": [2], |
679 "M261": [1], |
679 "M-261": [1], |
680 "M262": [2], |
680 "M-262": [2], |
681 "M263": ["foo", "bar"], |
681 "M-263": ["foo", "bar"], |
682 "M264": ["foo", "bar"], |
682 "M-264": ["foo", "bar"], |
683 "M265": ["foo", "bar"], |
683 "M-265": ["foo", "bar"], |
684 "M266": ["foo", "bar"], |
684 "M-266": ["foo", "bar"], |
685 "M267": ["foo"], |
685 "M-267": ["foo"], |
686 ## Bugbear |
686 ## Bugbear |
687 "M507": ["x"], |
687 "M-507": ["x"], |
688 "M512": [""], |
688 "M-512": [""], |
689 "M513": ["Exception", ""], |
689 "M-513": ["Exception", ""], |
690 "M514": ["OSError, IOError", " as err", "OSError", ""], |
690 "M-514": ["OSError, IOError", " as err", "OSError", ""], |
691 "M518": ["List"], |
691 "M-518": ["List"], |
692 "M523": ["x"], |
692 "M-523": ["x"], |
693 "M524": ["foobar"], |
693 "M-524": ["foobar"], |
694 "M525": ["OSError", ""], |
694 "M-525": ["OSError", ""], |
695 "M527": ["foo"], |
695 "M-527": ["foo"], |
696 "M529": [""], |
696 "M-529": [""], |
697 "M533": ["foo"], |
697 "M-533": ["foo"], |
698 "M534": ["split", "maxsplit"], |
698 "M-534": ["split", "maxsplit"], |
699 "M535": ["foo"], |
699 "M-535": ["foo"], |
700 ## Format Strings |
700 ## Format Strings |
701 "M601": ["%s"], |
701 "M-601": ["%s"], |
702 "M621": [5], |
702 "M-621": [5], |
703 "M622": ["foo"], |
703 "M-622": ["foo"], |
704 "M631": [5], |
704 "M-631": [5], |
705 "M632": ["foo"], |
705 "M-632": ["foo"], |
706 ## Future statements |
706 ## Future statements |
707 "M701": ["print_function, unicode_literals", "print_function"], |
707 "M-701": ["print_function, unicode_literals", "print_function"], |
708 "M702": ["print_function, unicode_literals"], |
708 "M-702": ["print_function, unicode_literals"], |
709 ## Gettext |
709 ## Gettext |
710 "M711": ["lgettext"], |
710 "M-711": ["lgettext"], |
711 ## Mutable Defaults |
711 ## Mutable Defaults |
712 "M821": ["Dict"], |
712 "M-821": ["Dict"], |
713 "M822": ["Call"], |
713 "M-822": ["Call"], |
714 "M823": ["dict"], |
714 "M-823": ["dict"], |
715 } |
715 } |