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

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2020 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6
7 """
8 Module implementing message translations for the code style plugin messages
9 (miscellaneous part).
10 """
11
12 from PyQt6.QtCore import QCoreApplication
13
14 _miscellaneousMessages = {
15 "M101": QCoreApplication.translate(
16 "MiscellaneousChecker",
17 "coding magic comment not found"),
18 "M102": QCoreApplication.translate(
19 "MiscellaneousChecker",
20 "unknown encoding ({0}) found in coding magic comment"),
21 "M111": QCoreApplication.translate(
22 "MiscellaneousChecker",
23 "copyright notice not present"),
24 "M112": QCoreApplication.translate(
25 "MiscellaneousChecker",
26 "copyright notice contains invalid author"),
27 "M131": QCoreApplication.translate(
28 "MiscellaneousChecker",
29 '"{0}" is a Python builtin and is being shadowed; '
30 'consider renaming the variable'),
31 "M132": QCoreApplication.translate(
32 "MiscellaneousChecker",
33 '"{0}" is used as an argument and thus shadows a '
34 'Python builtin; consider renaming the argument'),
35 "M181": QCoreApplication.translate(
36 "MiscellaneousChecker",
37 'unnecessary generator - rewrite as a list comprehension'),
38 "M182": QCoreApplication.translate(
39 "MiscellaneousChecker",
40 'unnecessary generator - rewrite as a set comprehension'),
41 "M183": QCoreApplication.translate(
42 "MiscellaneousChecker",
43 'unnecessary generator - rewrite as a dict comprehension'),
44 "M184": QCoreApplication.translate(
45 "MiscellaneousChecker",
46 'unnecessary list comprehension - rewrite as a set comprehension'),
47 "M185": QCoreApplication.translate(
48 "MiscellaneousChecker",
49 'unnecessary list comprehension - rewrite as a dict comprehension'),
50 "M186": QCoreApplication.translate(
51 "MiscellaneousChecker",
52 'unnecessary {0} call - rewrite as a literal'),
53 "M187a": QCoreApplication.translate(
54 "MiscellaneousChecker",
55 'unnecessary {0} call around {1}()'
56 ' - toggle reverse argument to sorted()'),
57 "M187b": QCoreApplication.translate(
58 "MiscellaneousChecker",
59 'unnecessary {0} call around {1}() - use sorted(..., reverse={2})'),
60 "M187c": QCoreApplication.translate(
61 "MiscellaneousChecker",
62 'unnecessary {0} call around {1}()'),
63 "M188": QCoreApplication.translate(
64 "MiscellaneousChecker",
65 'unnecessary {0} call within {1}()'),
66 "M189": QCoreApplication.translate(
67 "MiscellaneousChecker",
68 'unnecessary subscript reversal of iterable within {0}()'),
69 "M191": QCoreApplication.translate(
70 "MiscellaneousChecker",
71 'unnecessary {0} literal - rewrite as a {1} literal'),
72 "M192": QCoreApplication.translate(
73 "MiscellaneousChecker",
74 'unnecessary {0} passed to tuple() - rewrite as a {1} literal'),
75 "M193": QCoreApplication.translate(
76 "MiscellaneousChecker",
77 'unnecessary {0} passed to list() - rewrite as a {1} literal'),
78 "M195": QCoreApplication.translate(
79 "MiscellaneousChecker",
80 'unnecessary list call - remove the outer call to list()'),
81 "M196": QCoreApplication.translate(
82 "MiscellaneousChecker",
83 'unnecessary {0} comprehension - rewrite using {0}()'),
84 "M197": QCoreApplication.translate(
85 "MiscellaneousChecker",
86 'unnecessary {0} passed to tuple() - remove the outer call to {1}()'),
87 "M198": QCoreApplication.translate(
88 "MiscellaneousChecker",
89 'unnecessary {0} passed to list() - remove the outer call to {1}()'),
90
91 "M201": QCoreApplication.translate(
92 "MiscellaneousChecker",
93 "sort keys - '{0}' should be before '{1}'"),
94
95 "M301": QCoreApplication.translate(
96 "MiscellaneousChecker",
97 "use of 'datetime.datetime()' without 'tzinfo' argument should be"
98 " avoided"),
99 "M302": QCoreApplication.translate(
100 "MiscellaneousChecker",
101 "use of 'datetime.datetime.today()' should be avoided.\n"
102 "Use 'datetime.datetime.now(tz=)' instead."),
103 "M303": QCoreApplication.translate(
104 "MiscellaneousChecker",
105 "use of 'datetime.datetime.utcnow()' should be avoided.\n"
106 "Use 'datetime.datetime.now(tz=)' instead."),
107 "M304": QCoreApplication.translate(
108 "MiscellaneousChecker",
109 "use of 'datetime.datetime.utcfromtimestamp()' should be avoided.\n"
110 "Use 'datetime.datetime.fromtimestamp(, tz=)' instead."),
111 "M305": QCoreApplication.translate(
112 "MiscellaneousChecker",
113 "use of 'datetime.datetime.now()' without 'tz' argument should be"
114 " avoided"),
115 "M306": QCoreApplication.translate(
116 "MiscellaneousChecker",
117 "use of 'datetime.datetime.fromtimestamp()' without 'tz' argument"
118 " should be avoided"),
119 "M307": QCoreApplication.translate(
120 "MiscellaneousChecker",
121 "use of 'datetime.datetime.strptime()' should be followed by"
122 " '.replace(tzinfo=)'"),
123 "M308": QCoreApplication.translate(
124 "MiscellaneousChecker",
125 "use of 'datetime.datetime.fromordinal()' should be avoided"),
126 "M311": QCoreApplication.translate(
127 "MiscellaneousChecker",
128 "use of 'datetime.date()' should be avoided.\n"
129 "Use 'datetime.datetime(, tzinfo=).date()' instead."),
130 "M312": QCoreApplication.translate(
131 "MiscellaneousChecker",
132 "use of 'datetime.date.today()' should be avoided.\n"
133 "Use 'datetime.datetime.now(tz=).date()' instead."),
134 "M313": QCoreApplication.translate(
135 "MiscellaneousChecker",
136 "use of 'datetime.date.fromtimestamp()' should be avoided.\n"
137 "Use 'datetime.datetime.fromtimestamp(tz=).date()' instead."),
138 "M314": QCoreApplication.translate(
139 "MiscellaneousChecker",
140 "use of 'datetime.date.fromordinal()' should be avoided"),
141 "M315": QCoreApplication.translate(
142 "MiscellaneousChecker",
143 "use of 'datetime.date.fromisoformat()' should be avoided"),
144 "M321": QCoreApplication.translate(
145 "MiscellaneousChecker",
146 "use of 'datetime.time()' without 'tzinfo' argument should be"
147 " avoided"),
148
149 "M401": QCoreApplication.translate(
150 "MiscellaneousChecker",
151 "'sys.version[:3]' referenced (Python 3.10), use 'sys.version_info'"),
152 "M402": QCoreApplication.translate(
153 "MiscellaneousChecker",
154 "'sys.version[2]' referenced (Python 3.10), use 'sys.version_info'"),
155 "M403": QCoreApplication.translate(
156 "MiscellaneousChecker",
157 "'sys.version' compared to string (Python 3.10), use"
158 " 'sys.version_info'"),
159 "M411": QCoreApplication.translate(
160 "MiscellaneousChecker",
161 "'sys.version_info[0] == 3' referenced (Python 4), use '>='"),
162 "M412": QCoreApplication.translate(
163 "MiscellaneousChecker",
164 "'six.PY3' referenced (Python 4), use 'not six.PY2'"),
165 "M413": QCoreApplication.translate(
166 "MiscellaneousChecker",
167 "'sys.version_info[1]' compared to integer (Python 4),"
168 " compare 'sys.version_info' to tuple"),
169 "M414": QCoreApplication.translate(
170 "MiscellaneousChecker",
171 "'sys.version_info.minor' compared to integer (Python 4),"
172 " compare 'sys.version_info' to tuple"),
173 "M421": QCoreApplication.translate(
174 "MiscellaneousChecker",
175 "'sys.version[0]' referenced (Python 10), use 'sys.version_info'"),
176 "M422": QCoreApplication.translate(
177 "MiscellaneousChecker",
178 "'sys.version' compared to string (Python 10),"
179 " use 'sys.version_info'"),
180 "M423": QCoreApplication.translate(
181 "MiscellaneousChecker",
182 "'sys.version[:1]' referenced (Python 10), use 'sys.version_info'"),
183
184 "M501": QCoreApplication.translate(
185 "MiscellaneousChecker",
186 "Python does not support the unary prefix increment"),
187 "M502": QCoreApplication.translate(
188 "MiscellaneousChecker",
189 "using .strip() with multi-character strings is misleading"),
190 "M503": QCoreApplication.translate(
191 "MiscellaneousChecker",
192 "do not call assert False since python -O removes these calls"),
193 "M504": QCoreApplication.translate(
194 "MiscellaneousChecker",
195 "'sys.maxint' is not defined in Python 3 - use 'sys.maxsize'"),
196 "M505": QCoreApplication.translate(
197 "MiscellaneousChecker",
198 "'BaseException.message' has been deprecated as of Python 2.6 and is"
199 " removed in Python 3 - use 'str(e)'"),
200 "M506": QCoreApplication.translate(
201 "MiscellaneousChecker",
202 "assigning to 'os.environ' does not clear the environment -"
203 " use 'os.environ.clear()'"),
204 "M507": QCoreApplication.translate(
205 "MiscellaneousChecker",
206 "loop control variable {0} not used within the loop body -"
207 " start the name with an underscore"),
208 "M508": QCoreApplication.translate(
209 "MiscellaneousChecker",
210 "unncessary f-string"),
211 "M509": QCoreApplication.translate(
212 "MiscellaneousChecker",
213 "cannot use 'self.__class__' as first argument of 'super()' call"),
214 "M511": QCoreApplication.translate(
215 "MiscellaneousChecker",
216 """using 'hasattr(x, "__call__")' to test if 'x' is callable is"""
217 """ unreliable"""),
218 "M512": QCoreApplication.translate(
219 "MiscellaneousChecker",
220 "do not call getattr with a constant attribute value"),
221 "M513": QCoreApplication.translate(
222 "MiscellaneousChecker",
223 "do not call setattr with a constant attribute value"),
224 "M521": QCoreApplication.translate(
225 "MiscellaneousChecker",
226 "Python 3 does not include '.iter*' methods on dictionaries"),
227 "M522": QCoreApplication.translate(
228 "MiscellaneousChecker",
229 "Python 3 does not include '.view*' methods on dictionaries"),
230 "M523": QCoreApplication.translate(
231 "MiscellaneousChecker",
232 "'.next()' does not exist in Python 3"),
233 "M524": QCoreApplication.translate(
234 "MiscellaneousChecker",
235 "'__metaclass__' does nothing on Python 3 -"
236 " use 'class MyClass(BaseClass, metaclass=...)'"),
237
238 "M601": QCoreApplication.translate(
239 "MiscellaneousChecker",
240 "found {0} formatter"),
241 "M611": QCoreApplication.translate(
242 "MiscellaneousChecker",
243 "format string does contain unindexed parameters"),
244 "M612": QCoreApplication.translate(
245 "MiscellaneousChecker",
246 "docstring does contain unindexed parameters"),
247 "M613": QCoreApplication.translate(
248 "MiscellaneousChecker",
249 "other string does contain unindexed parameters"),
250 "M621": QCoreApplication.translate(
251 "MiscellaneousChecker",
252 "format call uses too large index ({0})"),
253 "M622": QCoreApplication.translate(
254 "MiscellaneousChecker",
255 "format call uses missing keyword ({0})"),
256 "M623": QCoreApplication.translate(
257 "MiscellaneousChecker",
258 "format call uses keyword arguments but no named entries"),
259 "M624": QCoreApplication.translate(
260 "MiscellaneousChecker",
261 "format call uses variable arguments but no numbered entries"),
262 "M625": QCoreApplication.translate(
263 "MiscellaneousChecker",
264 "format call uses implicit and explicit indexes together"),
265 "M631": QCoreApplication.translate(
266 "MiscellaneousChecker",
267 "format call provides unused index ({0})"),
268 "M632": QCoreApplication.translate(
269 "MiscellaneousChecker",
270 "format call provides unused keyword ({0})"),
271 "M651": QCoreApplication.translate(
272 "MiscellaneousChecker",
273 "logging statement uses string.format()"),
274 "M652": QCoreApplication.translate(
275 "MiscellaneousChecker",
276 "logging statement uses '%'"), # __IGNORE_WARNING_M601__
277 "M653": QCoreApplication.translate(
278 "MiscellaneousChecker",
279 "logging statement uses '+'"),
280 "M654": QCoreApplication.translate(
281 "MiscellaneousChecker",
282 "logging statement uses f-string"),
283 "M655": QCoreApplication.translate(
284 "MiscellaneousChecker",
285 "logging statement uses 'warn' instead of 'warning'"),
286
287 "M701": QCoreApplication.translate(
288 "MiscellaneousChecker",
289 "expected these __future__ imports: {0}; but only got: {1}"),
290 "M702": QCoreApplication.translate(
291 "MiscellaneousChecker",
292 "expected these __future__ imports: {0}; but got none"),
293 "M711": QCoreApplication.translate(
294 "MiscellaneousChecker",
295 "gettext import with alias _ found: {0}"),
296
297 "M801": QCoreApplication.translate(
298 "MiscellaneousChecker",
299 "print statement found"),
300 "M811": QCoreApplication.translate(
301 "MiscellaneousChecker",
302 "one element tuple found"),
303 "M821": QCoreApplication.translate(
304 "MiscellaneousChecker",
305 "mutable default argument of type {0}"),
306 "M822": QCoreApplication.translate(
307 "MiscellaneousChecker",
308 "mutable default argument of type {0}"),
309 "M823": QCoreApplication.translate(
310 "MiscellaneousChecker",
311 "mutable default argument of function call '{0}'"),
312 "M831": QCoreApplication.translate(
313 "MiscellaneousChecker",
314 "None should not be added at any return if function has no return"
315 " value except None"),
316 "M832": QCoreApplication.translate(
317 "MiscellaneousChecker",
318 "an explicit value at every return should be added if function has"
319 " a return value except None"),
320 "M833": QCoreApplication.translate(
321 "MiscellaneousChecker",
322 "an explicit return at the end of the function should be added if"
323 " it has a return value except None"),
324 "M834": QCoreApplication.translate(
325 "MiscellaneousChecker",
326 "a value should not be assigned to a variable if it will be used as a"
327 " return value only"),
328 "M841": QCoreApplication.translate(
329 "MiscellaneousChecker",
330 "prefer implied line continuation inside parentheses, "
331 "brackets and braces as opposed to a backslash"),
332 "M891": QCoreApplication.translate(
333 "MiscellaneousChecker",
334 "commented code lines should be removed"),
335 }
336
337 _miscellaneousMessagesSampleArgs = {
338 "M102": ["enc42"],
339 "M131": ["list"],
340 "M132": ["list"],
341 "M186": ["list"],
342 "M187a": ["reversed", "sorted"],
343 "M187b": ["reversed", "sorted", "True"],
344 "M187c": ["list", "sorted"],
345 "M188": ["sorted", "list"],
346 "M189": ["sorted"],
347 "M191": ["list", "set"],
348 "M192": ["list", "tuple"],
349 "M193": ["tuple", "list"],
350 "M196": ["list"],
351 "M197": ["tuple", "tuple"],
352 "M198": ["list", "list"],
353 "M201": ["bar", "foo"],
354 "M507": ["x"],
355 "M601": ["%s"],
356 "M621": [5],
357 "M622": ["foo"],
358 "M631": [5],
359 "M632": ["foo"],
360 "M701": ["print_function, unicode_literals", "print_function"],
361 "M702": ["print_function, unicode_literals"],
362 "M711": ["lgettext"],
363 "M821": ["Dict"],
364 "M822": ["Call"],
365 "M823": ["dict"],
366 }

eric ide

mercurial