eric6/Plugins/CheckerPlugins/CodeStyleChecker/translations.py

changeset 6942
2602857055c5
parent 6882
65d1bf4b7427
child 7021
2894aa889a4e
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2014 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing message translations for the code style plugin messages.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import QCoreApplication
13
14 from Globals import translate
15
16 __all__ = ["getTranslatedMessage"]
17
18 _messages = {
19 "E101": QCoreApplication.translate(
20 "pycodestyle",
21 "indentation contains mixed spaces and tabs"),
22 "E111": QCoreApplication.translate(
23 "pycodestyle",
24 "indentation is not a multiple of four"),
25 "E112": QCoreApplication.translate(
26 "pycodestyle",
27 "expected an indented block"),
28 "E113": QCoreApplication.translate(
29 "pycodestyle",
30 "unexpected indentation"),
31 "E114": QCoreApplication.translate(
32 "pycodestyle",
33 "indentation is not a multiple of four (comment)"),
34 "E115": QCoreApplication.translate(
35 "pycodestyle",
36 "expected an indented block (comment)"),
37 "E116": QCoreApplication.translate(
38 "pycodestyle",
39 "unexpected indentation (comment)"),
40 "E117": QCoreApplication.translate(
41 "pycodestyle",
42 "over-indented"),
43 "E121": QCoreApplication.translate(
44 "pycodestyle",
45 "continuation line indentation is not a multiple of four"),
46 "E122": QCoreApplication.translate(
47 "pycodestyle",
48 "continuation line missing indentation or outdented"),
49 "E123": QCoreApplication.translate(
50 "pycodestyle",
51 "closing bracket does not match indentation of opening"
52 " bracket's line"),
53 "E124": QCoreApplication.translate(
54 "pycodestyle",
55 "closing bracket does not match visual indentation"),
56 "E125": QCoreApplication.translate(
57 "pycodestyle",
58 "continuation line with same indent as next logical line"),
59 "E126": QCoreApplication.translate(
60 "pycodestyle",
61 "continuation line over-indented for hanging indent"),
62 "E127": QCoreApplication.translate(
63 "pycodestyle",
64 "continuation line over-indented for visual indent"),
65 "E128": QCoreApplication.translate(
66 "pycodestyle",
67 "continuation line under-indented for visual indent"),
68 "E129": QCoreApplication.translate(
69 "pycodestyle",
70 "visually indented line with same indent as next logical line"),
71 "E131": QCoreApplication.translate(
72 "pycodestyle",
73 "continuation line unaligned for hanging indent"),
74 "E133": QCoreApplication.translate(
75 "pycodestyle",
76 "closing bracket is missing indentation"),
77 "W191": QCoreApplication.translate(
78 "pycodestyle",
79 "indentation contains tabs"),
80 "E201": QCoreApplication.translate(
81 "pycodestyle",
82 "whitespace after '{0}'"),
83 "E202": QCoreApplication.translate(
84 "pycodestyle",
85 "whitespace before '{0}'"),
86 "E203": QCoreApplication.translate(
87 "pycodestyle",
88 "whitespace before '{0}'"),
89 "E211": QCoreApplication.translate(
90 "pycodestyle",
91 "whitespace before '{0}'"),
92 "E221": QCoreApplication.translate(
93 "pycodestyle",
94 "multiple spaces before operator"),
95 "E222": QCoreApplication.translate(
96 "pycodestyle",
97 "multiple spaces after operator"),
98 "E223": QCoreApplication.translate(
99 "pycodestyle",
100 "tab before operator"),
101 "E224": QCoreApplication.translate(
102 "pycodestyle",
103 "tab after operator"),
104 "E225": QCoreApplication.translate(
105 "pycodestyle",
106 "missing whitespace around operator"),
107 "E226": QCoreApplication.translate(
108 "pycodestyle",
109 "missing whitespace around arithmetic operator"),
110 "E227": QCoreApplication.translate(
111 "pycodestyle",
112 "missing whitespace around bitwise or shift operator"),
113 "E228": QCoreApplication.translate(
114 "pycodestyle",
115 "missing whitespace around modulo operator"),
116 "E231": QCoreApplication.translate(
117 "pycodestyle",
118 "missing whitespace after '{0}'"),
119 "E241": QCoreApplication.translate(
120 "pycodestyle",
121 "multiple spaces after '{0}'"),
122 "E242": QCoreApplication.translate(
123 "pycodestyle",
124 "tab after '{0}'"),
125 "E251": QCoreApplication.translate(
126 "pycodestyle",
127 "unexpected spaces around keyword / parameter equals"),
128 "E252": QCoreApplication.translate(
129 "pycodestyle",
130 "missing whitespace around parameter equals"),
131 "E261": QCoreApplication.translate(
132 "pycodestyle",
133 "at least two spaces before inline comment"),
134 "E262": QCoreApplication.translate(
135 "pycodestyle",
136 "inline comment should start with '# '"),
137 "E265": QCoreApplication.translate(
138 "pycodestyle",
139 "block comment should start with '# '"),
140 "E266": QCoreApplication.translate(
141 "pycodestyle",
142 "too many leading '#' for block comment"),
143 "E271": QCoreApplication.translate(
144 "pycodestyle",
145 "multiple spaces after keyword"),
146 "E272": QCoreApplication.translate(
147 "pycodestyle",
148 "multiple spaces before keyword"),
149 "E273": QCoreApplication.translate(
150 "pycodestyle",
151 "tab after keyword"),
152 "E274": QCoreApplication.translate(
153 "pycodestyle",
154 "tab before keyword"),
155 "E275": QCoreApplication.translate(
156 "pycodestyle",
157 "missing whitespace after keyword"),
158 "W291": QCoreApplication.translate(
159 "pycodestyle",
160 "trailing whitespace"),
161 "W292": QCoreApplication.translate(
162 "pycodestyle",
163 "no newline at end of file"),
164 "W293": QCoreApplication.translate(
165 "pycodestyle",
166 "blank line contains whitespace"),
167 "E301": QCoreApplication.translate(
168 "pycodestyle",
169 "expected {0} blank lines, found {1}"),
170 "E302": QCoreApplication.translate(
171 "pycodestyle",
172 "expected {0} blank lines, found {1}"),
173 "E303": QCoreApplication.translate(
174 "pycodestyle",
175 "too many blank lines ({0}), expected {1}"),
176 "E304": QCoreApplication.translate(
177 "pycodestyle",
178 "blank lines found after function decorator"),
179 "E305": QCoreApplication.translate(
180 "pycodestyle",
181 "expected {0} blank lines after class or function definition,"
182 " found {1}"),
183 "E306": QCoreApplication.translate(
184 "pycodestyle",
185 "expected {0} blank lines before a nested definition, found {1}"),
186 "E307": QCoreApplication.translate(
187 "pycodestyle",
188 "too many blank lines ({0}) before a nested definition, expected {1}"),
189 "E308": QCoreApplication.translate(
190 "pycodestyle",
191 "too many blank lines ({0})"),
192 "W391": QCoreApplication.translate(
193 "pycodestyle",
194 "blank line at end of file"),
195 "E401": QCoreApplication.translate(
196 "pycodestyle",
197 "multiple imports on one line"),
198 "E402": QCoreApplication.translate(
199 "pycodestyle",
200 "module level import not at top of file"),
201 "E501": QCoreApplication.translate(
202 "pycodestyle",
203 "line too long ({0} > {1} characters)"),
204 "E502": QCoreApplication.translate(
205 "pycodestyle",
206 "the backslash is redundant between brackets"),
207 "W503": QCoreApplication.translate(
208 "pycodestyle",
209 "line break before binary operator"),
210 "W504": QCoreApplication.translate(
211 "pycodestyle",
212 "line break after binary operator"),
213 "W505": QCoreApplication.translate(
214 "pycodestyle",
215 "doc line too long ({0} > {1} characters)"),
216 "W601": QCoreApplication.translate(
217 "pycodestyle",
218 ".has_key() is deprecated, use 'in'"),
219 "W602": QCoreApplication.translate(
220 "pycodestyle",
221 "deprecated form of raising exception"),
222 "W603": QCoreApplication.translate(
223 "pycodestyle",
224 "'<>' is deprecated, use '!='"),
225 "W604": QCoreApplication.translate(
226 "pycodestyle",
227 "backticks are deprecated, use 'repr()'"),
228 "W605": QCoreApplication.translate(
229 "pycodestyle",
230 "invalid escape sequence '\\{0}'"),
231 "W606": QCoreApplication.translate(
232 "pycodestyle",
233 "'async' and 'await' are reserved keywords starting with Python 3.7"),
234 "E701": QCoreApplication.translate(
235 "pycodestyle",
236 "multiple statements on one line (colon)"),
237 "E702": QCoreApplication.translate(
238 "pycodestyle",
239 "multiple statements on one line (semicolon)"),
240 "E703": QCoreApplication.translate(
241 "pycodestyle",
242 "statement ends with a semicolon"),
243 "E704": QCoreApplication.translate(
244 "pycodestyle",
245 "multiple statements on one line (def)"),
246 "E711": QCoreApplication.translate(
247 "pycodestyle",
248 "comparison to {0} should be {1}"),
249 "E712": QCoreApplication.translate(
250 "pycodestyle",
251 "comparison to {0} should be {1}"),
252 "E713": QCoreApplication.translate(
253 "pycodestyle",
254 "test for membership should be 'not in'"),
255 "E714": QCoreApplication.translate(
256 "pycodestyle",
257 "test for object identity should be 'is not'"),
258 "E721": QCoreApplication.translate(
259 "pycodestyle",
260 "do not compare types, use 'isinstance()'"),
261 "E722": QCoreApplication.translate(
262 "pycodestyle",
263 "do not use bare except"),
264 "E731": QCoreApplication.translate(
265 "pycodestyle",
266 "do not assign a lambda expression, use a def"),
267 "E741": QCoreApplication.translate(
268 "pycodestyle",
269 "ambiguous variable name '{0}'"),
270 "E742": QCoreApplication.translate(
271 "pycodestyle",
272 "ambiguous class definition '{0}'"),
273 "E743": QCoreApplication.translate(
274 "pycodestyle",
275 "ambiguous function definition '{0}'"),
276 "E901": QCoreApplication.translate(
277 "pycodestyle",
278 "{0}: {1}"),
279 "E902": QCoreApplication.translate(
280 "pycodestyle",
281 "{0}"),
282
283 # DocStyleChecker messages
284 "D101": QCoreApplication.translate(
285 "DocStyleChecker", "module is missing a docstring"),
286 "D102": QCoreApplication.translate(
287 "DocStyleChecker",
288 "public function/method is missing a docstring"),
289 "D103": QCoreApplication.translate(
290 "DocStyleChecker",
291 "private function/method may be missing a docstring"),
292 "D104": QCoreApplication.translate(
293 "DocStyleChecker", "public class is missing a docstring"),
294 "D105": QCoreApplication.translate(
295 "DocStyleChecker", "private class may be missing a docstring"),
296 "D111": QCoreApplication.translate(
297 "DocStyleChecker", 'docstring not surrounded by """'),
298 "D112": QCoreApplication.translate(
299 "DocStyleChecker",
300 'docstring containing \\ not surrounded by r"""'),
301 "D113": QCoreApplication.translate(
302 "DocStyleChecker",
303 'docstring containing unicode character not surrounded by u"""'),
304 "D121": QCoreApplication.translate(
305 "DocStyleChecker", "one-liner docstring on multiple lines"),
306 "D122": QCoreApplication.translate(
307 "DocStyleChecker", "docstring has wrong indentation"),
308 "D130": QCoreApplication.translate(
309 "DocStyleChecker", "docstring does not contain a summary"),
310 "D131": QCoreApplication.translate(
311 "DocStyleChecker", "docstring summary does not end with a period"),
312 "D132": QCoreApplication.translate(
313 "DocStyleChecker",
314 "docstring summary is not in imperative mood"
315 " (Does instead of Do)"),
316 "D133": QCoreApplication.translate(
317 "DocStyleChecker",
318 "docstring summary looks like a function's/method's signature"),
319 "D134": QCoreApplication.translate(
320 "DocStyleChecker",
321 "docstring does not mention the return value type"),
322 "D141": QCoreApplication.translate(
323 "DocStyleChecker",
324 "function/method docstring is separated by a blank line"),
325 "D142": QCoreApplication.translate(
326 "DocStyleChecker",
327 "class docstring is not preceded by a blank line"),
328 "D143": QCoreApplication.translate(
329 "DocStyleChecker",
330 "class docstring is not followed by a blank line"),
331 "D144": QCoreApplication.translate(
332 "DocStyleChecker",
333 "docstring summary is not followed by a blank line"),
334 "D145": QCoreApplication.translate(
335 "DocStyleChecker",
336 "last paragraph of docstring is not followed by a blank line"),
337
338 "D201": QCoreApplication.translate(
339 "DocStyleChecker", "module docstring is still a default string"),
340 "D202": QCoreApplication.translate(
341 "DocStyleChecker", "function docstring is still a default string"),
342 "D203": QCoreApplication.translate(
343 "DocStyleChecker",
344 "private function/method is missing a docstring"),
345 "D205": QCoreApplication.translate(
346 "DocStyleChecker", "private class is missing a docstring"),
347 "D206": QCoreApplication.translate(
348 "DocStyleChecker", "class docstring is still a default string"),
349 "D221": QCoreApplication.translate(
350 "DocStyleChecker",
351 "leading quotes of docstring not on separate line"),
352 "D222": QCoreApplication.translate(
353 "DocStyleChecker",
354 "trailing quotes of docstring not on separate line"),
355 "D231": QCoreApplication.translate(
356 "DocStyleChecker", "docstring summary does not end with a period"),
357 "D232": QCoreApplication.translate(
358 "DocStyleChecker", "docstring summary does not start with '{0}'"),
359 "D234": QCoreApplication.translate(
360 "DocStyleChecker",
361 "docstring does not contain a @return line but function/method"
362 " returns something"),
363 "D235": QCoreApplication.translate(
364 "DocStyleChecker",
365 "docstring contains a @return line but function/method doesn't"
366 " return anything"),
367 "D236": QCoreApplication.translate(
368 "DocStyleChecker",
369 "docstring does not contain enough @param/@keyparam lines"),
370 "D237": QCoreApplication.translate(
371 "DocStyleChecker",
372 "docstring contains too many @param/@keyparam lines"),
373 "D238": QCoreApplication.translate(
374 "DocStyleChecker",
375 "keyword only arguments must be documented with @keyparam lines"),
376 "D239": QCoreApplication.translate(
377 "DocStyleChecker", "order of @param/@keyparam lines does"
378 " not match the function/method signature"),
379 "D242": QCoreApplication.translate(
380 "DocStyleChecker", "class docstring is preceded by a blank line"),
381 "D243": QCoreApplication.translate(
382 "DocStyleChecker", "class docstring is followed by a blank line"),
383 "D244": QCoreApplication.translate(
384 "DocStyleChecker",
385 "function/method docstring is preceded by a blank line"),
386 "D245": QCoreApplication.translate(
387 "DocStyleChecker",
388 "function/method docstring is followed by a blank line"),
389 "D246": QCoreApplication.translate(
390 "DocStyleChecker",
391 "docstring summary is not followed by a blank line"),
392 "D247": QCoreApplication.translate(
393 "DocStyleChecker",
394 "last paragraph of docstring is followed by a blank line"),
395 "D250": QCoreApplication.translate(
396 "DocStyleChecker",
397 "docstring does not contain a @exception line but function/method"
398 " raises an exception"),
399 "D251": QCoreApplication.translate(
400 "DocStyleChecker",
401 "docstring contains a @exception line but function/method doesn't"
402 " raise an exception"),
403 "D252": QCoreApplication.translate(
404 "DocStyleChecker",
405 "raised exception '{0}' is not documented in docstring"),
406 "D253": QCoreApplication.translate(
407 "DocStyleChecker",
408 "documented exception '{0}' is not raised"),
409 "D260": QCoreApplication.translate(
410 "DocStyleChecker",
411 "docstring does not contain a @signal line but class defines signals"),
412 "D261": QCoreApplication.translate(
413 "DocStyleChecker",
414 "docstring contains a @signal line but class doesn't define signals"),
415 "D262": QCoreApplication.translate(
416 "DocStyleChecker",
417 "defined signal '{0}' is not documented in docstring"),
418 "D263": QCoreApplication.translate(
419 "DocStyleChecker",
420 "documented signal '{0}' is not defined"),
421
422 "D901": QCoreApplication.translate(
423 "DocStyleChecker", "{0}: {1}"),
424
425 # NamingStyleChecker messages
426 "N801": QCoreApplication.translate(
427 "NamingStyleChecker",
428 "class names should use CapWords convention"),
429 "N802": QCoreApplication.translate(
430 "NamingStyleChecker",
431 "function name should be lowercase"),
432 "N803": QCoreApplication.translate(
433 "NamingStyleChecker",
434 "argument name should be lowercase"),
435 "N804": QCoreApplication.translate(
436 "NamingStyleChecker",
437 "first argument of a class method should be named 'cls'"),
438 "N805": QCoreApplication.translate(
439 "NamingStyleChecker",
440 "first argument of a method should be named 'self'"),
441 "N806": QCoreApplication.translate(
442 "NamingStyleChecker",
443 "first argument of a static method should not be named"
444 " 'self' or 'cls"),
445 "N807": QCoreApplication.translate(
446 "NamingStyleChecker",
447 "module names should be lowercase"),
448 "N808": QCoreApplication.translate(
449 "NamingStyleChecker",
450 "package names should be lowercase"),
451 "N811": QCoreApplication.translate(
452 "NamingStyleChecker",
453 "constant imported as non constant"),
454 "N812": QCoreApplication.translate(
455 "NamingStyleChecker",
456 "lowercase imported as non lowercase"),
457 "N813": QCoreApplication.translate(
458 "NamingStyleChecker",
459 "camelcase imported as lowercase"),
460 "N814": QCoreApplication.translate(
461 "NamingStyleChecker",
462 "camelcase imported as constant"),
463 "N821": QCoreApplication.translate(
464 "NamingStyleChecker",
465 "variable in function should be lowercase"),
466 "N831": QCoreApplication.translate(
467 "NamingStyleChecker",
468 "names 'l', 'O' and 'I' should be avoided"),
469
470 # Code complexity messages
471 "C101": QCoreApplication.translate(
472 "ComplexityChecker", "'{0}' is too complex ({1})"),
473 "C111": QCoreApplication.translate(
474 "ComplexityChecker", "source code line is too complex ({0})"),
475 "C112": QCoreApplication.translate(
476 "ComplexityChecker",
477 "overall source code line complexity is too high ({0})"),
478 "C901": QCoreApplication.translate(
479 "ComplexityChecker", "{0}: {1}"),
480
481 # Messages of the Miscellaneous Checker
482 "M101": QCoreApplication.translate(
483 "MiscellaneousChecker",
484 "coding magic comment not found"),
485 "M102": QCoreApplication.translate(
486 "MiscellaneousChecker",
487 "unknown encoding ({0}) found in coding magic comment"),
488 "M111": QCoreApplication.translate(
489 "MiscellaneousChecker",
490 "copyright notice not present"),
491 "M112": QCoreApplication.translate(
492 "MiscellaneousChecker",
493 "copyright notice contains invalid author"),
494 "M131": QCoreApplication.translate(
495 "MiscellaneousChecker",
496 '"{0}" is a Python builtin and is being shadowed; '
497 'consider renaming the variable'),
498 "M132": QCoreApplication.translate(
499 "MiscellaneousChecker",
500 '"{0}" is used as an argument and thus shadows a '
501 'Python builtin; consider renaming the argument'),
502 "M191": QCoreApplication.translate(
503 "MiscellaneousChecker",
504 'unnecessary generator - rewrite as a list comprehension'),
505 "M192": QCoreApplication.translate(
506 "MiscellaneousChecker",
507 'unnecessary generator - rewrite as a set comprehension'),
508 "M193": QCoreApplication.translate(
509 "MiscellaneousChecker",
510 'unnecessary generator - rewrite as a dict comprehension'),
511 "M194": QCoreApplication.translate(
512 "MiscellaneousChecker",
513 'unnecessary list comprehension - rewrite as a set comprehension'),
514 "M195": QCoreApplication.translate(
515 "MiscellaneousChecker",
516 'unnecessary list comprehension - rewrite as a dict comprehension'),
517 "M196": QCoreApplication.translate(
518 "MiscellaneousChecker",
519 'unnecessary list literal - rewrite as a set literal'),
520 "M197": QCoreApplication.translate(
521 "MiscellaneousChecker",
522 'unnecessary list literal - rewrite as a dict literal'),
523 "M198": QCoreApplication.translate(
524 "MiscellaneousChecker",
525 'unnecessary list comprehension - "{0}" can take a generator'),
526 "M201": QCoreApplication.translate(
527 "MiscellaneousChecker",
528 "sort keys - '{0}' should be before '{1}'"),
529 "M501": QCoreApplication.translate(
530 "MiscellaneousChecker",
531 "Python does not support the unary prefix increment"),
532 "M502": QCoreApplication.translate(
533 "MiscellaneousChecker",
534 "using .strip() with multi-character strings is misleading"),
535 "M503": QCoreApplication.translate(
536 "MiscellaneousChecker",
537 """using 'hasattr(x, "__call__")' to test if 'x' is callable is"""
538 """ unreliable"""),
539 "M504": QCoreApplication.translate(
540 "MiscellaneousChecker",
541 "'sys.maxint' is not defined in Python 3 - use 'sys.maxsize'"),
542 "M505": QCoreApplication.translate(
543 "MiscellaneousChecker",
544 "'BaseException.message' has been deprecated as of Python 2.6 and is"
545 " removed in Python 3 - use 'str(e)'"),
546 "M506": QCoreApplication.translate(
547 "MiscellaneousChecker",
548 "assigning to 'os.environ' does not clear the environment -"
549 " use 'os.environ.clear()'"),
550 "M507": QCoreApplication.translate(
551 "MiscellaneousChecker",
552 "loop control variable {0} not used within the loop body -"
553 " start the name with an underscore"),
554 "M511": QCoreApplication.translate(
555 "MiscellaneousChecker",
556 "Python 3 does not include '.iter*' methods on dictionaries"),
557 "M512": QCoreApplication.translate(
558 "MiscellaneousChecker",
559 "Python 3 does not include '.view*' methods on dictionaries"),
560 "M513": QCoreApplication.translate(
561 "MiscellaneousChecker",
562 "'.next()' does not exist in Python 3"),
563 "M514": QCoreApplication.translate(
564 "MiscellaneousChecker",
565 "'__metaclass__' does nothing on Python 3 -"
566 " use 'class MyClass(BaseClass, metaclass=...)'"),
567 "M601": QCoreApplication.translate(
568 "MiscellaneousChecker",
569 "found {0} formatter"),
570 "M611": QCoreApplication.translate(
571 "MiscellaneousChecker",
572 "format string does contain unindexed parameters"),
573 "M612": QCoreApplication.translate(
574 "MiscellaneousChecker",
575 "docstring does contain unindexed parameters"),
576 "M613": QCoreApplication.translate(
577 "MiscellaneousChecker",
578 "other string does contain unindexed parameters"),
579 "M621": QCoreApplication.translate(
580 "MiscellaneousChecker",
581 "format call uses too large index ({0})"),
582 "M622": QCoreApplication.translate(
583 "MiscellaneousChecker",
584 "format call uses missing keyword ({0})"),
585 "M623": QCoreApplication.translate(
586 "MiscellaneousChecker",
587 "format call uses keyword arguments but no named entries"),
588 "M624": QCoreApplication.translate(
589 "MiscellaneousChecker",
590 "format call uses variable arguments but no numbered entries"),
591 "M625": QCoreApplication.translate(
592 "MiscellaneousChecker",
593 "format call uses implicit and explicit indexes together"),
594 "M631": QCoreApplication.translate(
595 "MiscellaneousChecker",
596 "format call provides unused index ({0})"),
597 "M632": QCoreApplication.translate(
598 "MiscellaneousChecker",
599 "format call provides unused keyword ({0})"),
600 "M651": QCoreApplication.translate(
601 "MiscellaneousChecker",
602 "logging statement uses string.format()"),
603 "M652": QCoreApplication.translate(
604 "MiscellaneousChecker",
605 "logging statement uses '%'"), # __IGNORE_WARNING_M601__
606 "M653": QCoreApplication.translate(
607 "MiscellaneousChecker",
608 "logging statement uses '+'"),
609 "M654": QCoreApplication.translate(
610 "MiscellaneousChecker",
611 "logging statement uses f-string"),
612 "M655": QCoreApplication.translate(
613 "MiscellaneousChecker",
614 "logging statement uses 'warn' instead of 'warning'"),
615 "M701": QCoreApplication.translate(
616 "MiscellaneousChecker",
617 "expected these __future__ imports: {0}; but only got: {1}"),
618 "M702": QCoreApplication.translate(
619 "MiscellaneousChecker",
620 "expected these __future__ imports: {0}; but got none"),
621 "M711": QCoreApplication.translate(
622 "MiscellaneousChecker",
623 "gettext import with alias _ found: {0}"),
624 "M801": QCoreApplication.translate(
625 "MiscellaneousChecker",
626 "print statement found"),
627 "M811": QCoreApplication.translate(
628 "MiscellaneousChecker",
629 "one element tuple found"),
630 "M821": QCoreApplication.translate(
631 "MiscellaneousChecker",
632 "mutable default argument of type {0}"),
633 "M822": QCoreApplication.translate(
634 "MiscellaneousChecker",
635 "mutable default argument of type {0}"),
636 "M823": QCoreApplication.translate(
637 "MiscellaneousChecker",
638 "mutable default argument of function call '{0}'"),
639 "M831": QCoreApplication.translate(
640 "MiscellaneousChecker",
641 "None should not be added at any return if function has no return"
642 " value except None"),
643 "M832": QCoreApplication.translate(
644 "MiscellaneousChecker",
645 "an explicit value at every return should be added if function has"
646 " a return value except None"),
647 "M833": QCoreApplication.translate(
648 "MiscellaneousChecker",
649 "an explicit return at the end of the function should be added if"
650 " it has a return value except None"),
651 "M834": QCoreApplication.translate(
652 "MiscellaneousChecker",
653 "a value should not be assigned to a variable if it will be used as a"
654 " return value only"),
655 "M901": QCoreApplication.translate(
656 "MiscellaneousChecker",
657 "{0}: {1}"),
658
659 # CodeStyleFixer messages
660 "FD111": QCoreApplication.translate(
661 'CodeStyleFixer',
662 "Triple single quotes converted to triple double quotes."),
663 'FD112': QCoreApplication.translate(
664 'CodeStyleFixer',
665 'Introductory quotes corrected to be {0}"""'),
666 "FD121": QCoreApplication.translate(
667 'CodeStyleFixer',
668 "Single line docstring put on one line."),
669 "FD131": QCoreApplication.translate(
670 'CodeStyleFixer',
671 "Period added to summary line."),
672 "FD141": QCoreApplication.translate(
673 'CodeStyleFixer',
674 "Blank line before function/method docstring removed."),
675 "FD142": QCoreApplication.translate(
676 'CodeStyleFixer',
677 "Blank line inserted before class docstring."),
678 "FD143": QCoreApplication.translate(
679 'CodeStyleFixer',
680 "Blank line inserted after class docstring."),
681 "FD144": QCoreApplication.translate(
682 'CodeStyleFixer',
683 "Blank line inserted after docstring summary."),
684 "FD145": QCoreApplication.translate(
685 'CodeStyleFixer',
686 "Blank line inserted after last paragraph of docstring."),
687 "FD221": QCoreApplication.translate(
688 'CodeStyleFixer',
689 "Leading quotes put on separate line."),
690 "FD222": QCoreApplication.translate(
691 'CodeStyleFixer',
692 "Trailing quotes put on separate line."),
693 "FD242": QCoreApplication.translate(
694 'CodeStyleFixer',
695 "Blank line before class docstring removed."),
696 "FD244": QCoreApplication.translate(
697 'CodeStyleFixer',
698 "Blank line before function/method docstring removed."),
699 "FD243": QCoreApplication.translate(
700 'CodeStyleFixer',
701 "Blank line after class docstring removed."),
702 "FD245": QCoreApplication.translate(
703 'CodeStyleFixer',
704 "Blank line after function/method docstring removed."),
705 "FD247": QCoreApplication.translate(
706 'CodeStyleFixer',
707 "Blank line after last paragraph removed."),
708 "FE101": QCoreApplication.translate(
709 'CodeStyleFixer',
710 "Tab converted to 4 spaces."),
711 "FE111": QCoreApplication.translate(
712 'CodeStyleFixer',
713 "Indentation adjusted to be a multiple of four."),
714 "FE121": QCoreApplication.translate(
715 'CodeStyleFixer',
716 "Indentation of continuation line corrected."),
717 "FE124": QCoreApplication.translate(
718 'CodeStyleFixer',
719 "Indentation of closing bracket corrected."),
720 "FE122": QCoreApplication.translate(
721 'CodeStyleFixer',
722 "Missing indentation of continuation line corrected."),
723 "FE123": QCoreApplication.translate(
724 'CodeStyleFixer',
725 "Closing bracket aligned to opening bracket."),
726 "FE125": QCoreApplication.translate(
727 'CodeStyleFixer',
728 "Indentation level changed."),
729 "FE126": QCoreApplication.translate(
730 'CodeStyleFixer',
731 "Indentation level of hanging indentation changed."),
732 "FE127": QCoreApplication.translate(
733 'CodeStyleFixer',
734 "Visual indentation corrected."),
735 "FE201": QCoreApplication.translate(
736 'CodeStyleFixer',
737 "Extraneous whitespace removed."),
738 "FE225": QCoreApplication.translate(
739 'CodeStyleFixer',
740 "Missing whitespace added."),
741 "FE221": QCoreApplication.translate(
742 'CodeStyleFixer',
743 "Extraneous whitespace removed."),
744 "FE231": QCoreApplication.translate(
745 'CodeStyleFixer',
746 "Missing whitespace added."),
747 "FE251": QCoreApplication.translate(
748 'CodeStyleFixer',
749 "Extraneous whitespace removed."),
750 "FE261": QCoreApplication.translate(
751 'CodeStyleFixer',
752 "Whitespace around comment sign corrected."),
753
754 "FE302+": lambda n=1: translate(
755 'CodeStyleFixer',
756 "%n blank line(s) inserted.", '', n),
757 "FE302-": lambda n=1: translate(
758 'CodeStyleFixer',
759 "%n superfluous lines removed", '', n),
760
761 "FE303": QCoreApplication.translate(
762 'CodeStyleFixer',
763 "Superfluous blank lines removed."),
764 "FE304": QCoreApplication.translate(
765 'CodeStyleFixer',
766 "Superfluous blank lines after function decorator removed."),
767 "FE401": QCoreApplication.translate(
768 'CodeStyleFixer',
769 "Imports were put on separate lines."),
770 "FE501": QCoreApplication.translate(
771 'CodeStyleFixer',
772 "Long lines have been shortened."),
773 "FE502": QCoreApplication.translate(
774 'CodeStyleFixer',
775 "Redundant backslash in brackets removed."),
776 "FE701": QCoreApplication.translate(
777 'CodeStyleFixer',
778 "Compound statement corrected."),
779 "FE702": QCoreApplication.translate(
780 'CodeStyleFixer',
781 "Compound statement corrected."),
782 "FE711": QCoreApplication.translate(
783 'CodeStyleFixer',
784 "Comparison to None/True/False corrected."),
785 "FN804": QCoreApplication.translate(
786 'CodeStyleFixer',
787 "'{0}' argument added."),
788 "FN806": QCoreApplication.translate(
789 'CodeStyleFixer',
790 "'{0}' argument removed."),
791 "FW291": QCoreApplication.translate(
792 'CodeStyleFixer',
793 "Whitespace stripped from end of line."),
794 "FW292": QCoreApplication.translate(
795 'CodeStyleFixer',
796 "newline added to end of file."),
797 "FW391": QCoreApplication.translate(
798 'CodeStyleFixer',
799 "Superfluous trailing blank lines removed from end of file."),
800 "FW603": QCoreApplication.translate(
801 'CodeStyleFixer',
802 "'<>' replaced by '!='."),
803
804 "FWRITE_ERROR": QCoreApplication.translate(
805 'CodeStyleFixer',
806 "Could not save the file! Skipping it. Reason: {0}"),
807 }
808
809 _messages_sample_args = {
810 "E201": ["([{"],
811 "E202": ["}])"],
812 "E203": [",;:"],
813 "E211": ["(["],
814 "E231": [",;:"],
815 "E241": [",;:"],
816 "E242": [",;:"],
817 "E301": [1, 0],
818 "E302": [2, 1],
819 "E303": [3, 2],
820 "E305": [2, 1],
821 "E306": [1, 0],
822 "E307": [3, 1],
823 "E308": [3],
824 "E501": [85, 79],
825 "W505": [80, 72],
826 "E605": ["A"],
827 "E711": ["None", "'if cond is None:'"],
828 "E712": ["True", "'if cond is True:' or 'if cond:'"],
829 "E741": ["l"],
830 "E742": ["l"],
831 "E743": ["l"],
832 "E901": ["SyntaxError", "Invalid Syntax"],
833 "E902": ["IOError"],
834 "D232": ["public"],
835 "D252": ["RuntimeError"],
836 "D253": ["RuntimeError"],
837 "D262": ["buttonClicked"],
838 "D263": ["buttonClicked"],
839 "D901": ["SyntaxError", "Invalid Syntax"],
840 "C101": ["foo.bar", "42"],
841 "C111": [42],
842 "C112": [12.0],
843 "C901": ["SyntaxError", "Invalid Syntax"],
844 "M102": ["enc42"],
845 "M131": ["list"],
846 "M132": ["list"],
847 "M198": ["sorted"],
848 "M201": ["bar", "foo"],
849 "M507": ["x"],
850 "M601": ["%s"],
851 "M621": [5],
852 "M622": ["foo"],
853 "M631": [5],
854 "M632": ["foo"],
855 "M701": ["print_function, unicode_literals", "print_function"],
856 "M702": ["print_function, unicode_literals"],
857 "M711": ["lgettext"],
858 "M821": ["Dict"],
859 "M822": ["Call"],
860 "M823": ["dict"],
861 "M901": ["SyntaxError", "Invalid Syntax"],
862 "FWRITE_ERROR": ["IOError"],
863 }
864
865
866 def getTranslatedMessage(message):
867 """
868 Module function to get a translated and formatted message for a
869 given pyflakes message ID.
870
871 @param message the message ID (string)
872 @return translated and formatted message (string)
873 """
874 if isinstance(message, list):
875 message, args = message
876 else:
877 args = []
878
879 if message in _messages:
880 if isinstance(args, int):
881 # Retranslate with correct plural form
882 return _messages[message](args)
883 else:
884 if message.startswith(('FD', 'FE', 'FN', 'FW')):
885 prefix = ''
886 else:
887 prefix = message + ' '
888 return prefix + _messages[message].format(*args)
889 elif ' ' in message:
890 # already translated
891 return message
892 else:
893 return QCoreApplication.translate(
894 "CodeStyleFixer", " no message defined for code '{0}'")\
895 .format(message)
896
897 #
898 # eflag: noqa = M201

eric ide

mercurial