5 # Original (c) 2005 Divmod, Inc. See LICENSE file for details |
5 # Original (c) 2005 Divmod, Inc. See LICENSE file for details |
6 # |
6 # |
7 # This module is based on pyflakes for Python2 but was heavily hacked to |
7 # This module is based on pyflakes for Python2 but was heavily hacked to |
8 # work within Eric5 and Qt (translatable messages) |
8 # work within Eric5 and Qt (translatable messages) |
9 |
9 |
|
10 """ |
|
11 Module implementing the messages for py2flakes. |
|
12 """ |
|
13 |
10 |
14 |
11 def QT_TRANSLATE_NOOP(mod, txt): |
15 def QT_TRANSLATE_NOOP(mod, txt): |
12 """ |
16 """ |
13 Function to tell 'lupdate' which strings to keep for translation. |
17 Function to tell 'lupdate' which strings to keep for translation. |
14 |
18 |
57 |
61 |
58 class UnusedImport(Message): |
62 class UnusedImport(Message): |
59 """ |
63 """ |
60 Class defining the "Unused Import" message. |
64 Class defining the "Unused Import" message. |
61 """ |
65 """ |
62 message = QT_TRANSLATE_NOOP('py3Flakes', |
66 message = QT_TRANSLATE_NOOP( |
|
67 'py3Flakes', |
63 '{0!r} imported but unused.') |
68 '{0!r} imported but unused.') |
64 |
69 |
65 def __init__(self, filename, lineno, name): |
70 def __init__(self, filename, lineno, name): |
66 """ |
71 """ |
67 Constructor |
72 Constructor |
76 |
81 |
77 class RedefinedWhileUnused(Message): |
82 class RedefinedWhileUnused(Message): |
78 """ |
83 """ |
79 Class defining the "Redefined While Unused" message. |
84 Class defining the "Redefined While Unused" message. |
80 """ |
85 """ |
81 message = QT_TRANSLATE_NOOP('py3Flakes', |
86 message = QT_TRANSLATE_NOOP( |
|
87 'py3Flakes', |
82 'Redefinition of unused {0!r} from line {1!r}.') |
88 'Redefinition of unused {0!r} from line {1!r}.') |
83 |
89 |
84 def __init__(self, filename, lineno, name, orig_lineno): |
90 def __init__(self, filename, lineno, name, orig_lineno): |
85 """ |
91 """ |
86 Constructor |
92 Constructor |
93 Message.__init__(self, filename, lineno) |
99 Message.__init__(self, filename, lineno) |
94 self.message_args = (name, orig_lineno) |
100 self.message_args = (name, orig_lineno) |
95 |
101 |
96 |
102 |
97 class RedefinedInListComp(Message): |
103 class RedefinedInListComp(Message): |
98 message = QT_TRANSLATE_NOOP('py3Flakes', |
104 """ |
|
105 Class defining the list comprehension redefinition. |
|
106 """ |
|
107 message = QT_TRANSLATE_NOOP( |
|
108 'py3Flakes', |
99 'List comprehension redefines {0!r} from line {1!r}.') |
109 'List comprehension redefines {0!r} from line {1!r}.') |
100 |
110 |
101 def __init__(self, filename, lineno, name, orig_lineno): |
111 def __init__(self, filename, lineno, name, orig_lineno): |
102 """ |
112 """ |
103 Constructor |
113 Constructor |
113 |
123 |
114 class ImportShadowedByLoopVar(Message): |
124 class ImportShadowedByLoopVar(Message): |
115 """ |
125 """ |
116 Class defining the "Import Shadowed By Loop Var" message. |
126 Class defining the "Import Shadowed By Loop Var" message. |
117 """ |
127 """ |
118 message = QT_TRANSLATE_NOOP('py3Flakes', |
128 message = QT_TRANSLATE_NOOP( |
|
129 'py3Flakes', |
119 'Import {0!r} from line {1!r} shadowed by loop variable.') |
130 'Import {0!r} from line {1!r} shadowed by loop variable.') |
120 |
131 |
121 def __init__(self, filename, lineno, name, orig_lineno): |
132 def __init__(self, filename, lineno, name, orig_lineno): |
122 """ |
133 """ |
123 Constructor |
134 Constructor |
133 |
144 |
134 class ImportStarUsed(Message): |
145 class ImportStarUsed(Message): |
135 """ |
146 """ |
136 Class defining the "Import Star Used" message. |
147 Class defining the "Import Star Used" message. |
137 """ |
148 """ |
138 message = QT_TRANSLATE_NOOP('py3Flakes', |
149 message = QT_TRANSLATE_NOOP( |
|
150 'py3Flakes', |
139 "'from {0} import *' used; unable to detect undefined names.") |
151 "'from {0} import *' used; unable to detect undefined names.") |
140 |
152 |
141 def __init__(self, filename, lineno, modname): |
153 def __init__(self, filename, lineno, modname): |
142 """ |
154 """ |
143 Constructor |
155 Constructor |
170 |
182 |
171 class UndefinedExport(Message): |
183 class UndefinedExport(Message): |
172 """ |
184 """ |
173 Class defining the "Undefined Export" message. |
185 Class defining the "Undefined Export" message. |
174 """ |
186 """ |
175 message = QT_TRANSLATE_NOOP('py3Flakes', |
187 message = QT_TRANSLATE_NOOP( |
|
188 'py3Flakes', |
176 'Undefined name {0!r} in __all__.') |
189 'Undefined name {0!r} in __all__.') |
177 |
190 |
178 def __init__(self, filename, lineno, name): |
191 def __init__(self, filename, lineno, name): |
179 """ |
192 """ |
180 Constructor |
193 Constructor |
189 |
202 |
190 class UndefinedLocal(Message): |
203 class UndefinedLocal(Message): |
191 """ |
204 """ |
192 Class defining the "Undefined Local Variable" message. |
205 Class defining the "Undefined Local Variable" message. |
193 """ |
206 """ |
194 message = QT_TRANSLATE_NOOP('py3Flakes', |
207 message = QT_TRANSLATE_NOOP( |
195 "Local variable {0!r} (defined in enclosing scope on line {1!r})" \ |
208 'py3Flakes', |
196 " referenced before assignment.") |
209 "Local variable {0!r} (defined in enclosing scope on line {1!r})" |
|
210 " referenced before assignment.") |
197 |
211 |
198 def __init__(self, filename, lineno, name, orig_lineno): |
212 def __init__(self, filename, lineno, name, orig_lineno): |
199 """ |
213 """ |
200 Constructor |
214 Constructor |
201 |
215 |
210 |
224 |
211 class DuplicateArgument(Message): |
225 class DuplicateArgument(Message): |
212 """ |
226 """ |
213 Class defining the "Duplicate Argument" message. |
227 Class defining the "Duplicate Argument" message. |
214 """ |
228 """ |
215 message = QT_TRANSLATE_NOOP('py3Flakes', |
229 message = QT_TRANSLATE_NOOP( |
|
230 'py3Flakes', |
216 'Duplicate argument {0!r} in function definition.') |
231 'Duplicate argument {0!r} in function definition.') |
217 |
232 |
218 def __init__(self, filename, lineno, name): |
233 def __init__(self, filename, lineno, name): |
219 """ |
234 """ |
220 Constructor |
235 Constructor |
229 |
244 |
230 class Redefined(Message): |
245 class Redefined(Message): |
231 """ |
246 """ |
232 Class defining the "Redefined" message. |
247 Class defining the "Redefined" message. |
233 """ |
248 """ |
234 message = QT_TRANSLATE_NOOP('py3Flakes', |
249 message = QT_TRANSLATE_NOOP( |
|
250 'py3Flakes', |
235 'Redefinition of {0!r} from line {1!r}.') |
251 'Redefinition of {0!r} from line {1!r}.') |
236 |
252 |
237 def __init__(self, filename, lineno, name, orig_lineno): |
253 def __init__(self, filename, lineno, name, orig_lineno): |
238 """ |
254 """ |
239 Constructor |
255 Constructor |
249 |
265 |
250 class LateFutureImport(Message): |
266 class LateFutureImport(Message): |
251 """ |
267 """ |
252 Class defining the "Late Future Import" message. |
268 Class defining the "Late Future Import" message. |
253 """ |
269 """ |
254 message = QT_TRANSLATE_NOOP('py3Flakes', |
270 message = QT_TRANSLATE_NOOP( |
|
271 'py3Flakes', |
255 'Future import(s) {0!r} after other statements.') |
272 'Future import(s) {0!r} after other statements.') |
256 |
273 |
257 def __init__(self, filename, lineno, names): |
274 def __init__(self, filename, lineno, names): |
258 """ |
275 """ |
259 Constructor |
276 Constructor |
271 Class defining the "Unused Variable" message. |
288 Class defining the "Unused Variable" message. |
272 |
289 |
273 Indicates that a variable has been explicitly assigned to but not actually |
290 Indicates that a variable has been explicitly assigned to but not actually |
274 used. |
291 used. |
275 """ |
292 """ |
276 message = QT_TRANSLATE_NOOP('py3Flakes', |
293 message = QT_TRANSLATE_NOOP( |
|
294 'py3Flakes', |
277 'Local variable {0!r} is assigned to but never used.') |
295 'Local variable {0!r} is assigned to but never used.') |
278 |
296 |
279 def __init__(self, filename, lineno, names): |
297 def __init__(self, filename, lineno, names): |
280 """ |
298 """ |
281 Constructor |
299 Constructor |
282 |
300 |
283 @param filename name of the file (string) |
301 @param filename name of the file (string) |
284 @param lineno line number (integer) |
302 @param lineno line number (integer) |
285 @param name name of the unused variable (string) |
303 @param names names of the unused variable (string) |
286 """ |
304 """ |
287 Message.__init__(self, filename, lineno) |
305 Message.__init__(self, filename, lineno) |
288 self.message_args = (names,) |
306 self.message_args = (names,) |
289 |
307 |
290 # |
308 # |