]>
crepu.dev Git - config.git/blob - djavu-asus/emacs/elpy/rpc-venv/lib/python3.11/site-packages/pyflakes/messages.py
86cf6c78ec5b0776a3361e8a642e8c3b5937737a
2 Provide the class Message and its subclasses.
10 def __init__(self
, filename
, loc
):
11 self
.filename
= filename
12 self
.lineno
= loc
.lineno
13 self
.col
= loc
.col_offset
16 return '{}:{}:{}: {}'.format(self
.filename
, self
.lineno
, self
.col
+1,
17 self
.message
% self
.message_args
)
20 class UnusedImport(Message
):
21 message
= '%r imported but unused'
23 def __init__(self
, filename
, loc
, name
):
24 Message
.__init
__(self
, filename
, loc
)
25 self
.message_args
= (name
,)
28 class RedefinedWhileUnused(Message
):
29 message
= 'redefinition of unused %r from line %r'
31 def __init__(self
, filename
, loc
, name
, orig_loc
):
32 Message
.__init
__(self
, filename
, loc
)
33 self
.message_args
= (name
, orig_loc
.lineno
)
36 class ImportShadowedByLoopVar(Message
):
37 message
= 'import %r from line %r shadowed by loop variable'
39 def __init__(self
, filename
, loc
, name
, orig_loc
):
40 Message
.__init
__(self
, filename
, loc
)
41 self
.message_args
= (name
, orig_loc
.lineno
)
44 class ImportStarNotPermitted(Message
):
45 message
= "'from %s import *' only allowed at module level"
47 def __init__(self
, filename
, loc
, modname
):
48 Message
.__init
__(self
, filename
, loc
)
49 self
.message_args
= (modname
,)
52 class ImportStarUsed(Message
):
53 message
= "'from %s import *' used; unable to detect undefined names"
55 def __init__(self
, filename
, loc
, modname
):
56 Message
.__init
__(self
, filename
, loc
)
57 self
.message_args
= (modname
,)
60 class ImportStarUsage(Message
):
61 message
= "%r may be undefined, or defined from star imports: %s"
63 def __init__(self
, filename
, loc
, name
, from_list
):
64 Message
.__init
__(self
, filename
, loc
)
65 self
.message_args
= (name
, from_list
)
68 class UndefinedName(Message
):
69 message
= 'undefined name %r'
71 def __init__(self
, filename
, loc
, name
):
72 Message
.__init
__(self
, filename
, loc
)
73 self
.message_args
= (name
,)
76 class DoctestSyntaxError(Message
):
77 message
= 'syntax error in doctest'
79 def __init__(self
, filename
, loc
, position
=None):
80 Message
.__init
__(self
, filename
, loc
)
82 (self
.lineno
, self
.col
) = position
83 self
.message_args
= ()
86 class UndefinedExport(Message
):
87 message
= 'undefined name %r in __all__'
89 def __init__(self
, filename
, loc
, name
):
90 Message
.__init
__(self
, filename
, loc
)
91 self
.message_args
= (name
,)
94 class UndefinedLocal(Message
):
95 message
= 'local variable %r {0} referenced before assignment'
97 default
= 'defined in enclosing scope on line %r'
98 builtin
= 'defined as a builtin'
100 def __init__(self
, filename
, loc
, name
, orig_loc
):
101 Message
.__init
__(self
, filename
, loc
)
103 self
.message
= self
.message
.format(self
.builtin
)
104 self
.message_args
= name
106 self
.message
= self
.message
.format(self
.default
)
107 self
.message_args
= (name
, orig_loc
.lineno
)
110 class DuplicateArgument(Message
):
111 message
= 'duplicate argument %r in function definition'
113 def __init__(self
, filename
, loc
, name
):
114 Message
.__init
__(self
, filename
, loc
)
115 self
.message_args
= (name
,)
118 class MultiValueRepeatedKeyLiteral(Message
):
119 message
= 'dictionary key %r repeated with different values'
121 def __init__(self
, filename
, loc
, key
):
122 Message
.__init
__(self
, filename
, loc
)
123 self
.message_args
= (key
,)
126 class MultiValueRepeatedKeyVariable(Message
):
127 message
= 'dictionary key variable %s repeated with different values'
129 def __init__(self
, filename
, loc
, key
):
130 Message
.__init
__(self
, filename
, loc
)
131 self
.message_args
= (key
,)
134 class LateFutureImport(Message
):
135 message
= 'from __future__ imports must occur at the beginning of the file'
138 class FutureFeatureNotDefined(Message
):
139 """An undefined __future__ feature name was imported."""
140 message
= 'future feature %s is not defined'
142 def __init__(self
, filename
, loc
, name
):
143 Message
.__init
__(self
, filename
, loc
)
144 self
.message_args
= (name
,)
147 class UnusedVariable(Message
):
149 Indicates that a variable has been explicitly assigned to but not actually
152 message
= 'local variable %r is assigned to but never used'
154 def __init__(self
, filename
, loc
, names
):
155 Message
.__init
__(self
, filename
, loc
)
156 self
.message_args
= (names
,)
159 class UnusedAnnotation(Message
):
161 Indicates that a variable has been explicitly annotated to but not actually
164 message
= 'local variable %r is annotated but never used'
166 def __init__(self
, filename
, loc
, names
):
167 Message
.__init
__(self
, filename
, loc
)
168 self
.message_args
= (names
,)
171 class ReturnOutsideFunction(Message
):
173 Indicates a return statement outside of a function/method.
175 message
= '\'return\' outside function'
178 class YieldOutsideFunction(Message
):
180 Indicates a yield or yield from statement outside of a function/method.
182 message
= '\'yield\' outside function'
185 # For whatever reason, Python gives different error messages for these two. We
186 # match the Python error message exactly.
187 class ContinueOutsideLoop(Message
):
189 Indicates a continue statement outside of a while or for loop.
191 message
= '\'continue\' not properly in loop'
194 class BreakOutsideLoop(Message
):
196 Indicates a break statement outside of a while or for loop.
198 message
= '\'break\' outside loop'
201 class DefaultExceptNotLast(Message
):
203 Indicates an except: block as not the last exception handler.
205 message
= 'default \'except:\' must be last'
208 class TwoStarredExpressions(Message
):
210 Two or more starred expressions in an assignment (a, *b, *c = d).
212 message
= 'two starred expressions in assignment'
215 class TooManyExpressionsInStarredAssignment(Message
):
217 Too many expressions in an assignment with star-unpacking
219 message
= 'too many expressions in star-unpacking assignment'
222 class IfTuple(Message
):
224 Conditional test is a non-empty tuple literal, which are always True.
226 message
= '\'if tuple literal\' is always true, perhaps remove accidental comma?'
229 class AssertTuple(Message
):
231 Assertion test is a non-empty tuple literal, which are always True.
233 message
= 'assertion is always true, perhaps remove parentheses?'
236 class ForwardAnnotationSyntaxError(Message
):
237 message
= 'syntax error in forward annotation %r'
239 def __init__(self
, filename
, loc
, annotation
):
240 Message
.__init
__(self
, filename
, loc
)
241 self
.message_args
= (annotation
,)
244 class RaiseNotImplemented(Message
):
245 message
= "'raise NotImplemented' should be 'raise NotImplementedError'"
248 class InvalidPrintSyntax(Message
):
249 message
= 'use of >> is invalid with print function'
252 class IsLiteral(Message
):
253 message
= 'use ==/!= to compare constant literals (str, bytes, int, float, tuple)'
256 class FStringMissingPlaceholders(Message
):
257 message
= 'f-string is missing placeholders'
260 class StringDotFormatExtraPositionalArguments(Message
):
261 message
= "'...'.format(...) has unused arguments at position(s): %s"
263 def __init__(self
, filename
, loc
, extra_positions
):
264 Message
.__init
__(self
, filename
, loc
)
265 self
.message_args
= (extra_positions
,)
268 class StringDotFormatExtraNamedArguments(Message
):
269 message
= "'...'.format(...) has unused named argument(s): %s"
271 def __init__(self
, filename
, loc
, extra_keywords
):
272 Message
.__init
__(self
, filename
, loc
)
273 self
.message_args
= (extra_keywords
,)
276 class StringDotFormatMissingArgument(Message
):
277 message
= "'...'.format(...) is missing argument(s) for placeholder(s): %s"
279 def __init__(self
, filename
, loc
, missing_arguments
):
280 Message
.__init
__(self
, filename
, loc
)
281 self
.message_args
= (missing_arguments
,)
284 class StringDotFormatMixingAutomatic(Message
):
285 message
= "'...'.format(...) mixes automatic and manual numbering"
288 class StringDotFormatInvalidFormat(Message
):
289 message
= "'...'.format(...) has invalid format string: %s"
291 def __init__(self
, filename
, loc
, error
):
292 Message
.__init
__(self
, filename
, loc
)
293 self
.message_args
= (error
,)
296 class PercentFormatInvalidFormat(Message
):
297 message
= "'...' %% ... has invalid format string: %s"
299 def __init__(self
, filename
, loc
, error
):
300 Message
.__init
__(self
, filename
, loc
)
301 self
.message_args
= (error
,)
304 class PercentFormatMixedPositionalAndNamed(Message
):
305 message
= "'...' %% ... has mixed positional and named placeholders"
308 class PercentFormatUnsupportedFormatCharacter(Message
):
309 message
= "'...' %% ... has unsupported format character %r"
311 def __init__(self
, filename
, loc
, c
):
312 Message
.__init
__(self
, filename
, loc
)
313 self
.message_args
= (c
,)
316 class PercentFormatPositionalCountMismatch(Message
):
317 message
= "'...' %% ... has %d placeholder(s) but %d substitution(s)"
319 def __init__(self
, filename
, loc
, n_placeholders
, n_substitutions
):
320 Message
.__init
__(self
, filename
, loc
)
321 self
.message_args
= (n_placeholders
, n_substitutions
)
324 class PercentFormatExtraNamedArguments(Message
):
325 message
= "'...' %% ... has unused named argument(s): %s"
327 def __init__(self
, filename
, loc
, extra_keywords
):
328 Message
.__init
__(self
, filename
, loc
)
329 self
.message_args
= (extra_keywords
,)
332 class PercentFormatMissingArgument(Message
):
333 message
= "'...' %% ... is missing argument(s) for placeholder(s): %s"
335 def __init__(self
, filename
, loc
, missing_arguments
):
336 Message
.__init
__(self
, filename
, loc
)
337 self
.message_args
= (missing_arguments
,)
340 class PercentFormatExpectedMapping(Message
):
341 message
= "'...' %% ... expected mapping but got sequence"
344 class PercentFormatExpectedSequence(Message
):
345 message
= "'...' %% ... expected sequence but got mapping"
348 class PercentFormatStarRequiresSequence(Message
):
349 message
= "'...' %% ... `*` specifier requires sequence"