Plugins/CheckerPlugins/SyntaxChecker/pyflakes/messages.py

changeset 3544
431c842fd09a
parent 3484
645c12de6b0c
child 3670
f0cb7579c0b4
equal deleted inserted replaced
3542:07cde1e38b06 3544:431c842fd09a
6 # 6 #
7 # This module is based on pyflakes for Python2 and Python3, but was modified to 7 # This module is based on pyflakes for Python2 and Python3, but was modified to
8 # be integrated into eric5 8 # be integrated into eric5
9 9
10 """ 10 """
11 Module implementing the messages for pyflakes. 11 Module providing the class Message and its subclasses.
12 """ 12 """
13 13
14 14
15 class Message(object): 15 class Message(object):
16 """ 16 """
17 Class defining the base for all specific message classes. 17 Class defining the base for all specific message classes.
18 """ 18 """
19 message_id = 'F00' 19 message_id = 'F00'
20 message = '' 20 message = ''
21 message_args = () 21 message_args = ()
22 22
23 def __init__(self, filename, loc): 23 def __init__(self, filename, loc):
24 """ 24 """
25 Constructor 25 Constructor
26 26
27 @param filename name of the file (string) 27 @param filename name of the file (string)
28 @param loc location of the issue 28 @param loc location of the issue
29 """ 29 """
30 self.filename = filename 30 self.filename = filename
31 self.lineno = loc.lineno 31 self.lineno = loc.lineno
32 self.col = getattr(loc, 'col_offset', 0) 32 self.col = getattr(loc, 'col_offset', 0)
33 33
34 def __str__(self): 34 def __str__(self):
35 """ 35 """
36 Special method return a string representation of the instance object. 36 Special method return a string representation of the instance object.
37 37
38 @return string representation of the object (string) 38 @return string representation of the object (string)
55 """ 55 """
56 Class defining the "Unused Import" message. 56 Class defining the "Unused Import" message.
57 """ 57 """
58 message_id = 'F01' 58 message_id = 'F01'
59 message = '%r imported but unused' 59 message = '%r imported but unused'
60 60
61 def __init__(self, filename, loc, name): 61 def __init__(self, filename, loc, name):
62 """ 62 """
63 Constructor 63 Constructor
64 64
65 @param filename name of the file (string) 65 @param filename name of the file (string)
74 """ 74 """
75 Class defining the "Redefined While Unused" message. 75 Class defining the "Redefined While Unused" message.
76 """ 76 """
77 message_id = 'F02' 77 message_id = 'F02'
78 message = 'redefinition of unused %r from line %r' 78 message = 'redefinition of unused %r from line %r'
79 79
80 def __init__(self, filename, loc, name, orig_loc): 80 def __init__(self, filename, loc, name, orig_loc):
81 """ 81 """
82 Constructor 82 Constructor
83 83
84 @param filename name of the file (string) 84 @param filename name of the file (string)
114 """ 114 """
115 Class defining the "Import Shadowed By Loop Var" message. 115 Class defining the "Import Shadowed By Loop Var" message.
116 """ 116 """
117 message_id = 'F03' 117 message_id = 'F03'
118 message = 'import %r from line %r shadowed by loop variable' 118 message = 'import %r from line %r shadowed by loop variable'
119 119
120 def __init__(self, filename, loc, name, orig_loc): 120 def __init__(self, filename, loc, name, orig_loc):
121 """ 121 """
122 Constructor 122 Constructor
123 123
124 @param filename name of the file (string) 124 @param filename name of the file (string)
134 """ 134 """
135 Class defining the "Import Star Used" message. 135 Class defining the "Import Star Used" message.
136 """ 136 """
137 message_id = 'F04' 137 message_id = 'F04'
138 message = "'from %s import *' used; unable to detect undefined names" 138 message = "'from %s import *' used; unable to detect undefined names"
139 139
140 def __init__(self, filename, loc, modname): 140 def __init__(self, filename, loc, modname):
141 """ 141 """
142 Constructor 142 Constructor
143 143
144 @param filename name of the file (string) 144 @param filename name of the file (string)
153 """ 153 """
154 Class defining the "Undefined Name" message. 154 Class defining the "Undefined Name" message.
155 """ 155 """
156 message_id = 'F05' 156 message_id = 'F05'
157 message = 'undefined name %r' 157 message = 'undefined name %r'
158 158
159 def __init__(self, filename, loc, name): 159 def __init__(self, filename, loc, name):
160 """ 160 """
161 Constructor 161 Constructor
162 162
163 @param filename name of the file (string) 163 @param filename name of the file (string)
193 """ 193 """
194 Class defining the "Undefined Export" message. 194 Class defining the "Undefined Export" message.
195 """ 195 """
196 message_id = 'F06' 196 message_id = 'F06'
197 message = 'undefined name %r in __all__' 197 message = 'undefined name %r in __all__'
198 198
199 def __init__(self, filename, loc, name): 199 def __init__(self, filename, loc, name):
200 """ 200 """
201 Constructor 201 Constructor
202 202
203 @param filename name of the file (string) 203 @param filename name of the file (string)
211 class UndefinedLocal(Message): 211 class UndefinedLocal(Message):
212 """ 212 """
213 Class defining the "Undefined Local Variable" message. 213 Class defining the "Undefined Local Variable" message.
214 """ 214 """
215 message_id = 'F07' 215 message_id = 'F07'
216 message = "local variable %r (defined in enclosing scope on line %r)" \ 216 message = ('local variable %r (defined in enclosing scope on line %r) '
217 " referenced before assignment" 217 'referenced before assignment')
218 218
219 def __init__(self, filename, loc, name, orig_loc): 219 def __init__(self, filename, loc, name, orig_loc):
220 """ 220 """
221 Constructor 221 Constructor
222 222
223 @param filename name of the file (string) 223 @param filename name of the file (string)
233 """ 233 """
234 Class defining the "Duplicate Argument" message. 234 Class defining the "Duplicate Argument" message.
235 """ 235 """
236 message_id = 'F08' 236 message_id = 'F08'
237 message = 'duplicate argument %r in function definition' 237 message = 'duplicate argument %r in function definition'
238 238
239 def __init__(self, filename, loc, name): 239 def __init__(self, filename, loc, name):
240 """ 240 """
241 Constructor 241 Constructor
242 242
243 @param filename name of the file (string) 243 @param filename name of the file (string)
252 """ 252 """
253 Class defining the "Redefined" message. 253 Class defining the "Redefined" message.
254 """ 254 """
255 message_id = 'F09' 255 message_id = 'F09'
256 message = 'redefinition of %r from line %r' 256 message = 'redefinition of %r from line %r'
257 257
258 def __init__(self, filename, loc, name, orig_loc): 258 def __init__(self, filename, loc, name, orig_loc):
259 """ 259 """
260 Constructor 260 Constructor
261 261
262 @param filename name of the file (string) 262 @param filename name of the file (string)
272 """ 272 """
273 Class defining the "Late Future Import" message. 273 Class defining the "Late Future Import" message.
274 """ 274 """
275 message_id = 'F10' 275 message_id = 'F10'
276 message = 'future import(s) %r after other statements' 276 message = 'future import(s) %r after other statements'
277 277
278 def __init__(self, filename, loc, names): 278 def __init__(self, filename, loc, names):
279 """ 279 """
280 Constructor 280 Constructor
281 281
282 @param filename name of the file (string) 282 @param filename name of the file (string)
294 Indicates that a variable has been explicitly assigned to but not actually 294 Indicates that a variable has been explicitly assigned to but not actually
295 used. 295 used.
296 """ 296 """
297 message_id = 'F11' 297 message_id = 'F11'
298 message = 'local variable %r is assigned to but never used' 298 message = 'local variable %r is assigned to but never used'
299
300 def __init__(self, filename, loc, names):
301 """
302 Constructor
303
304 @param filename name of the file (string)
305 @param loc location of the issue
306 @param names names of unused variable (string)
307 """
308 Message.__init__(self, filename, loc)
309 self.message_args = (names,)
310
311
312 class ReturnWithArgsInsideGenerator(Message):
313 """
314 Class defining the "Return values in generator" message.
299 315
300 def __init__(self, filename, loc, names): 316 Indicates a return statement with arguments inside a generator.
301 """ 317 """
302 Constructor 318 message_id = 'F14'
303 319 message = '\'return\' with argument inside generator'
304 @param filename name of the file (string)
305 @param loc location of the issue
306 @param names names of unused variable (string)
307 """
308 Message.__init__(self, filename, loc)
309 self.message_args = (names,)

eric ide

mercurial