src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/translations.py

branch
eric7
changeset 10360
9ffdb1490bd2
parent 10359
de0420dac60e
child 10361
e6ff9a4f6ee5
equal deleted inserted replaced
10359:de0420dac60e 10360:9ffdb1490bd2
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 "M101": QCoreApplication.translate(
17 "MiscellaneousChecker", "coding magic comment not found" 17 "MiscellaneousChecker",
18 "coding magic comment not found",
18 ), 19 ),
19 "M102": QCoreApplication.translate( 20 "M102": QCoreApplication.translate(
20 "MiscellaneousChecker", "unknown encoding ({0}) found in coding magic comment" 21 "MiscellaneousChecker",
22 "unknown encoding ({0}) found in coding magic comment",
21 ), 23 ),
22 ## Copyright 24 ## Copyright
23 "M111": QCoreApplication.translate( 25 "M111": QCoreApplication.translate(
24 "MiscellaneousChecker", "copyright notice not present" 26 "MiscellaneousChecker",
27 "copyright notice not present",
25 ), 28 ),
26 "M112": QCoreApplication.translate( 29 "M112": QCoreApplication.translate(
27 "MiscellaneousChecker", "copyright notice contains invalid author" 30 "MiscellaneousChecker",
31 "copyright notice contains invalid author",
28 ), 32 ),
29 ## Shadowed Builtins 33 ## Shadowed Builtins
30 "M131": QCoreApplication.translate( 34 "M131": QCoreApplication.translate(
31 "MiscellaneousChecker", 35 "MiscellaneousChecker",
32 '"{0}" is a Python builtin and is being shadowed; ' 36 '"{0}" is a Python builtin and is being shadowed; '
36 "MiscellaneousChecker", 40 "MiscellaneousChecker",
37 '"{0}" is used as an argument and thus shadows a ' 41 '"{0}" is used as an argument and thus shadows a '
38 "Python builtin; consider renaming the argument", 42 "Python builtin; consider renaming the argument",
39 ), 43 ),
40 ## Comprehensions 44 ## Comprehensions
45 "M180": QCoreApplication.translate(
46 "MiscellaneousChecker",
47 "unnecessary generator - rewrite as a list comprehension",
48 ),
41 "M181": QCoreApplication.translate( 49 "M181": QCoreApplication.translate(
42 "MiscellaneousChecker", 50 "MiscellaneousChecker",
43 "unnecessary generator - rewrite as a list comprehension", 51 "unnecessary generator - rewrite as a set comprehension",
44 ), 52 ),
45 "M182": QCoreApplication.translate( 53 "M182": QCoreApplication.translate(
46 "MiscellaneousChecker", "unnecessary generator - rewrite as a set comprehension" 54 "MiscellaneousChecker",
55 "unnecessary generator - rewrite as a dict comprehension",
47 ), 56 ),
48 "M183": QCoreApplication.translate( 57 "M183": QCoreApplication.translate(
49 "MiscellaneousChecker", 58 "MiscellaneousChecker",
50 "unnecessary generator - rewrite as a dict comprehension", 59 "unnecessary list comprehension - rewrite as a set comprehension",
51 ), 60 ),
52 "M184": QCoreApplication.translate( 61 "M184": QCoreApplication.translate(
53 "MiscellaneousChecker", 62 "MiscellaneousChecker",
54 "unnecessary list comprehension - rewrite as a set comprehension", 63 "unnecessary list comprehension - rewrite as a dict comprehension",
55 ), 64 ),
56 "M185": QCoreApplication.translate( 65 "M185": QCoreApplication.translate(
57 "MiscellaneousChecker", 66 "MiscellaneousChecker",
58 "unnecessary list comprehension - rewrite as a dict comprehension", 67 "unnecessary {0} literal - rewrite as a {1} literal",
59 ), 68 ),
60 "M186": QCoreApplication.translate( 69 "M186": QCoreApplication.translate(
61 "MiscellaneousChecker", "unnecessary {0} call - rewrite as a literal" 70 "MiscellaneousChecker",
62 ), 71 "unnecessary {0} literal - rewrite as a {1} literal",
63 "M187a": QCoreApplication.translate( 72 ),
73 "M188": QCoreApplication.translate(
74 "MiscellaneousChecker",
75 "unnecessary {0} call - rewrite as a literal",
76 ),
77 "M189a": QCoreApplication.translate(
78 "MiscellaneousChecker",
79 "unnecessary {0} passed to tuple() - remove the outer call to {1}()",
80 ),
81 "M189b": QCoreApplication.translate(
82 "MiscellaneousChecker",
83 "unnecessary {0} passed to tuple() - rewrite as a {1} literal",
84 ),
85 "M190a": QCoreApplication.translate(
86 "MiscellaneousChecker",
87 "unnecessary {0} passed to list() - remove the outer call to {1}()",
88 ),
89 "M190b": QCoreApplication.translate(
90 "MiscellaneousChecker",
91 "unnecessary {0} passed to list() - rewrite as a {1} literal",
92 ),
93 "M191": QCoreApplication.translate(
94 "MiscellaneousChecker",
95 "unnecessary list call - remove the outer call to list()",
96 ),
97 "M193a": QCoreApplication.translate(
64 "MiscellaneousChecker", 98 "MiscellaneousChecker",
65 "unnecessary {0} call around {1}() - toggle reverse argument to sorted()", 99 "unnecessary {0} call around {1}() - toggle reverse argument to sorted()",
66 ), 100 ),
67 "M187b": QCoreApplication.translate( 101 "M193b": QCoreApplication.translate(
68 "MiscellaneousChecker", 102 "MiscellaneousChecker",
69 "unnecessary {0} call around {1}() - use sorted(..., reverse={2})", 103 "unnecessary {0} call around {1}() - use sorted(..., reverse={2!r})",
70 ), 104 ),
71 "M187c": QCoreApplication.translate( 105 "M193c": QCoreApplication.translate(
72 "MiscellaneousChecker", "unnecessary {0} call around {1}()" 106 "MiscellaneousChecker",
73 ), 107 "unnecessary {0} call around {1}()",
74 "M188": QCoreApplication.translate( 108 ),
75 "MiscellaneousChecker", "unnecessary {0} call within {1}()" 109 "M194": QCoreApplication.translate(
76 ), 110 "MiscellaneousChecker",
77 "M189": QCoreApplication.translate( 111 "unnecessary {0} call within {1}()",
112 ),
113 "M195": QCoreApplication.translate(
78 "MiscellaneousChecker", 114 "MiscellaneousChecker",
79 "unnecessary subscript reversal of iterable within {0}()", 115 "unnecessary subscript reversal of iterable within {0}()",
80 ), 116 ),
81 "M191": QCoreApplication.translate(
82 "MiscellaneousChecker", "unnecessary {0} literal - rewrite as a {1} literal"
83 ),
84 "M192": QCoreApplication.translate(
85 "MiscellaneousChecker",
86 "unnecessary {0} passed to tuple() - rewrite as a {1} literal",
87 ),
88 "M193": QCoreApplication.translate(
89 "MiscellaneousChecker",
90 "unnecessary {0} passed to list() - rewrite as a {1} literal",
91 ),
92 "M195": QCoreApplication.translate(
93 "MiscellaneousChecker",
94 "unnecessary list call - remove the outer call to list()",
95 ),
96 "M196": QCoreApplication.translate( 117 "M196": QCoreApplication.translate(
97 "MiscellaneousChecker", "unnecessary {0} comprehension - rewrite using {0}()" 118 "MiscellaneousChecker",
119 "unnecessary {0} comprehension - rewrite using {0}()",
98 ), 120 ),
99 "M197": QCoreApplication.translate( 121 "M197": QCoreApplication.translate(
100 "MiscellaneousChecker", 122 "MiscellaneousChecker",
101 "unnecessary {0} passed to tuple() - remove the outer call to {1}()", 123 "Unnecessary use of map - use a {0} instead",
124
102 ), 125 ),
103 "M198": QCoreApplication.translate( 126 "M198": QCoreApplication.translate(
104 "MiscellaneousChecker", 127 "MiscellaneousChecker",
105 "unnecessary {0} passed to list() - remove the outer call to {1}()", 128 "Unnecessary {0} passed to dict() - remove the outer call to dict()"
106 ), 129 ),
130 "M199": QCoreApplication.translate(
131 "MiscellaneousChecker",
132 "Unnecessary list comprehension passed to {0}() prevents short-circuiting"
133 " - rewrite as a generator"
134 ),
135
136
137
138
107 ## Dictionaries with sorted keys 139 ## Dictionaries with sorted keys
108 "M201": QCoreApplication.translate( 140 "M201": QCoreApplication.translate(
109 "MiscellaneousChecker", "sort keys - '{0}' should be before '{1}'" 141 "MiscellaneousChecker",
142 "sort keys - '{0}' should be before '{1}'",
110 ), 143 ),
111 ## Property 144 ## Property
112 "M210": QCoreApplication.translate( 145 "M210": QCoreApplication.translate(
113 "MiscellaneousChecker", 146 "MiscellaneousChecker",
114 "the number of arguments for property getter method is wrong" 147 "the number of arguments for property getter method is wrong"
196 "MiscellaneousChecker", 229 "MiscellaneousChecker",
197 "use of 'datetime.date.fromtimestamp()' should be avoided.\n" 230 "use of 'datetime.date.fromtimestamp()' should be avoided.\n"
198 "Use 'datetime.datetime.fromtimestamp(tz=).date()' instead.", 231 "Use 'datetime.datetime.fromtimestamp(tz=).date()' instead.",
199 ), 232 ),
200 "M314": QCoreApplication.translate( 233 "M314": QCoreApplication.translate(
201 "MiscellaneousChecker", "use of 'datetime.date.fromordinal()' should be avoided" 234 "MiscellaneousChecker",
235 "use of 'datetime.date.fromordinal()' should be avoided",
202 ), 236 ),
203 "M315": QCoreApplication.translate( 237 "M315": QCoreApplication.translate(
204 "MiscellaneousChecker", 238 "MiscellaneousChecker",
205 "use of 'datetime.date.fromisoformat()' should be avoided", 239 "use of 'datetime.date.fromisoformat()' should be avoided",
206 ), 240 ),
224 "M411": QCoreApplication.translate( 258 "M411": QCoreApplication.translate(
225 "MiscellaneousChecker", 259 "MiscellaneousChecker",
226 "'sys.version_info[0] == 3' referenced (Python 4), use '>='", 260 "'sys.version_info[0] == 3' referenced (Python 4), use '>='",
227 ), 261 ),
228 "M412": QCoreApplication.translate( 262 "M412": QCoreApplication.translate(
229 "MiscellaneousChecker", "'six.PY3' referenced (Python 4), use 'not six.PY2'" 263 "MiscellaneousChecker",
264 "'six.PY3' referenced (Python 4), use 'not six.PY2'",
230 ), 265 ),
231 "M413": QCoreApplication.translate( 266 "M413": QCoreApplication.translate(
232 "MiscellaneousChecker", 267 "MiscellaneousChecker",
233 "'sys.version_info[1]' compared to integer (Python 4)," 268 "'sys.version_info[1]' compared to integer (Python 4),"
234 " compare 'sys.version_info' to tuple", 269 " compare 'sys.version_info' to tuple",
257 " errors, interrupts, system exit, and so on. Prefer 'except Exception:'." 292 " errors, interrupts, system exit, and so on. Prefer 'except Exception:'."
258 " If you're sure what you're doing, be explicit and write" 293 " If you're sure what you're doing, be explicit and write"
259 " 'except BaseException:'.", 294 " 'except BaseException:'.",
260 ), 295 ),
261 "M502": QCoreApplication.translate( 296 "M502": QCoreApplication.translate(
262 "MiscellaneousChecker", "Python does not support the unary prefix increment" 297 "MiscellaneousChecker",
298 "Python does not support the unary prefix increment",
263 ), 299 ),
264 "M503": QCoreApplication.translate( 300 "M503": QCoreApplication.translate(
265 "MiscellaneousChecker", 301 "MiscellaneousChecker",
266 "assigning to 'os.environ' does not clear the environment -" 302 "assigning to 'os.environ' does not clear the environment -"
267 " use 'os.environ.clear()'", 303 " use 'os.environ.clear()'",
281 "MiscellaneousChecker", 317 "MiscellaneousChecker",
282 "loop control variable {0} not used within the loop body -" 318 "loop control variable {0} not used within the loop body -"
283 " start the name with an underscore", 319 " start the name with an underscore",
284 ), 320 ),
285 "M509": QCoreApplication.translate( 321 "M509": QCoreApplication.translate(
286 "MiscellaneousChecker", "do not call getattr with a constant attribute value" 322 "MiscellaneousChecker",
323 "do not call getattr with a constant attribute value",
287 ), 324 ),
288 "M510": QCoreApplication.translate( 325 "M510": QCoreApplication.translate(
289 "MiscellaneousChecker", "do not call setattr with a constant attribute value" 326 "MiscellaneousChecker",
327 "do not call setattr with a constant attribute value",
290 ), 328 ),
291 "M511": QCoreApplication.translate( 329 "M511": QCoreApplication.translate(
292 "MiscellaneousChecker", 330 "MiscellaneousChecker",
293 "do not call assert False since python -O removes these calls", 331 "do not call assert False since python -O removes these calls",
294 ), 332 ),
421 "M535": QCoreApplication.translate( 459 "M535": QCoreApplication.translate(
422 "MiscellaneousChecker", 460 "MiscellaneousChecker",
423 "Static key in dict comprehension: {0!r}.", 461 "Static key in dict comprehension: {0!r}.",
424 ), 462 ),
425 ## Bugbear++ 463 ## Bugbear++
426 "M581": QCoreApplication.translate("MiscellaneousChecker", "unncessary f-string"), 464 "M581": QCoreApplication.translate(
465 "MiscellaneousChecker",
466 "unncessary f-string",
467 ),
427 "M582": QCoreApplication.translate( 468 "M582": QCoreApplication.translate(
428 "MiscellaneousChecker", 469 "MiscellaneousChecker",
429 "cannot use 'self.__class__' as first argument of 'super()' call", 470 "cannot use 'self.__class__' as first argument of 'super()' call",
430 ), 471 ),
431 ## Format Strings 472 ## Format Strings
432 "M601": QCoreApplication.translate("MiscellaneousChecker", "found {0} formatter"), 473 "M601": QCoreApplication.translate(
474 "MiscellaneousChecker",
475 "found {0} formatter",
476 ),
433 "M611": QCoreApplication.translate( 477 "M611": QCoreApplication.translate(
434 "MiscellaneousChecker", "format string does contain unindexed parameters" 478 "MiscellaneousChecker",
479 "format string does contain unindexed parameters",
435 ), 480 ),
436 "M612": QCoreApplication.translate( 481 "M612": QCoreApplication.translate(
437 "MiscellaneousChecker", "docstring does contain unindexed parameters" 482 "MiscellaneousChecker",
483 "docstring does contain unindexed parameters",
438 ), 484 ),
439 "M613": QCoreApplication.translate( 485 "M613": QCoreApplication.translate(
440 "MiscellaneousChecker", "other string does contain unindexed parameters" 486 "MiscellaneousChecker",
487 "other string does contain unindexed parameters",
441 ), 488 ),
442 "M621": QCoreApplication.translate( 489 "M621": QCoreApplication.translate(
443 "MiscellaneousChecker", "format call uses too large index ({0})" 490 "MiscellaneousChecker",
491 "format call uses too large index ({0})",
444 ), 492 ),
445 "M622": QCoreApplication.translate( 493 "M622": QCoreApplication.translate(
446 "MiscellaneousChecker", "format call uses missing keyword ({0})" 494 "MiscellaneousChecker",
495 "format call uses missing keyword ({0})",
447 ), 496 ),
448 "M623": QCoreApplication.translate( 497 "M623": QCoreApplication.translate(
449 "MiscellaneousChecker", 498 "MiscellaneousChecker",
450 "format call uses keyword arguments but no named entries", 499 "format call uses keyword arguments but no named entries",
451 ), 500 ),
456 "M625": QCoreApplication.translate( 505 "M625": QCoreApplication.translate(
457 "MiscellaneousChecker", 506 "MiscellaneousChecker",
458 "format call uses implicit and explicit indexes together", 507 "format call uses implicit and explicit indexes together",
459 ), 508 ),
460 "M631": QCoreApplication.translate( 509 "M631": QCoreApplication.translate(
461 "MiscellaneousChecker", "format call provides unused index ({0})" 510 "MiscellaneousChecker",
511 "format call provides unused index ({0})",
462 ), 512 ),
463 "M632": QCoreApplication.translate( 513 "M632": QCoreApplication.translate(
464 "MiscellaneousChecker", "format call provides unused keyword ({0})" 514 "MiscellaneousChecker",
515 "format call provides unused keyword ({0})",
465 ), 516 ),
466 ## Logging 517 ## Logging
467 "M651": QCoreApplication.translate( 518 "M651": QCoreApplication.translate(
468 "MiscellaneousChecker", "logging statement uses string.format()" 519 "MiscellaneousChecker",
520 "logging statement uses string.format()",
469 ), 521 ),
470 "M652": QCoreApplication.translate( 522 "M652": QCoreApplication.translate(
471 "MiscellaneousChecker", "logging statement uses '%'" # __IGNORE_WARNING_M601__ 523 "MiscellaneousChecker",
524 "logging statement uses '%'", # __IGNORE_WARNING_M601__
472 ), 525 ),
473 "M653": QCoreApplication.translate( 526 "M653": QCoreApplication.translate(
474 "MiscellaneousChecker", "logging statement uses '+'" 527 "MiscellaneousChecker",
528 "logging statement uses '+'",
475 ), 529 ),
476 "M654": QCoreApplication.translate( 530 "M654": QCoreApplication.translate(
477 "MiscellaneousChecker", "logging statement uses f-string" 531 "MiscellaneousChecker",
532 "logging statement uses f-string",
478 ), 533 ),
479 "M655": QCoreApplication.translate( 534 "M655": QCoreApplication.translate(
480 "MiscellaneousChecker", "logging statement uses 'warn' instead of 'warning'" 535 "MiscellaneousChecker",
536 "logging statement uses 'warn' instead of 'warning'",
481 ), 537 ),
482 ## Future statements 538 ## Future statements
483 "M701": QCoreApplication.translate( 539 "M701": QCoreApplication.translate(
484 "MiscellaneousChecker", 540 "MiscellaneousChecker",
485 "expected these __future__ imports: {0}; but only got: {1}", 541 "expected these __future__ imports: {0}; but only got: {1}",
486 ), 542 ),
487 "M702": QCoreApplication.translate( 543 "M702": QCoreApplication.translate(
488 "MiscellaneousChecker", "expected these __future__ imports: {0}; but got none" 544 "MiscellaneousChecker",
545 "expected these __future__ imports: {0}; but got none",
489 ), 546 ),
490 ## Gettext 547 ## Gettext
491 "M711": QCoreApplication.translate( 548 "M711": QCoreApplication.translate(
492 "MiscellaneousChecker", "gettext import with alias _ found: {0}" 549 "MiscellaneousChecker",
550 "gettext import with alias _ found: {0}",
493 ), 551 ),
494 ##~ print() statements 552 ##~ print() statements
495 "M801": QCoreApplication.translate("MiscellaneousChecker", "print statement found"), 553 "M801": QCoreApplication.translate(
554 "MiscellaneousChecker",
555 "print statement found",
556 ),
496 ## one element tuple 557 ## one element tuple
497 "M811": QCoreApplication.translate( 558 "M811": QCoreApplication.translate(
498 "MiscellaneousChecker", "one element tuple found" 559 "MiscellaneousChecker",
560 "one element tuple found",
499 ), 561 ),
500 ## Mutable Defaults 562 ## Mutable Defaults
501 "M821": QCoreApplication.translate( 563 "M821": QCoreApplication.translate(
502 "MiscellaneousChecker", "mutable default argument of type {0}" 564 "MiscellaneousChecker",
565 "mutable default argument of type {0}",
503 ), 566 ),
504 "M822": QCoreApplication.translate( 567 "M822": QCoreApplication.translate(
505 "MiscellaneousChecker", "mutable default argument of type {0}" 568 "MiscellaneousChecker",
569 "mutable default argument of type {0}",
506 ), 570 ),
507 "M823": QCoreApplication.translate( 571 "M823": QCoreApplication.translate(
508 "MiscellaneousChecker", "mutable default argument of function call '{0}'" 572 "MiscellaneousChecker",
573 "mutable default argument of function call '{0}'",
509 ), 574 ),
510 ##~ return statements 575 ##~ return statements
511 "M831": QCoreApplication.translate( 576 "M831": QCoreApplication.translate(
512 "MiscellaneousChecker", 577 "MiscellaneousChecker",
513 "None should not be added at any return if function has no return" 578 "None should not be added at any return if function has no return"
534 "prefer implied line continuation inside parentheses, " 599 "prefer implied line continuation inside parentheses, "
535 "brackets and braces as opposed to a backslash", 600 "brackets and braces as opposed to a backslash",
536 ), 601 ),
537 ## commented code 602 ## commented code
538 "M891": QCoreApplication.translate( 603 "M891": QCoreApplication.translate(
539 "MiscellaneousChecker", "commented code lines should be removed" 604 "MiscellaneousChecker",
605 "commented code lines should be removed",
540 ), 606 ),
541 } 607 }
542 608
543 _miscellaneousMessagesSampleArgs = { 609 _miscellaneousMessagesSampleArgs = {
544 "M102": ["enc42"], 610 "M102": ["enc42"],
545 "M131": ["list"], 611 "M131": ["list"],
546 "M132": ["list"], 612 "M132": ["list"],
547 "M186": ["list"], 613 "M185": ["list", "set"],
548 "M187a": ["reversed", "sorted"], 614 "M186": ["list", "dict"],
549 "M187b": ["reversed", "sorted", "True"], 615 "M188": ["list"],
550 "M187c": ["list", "sorted"], 616 "M189a": ["tuple", "tuple"],
551 "M188": ["sorted", "list"], 617 "M189b": ["list", "tuple"],
552 "M189": ["sorted"], 618 "M190a": ["list", "list"],
553 "M191": ["list", "set"], 619 "M190b": ["tuple", "list"],
554 "M192": ["list", "tuple"], 620 "M193a": ["reversed", "sorted"],
555 "M193": ["tuple", "list"], 621 "M193b": ["reversed", "sorted", "True"],
622 "M193c": ["list", "sorted"],
623 "M194": ["list", "sorted"],
624 "M195": ["sorted"],
556 "M196": ["list"], 625 "M196": ["list"],
557 "M197": ["tuple", "tuple"], 626 "M197": ["list"],
558 "M198": ["list", "list"], 627 "M198": ["dict comprehension"],
628 "M199": ["any"],
559 "M201": ["bar", "foo"], 629 "M201": ["bar", "foo"],
560 "M210": [2], 630 "M210": [2],
561 "M211": [1], 631 "M211": [1],
562 "M212": [2], 632 "M212": [2],
563 "M213": ["foo", "bar"], 633 "M213": ["foo", "bar"],

eric ide

mercurial