Debian Codegraph @

tests/syntax_errors_descriptions.py

raw symbols SCIP
1 """In this file, descriptions is a dict whose keys are the names of
2 Python files that raise a SyntaxError (or subclass) when they are imported.
3 This is done from the file
4 /tests/syntax/catch_syntax_error.py
5
6 Here is the meaning of the various dict keys:
7
8 title/"title" is the heading that should appear in the documentation for
9 this particular case.
10
11 version_dependent/"version dependent" indicates that an exception will be raised but
12 that the explanation provided by Friendly-traceback
13 might vary depending on the Python version used.
14 The value corresponding to this key is a list of text fragments,
15 at least one of which should appear in the explanation given by Friendly-traceback.
16
17 In this case, in_cause/"in cause" (mentioned below) is usually set to "ignored"
18 as catch_syntax_error.py needs a value for all cases.
19
20 Note that, in some cases, a SyntaxError will not be raised by a given Python version.
21 In this case, we delete the entry at the very bottom of this file.
22
23 When the basic explanation is the same (or similar enough) for all Python versions,
24 which is generally the case, the following is used instead:
25
26 in_cause/"in cause" is some text that should be found in the explanation provided by
27 Friendly-traceback when importing this file.
28
29 also_in_cause/"also in cause" is a list of text fragments that should
30 also be found in the explanation. Note that this can sometimes be version dependent
31 in which case a change is made at the end of the file.
32
33 not_in_cause/"not in cause" is a list of text fragments that should
34 not be found in the explanation.
35 """
36 import sys
37
38 title = "title"
39 version_dependent = "version dependent"
40 in_cause = "in cause"
41 also_in_cause = "also in cause"
42 not_in_cause = "not in cause"
43
44 no_slash = "Function definitions cannot include the symbol `/` in this Python version"
45
46 descriptions = {
47 "and_in_import_statement": {
48 in_cause: "only be used for boolean expressions",
49 title: "Using 'and' in import statement",
50 },
51 "and_in_import_statement_2": {
52 in_cause: "only be used for boolean expressions",
53 title: "Using 'and' after comma in import statement",
54 },
55 "annotated_name_global": {
56 in_cause: "It cannot be declared to be a global variable.",
57 title: "Annotated name cannot be global",
58 },
59 "as_instead_of_comma_in_import": {
60 in_cause: "and rename it using the Python keyword `as`",
61 title: "Incorrect use of 'from module import ... as ...",
62 },
63 "assign_instead_of_equal": {
64 in_cause: "Perhaps you needed `==`",
65 "version_dependent": ["`:=` instead of `=`.", "instead of `=`."],
66 title: "Assign instead of equal (or walrus).",
67 },
68 "assign_name_before_global_1": {
69 in_cause: "before declaring it as a global variable.",
70 title: "Name assigned prior to global declaration",
71 },
72 "assign_name_before_global_2": {
73 in_cause: "You used the variable `var`",
74 title: "Name used prior to global declaration",
75 },
76 "assign_name_before_nonlocal_1": {
77 in_cause: "before declaring it as a nonlocal variable.",
78 title: "Name used prior to nonlocal declaration",
79 },
80 "assign_name_before_nonlocal_2": {
81 in_cause: "You assigned a value to the variable `s`",
82 title: "Name assigned prior to nonlocal declaration",
83 },
84 "assign_to_conditional": {
85 in_cause: "conditional expression instead of the name of a variable",
86 title: "Assign to conditional expression",
87 },
88 "assign_to_debug": {
89 in_cause: "`__debug__` is a constant in Python",
90 title: "Assignment to keyword (__debug__)",
91 },
92 "assign_to_debug2": {
93 in_cause: "`__debug__` is a constant in Python",
94 title: "Assignment to keyword (__debug__)",
95 },
96 "assign_to_ellipsis": {
97 in_cause: "The ellipsis symbol `...` is a constant in Python",
98 title: "Assignment to Ellipsis symbol",
99 },
100 "assign_to_f_string": {
101 in_cause: "expression that has the f-string",
102 title: "Cannot assign to f-string",
103 },
104 "assign_to_function_call_1": {
105 in_cause: "function call and is not simply the name of a variable",
106 title: "Cannot assign to function call: single = sign",
107 also_in_cause: ["len('a')"],
108 },
109 "assign_to_function_call_2": {
110 in_cause: "function call and is not simply the name of a variable",
111 title: "Cannot assign to function call: two = signs",
112 also_in_cause: ["^^^^^^^^^^^^"],
113 },
114 "assign_to_function_call_3": {
115 in_cause: "function call and is not simply the name of a variable",
116 title: "Cannot assign to function call: continues on second line",
117 also_in_cause: ["^^^^^^^-->"],
118 },
119 "assign_to_generator": {
120 in_cause: "generator expression instead of the name of a variable",
121 title: "Assign to generator expression",
122 },
123 "assign_to_literal_dict": {
124 in_cause: "is or includes an actual object of type `dict`",
125 title: "Cannot assign to literal - 4",
126 },
127 "assign_to_literal_int": {
128 in_cause: "is or includes an actual object of type `int`",
129 title: "Cannot assign to literal int",
130 also_in_cause: ["Perhaps you meant to write"],
131 },
132 "assign_to_literal_int_2": {
133 in_cause: "is or includes an actual object of type `int`",
134 title: "Cannot assign to literal int - 2",
135 },
136 "assign_to_literal_int_3": {
137 in_cause: "is or includes an actual object",
138 title: "Cannot assign to literal - 5",
139 },
140 "assign_to_literal_set": {
141 in_cause: "is or includes an actual object of type `set`",
142 title: "Cannot assign to literal - 3",
143 },
144 "assign_to_keyword_def": { # = sign is flagged
145 in_cause: "assign a value to the Python keyword `def`",
146 title: "Assign to keyword def",
147 },
148 "assign_to_keyword_else": { # else is flagged
149 in_cause: "assign a value to the Python keyword `else`",
150 title: "Assign to keyword else",
151 },
152 "assign_to_keyword_none": {
153 in_cause: "`None` is a constant in Python",
154 title: "Assignment to keyword (None)",
155 },
156 "assign_to_operation": {
157 in_cause: "only used to assign a value to a variable",
158 title: "Assign to math operation",
159 },
160 "assign_to_yield_expression": {
161 in_cause: "You wrote an expression that includes the `yield` keyword",
162 title: "Assign to yield expression",
163 also_in_cause: ["You cannot assign a value to such an expression."],
164 },
165 "assignment_expression_cannot_rebind": {
166 version_dependent: [
167 "The augmented assignment operator is not allowed",
168 "a comprehension to assign a value to the iteration variable",
169 ],
170 in_cause: "ignored",
171 title: "Augmented assignment inside comprehension",
172 },
173 "assignment_expression_cannot_rebind_2": {
174 version_dependent: [
175 "The augmented assignment operator is not allowed",
176 "a comprehension to assign a value to the iteration variable",
177 ],
178 in_cause: "ignored",
179 title: "Augmented assignment inside comprehension - inner loop",
180 },
181 "async_def_missing_parens": {
182 in_cause: "Did you forget parentheses?",
183 title: "def: missing parentheses",
184 },
185 "augmented_assignment_to_literal": {
186 version_dependent: [
187 "walrus operator",
188 "the walrus operator, with literals like",
189 ],
190 in_cause: "ignored",
191 title: "Augmented assignment to literal",
192 },
193 "augmented_assigment_with_true": {
194 version_dependent: ["walrus operator", "`True` is a constant in Python"],
195 in_cause: "ignored",
196 title: "Walrus/Named assignment depending on Python version",
197 },
198 "backslash_instead_of_slash": {
199 in_cause: "Did you mean to divide",
200 title: "Backslash instead of slash",
201 },
202 "bracket_instead_of_paren": {
203 in_cause: "You used square brackets, `[...]` instead of parentheses.",
204 title: "Brackets instead of parentheses",
205 },
206 "break_outside_loop": {
207 in_cause: "The Python keyword `break` can only be used",
208 title: "break outside loop",
209 },
210 "cannot_assign_to_attribute_here" : {
211 in_cause: "You likely used an assignment operator `=` instead of an equality operator `==`",
212 title: "Cannot assign to attribute here.",
213 },
214 "cannot_guess_the_cause": {
215 in_cause: "Currently, I cannot guess the likely cause of this error.",
216 title: "Cannot guess the cause",
217 },
218 "cannot_use_star": {
219 in_cause: "The star operator",
220 title: "Cannot use star operator",
221 },
222 "cannot_use_double_star": {
223 in_cause: "The double star operator",
224 title: "Cannot use double star operator",
225 },
226 "class_missing_name": {
227 in_cause: "A class needs a name.",
228 title: "Missing class name",
229 },
230 "comprehension_missing_tuple_paren": {
231 in_cause: "and forgot to include parentheses around tuples",
232 title: "Missing () for tuples in comprehension",
233 },
234 "comprehension_with_condition_no_else": {
235 version_dependent: [
236 "`else some_value` clause was expected after the `if` expression",
237 "The correct order depends if there is an `else` clause or not",
238 ],
239 in_cause: "ignored",
240 title: "Comprehension with condition (no else)",
241 },
242 "comprehension_with_condition_with_else": {
243 in_cause: "The correct order depends if there is an `else` clause or not",
244 title: "Comprehension with condition (with else)",
245 },
246 "continue_outside_loop": {
247 in_cause: "The Python keyword `continue` can only be used",
248 title: "continue outside loop",
249 },
250 "copy_pasted_code": {
251 in_cause: "copy-pasted code from an interactive interpreter",
252 title: "Copy/paste from interpreter",
253 also_in_cause: ["`>>>`"],
254 },
255 "copy_pasted_code_2": {
256 in_cause: "copy-pasted code from an interactive interpreter",
257 title: "Copy/paste from interpreter - 2",
258 also_in_cause: ["`...`"],
259 },
260 "debug_fstring_not_supported": { # not allowed prior to Python 3.8
261 in_cause: "You are likely using a 'debug' syntax of f-strings",
262 title: "Debug-feature of f-string not supported",
263 },
264 "def_arg_after_kwarg": {
265 in_cause: "Positional arguments must come before keyword argument",
266 title: "def: positional arg after kwargs",
267 },
268 "def_bare_star_arg": {
269 in_cause: "replace `*` by either `*arguments` or ",
270 title: "def: named arguments must follow bare *",
271 },
272 "def_code_block": {
273 in_cause: "tried to define a function and did not",
274 title: "def: misused as code block",
275 },
276 "def_code_block_2": {
277 in_cause: "tried to define a function or method and did not",
278 title: "def: misused as code block - 2",
279 },
280 "def_dotted_argument": {
281 in_cause: "You cannot use dotted names as function arguments.",
282 title: "Dotted name as function argument",
283 also_in_cause: ["Did you mean to write a comma?"],
284 },
285 "def_dotted_argument_2": {
286 in_cause: "You cannot use dotted names as function arguments.",
287 title: "Dotted name as function argument",
288 not_in_cause: ["Did you mean to write a comma?"],
289 },
290 "def_dotted_function_name": {
291 in_cause: "You cannot use dots in function names.",
292 title: "Dotted function name",
293 },
294 "def_dict_as_arg": {
295 in_cause: "You cannot have any explicit dict or set as function arguments",
296 title: "def: dict as argument",
297 },
298 "def_duplicate_arg": {
299 in_cause: "argument should appear only once in a function definition",
300 title: "def: arguments must be unique in function definition",
301 },
302 "def_extra_semi_colon": {
303 in_cause: "Did you write something by mistake after the colon",
304 title: "def: semicolon after colon",
305 },
306 "def_extra_comma": {
307 in_cause: "Did you mean to write `,`",
308 title: "def: extra comma",
309 },
310 "def_forward_slash_1": {
311 version_dependent: [
312 no_slash,
313 "You have unspecified keyword arguments that appear before",
314 ],
315 in_cause: "ignored",
316 title: "def: unspecified keywords before /",
317 },
318 "def_forward_slash_2": {
319 version_dependent: [
320 no_slash,
321 "When they are used together, `/` must appear before `*`",
322 ],
323 in_cause: "ignored",
324 title: "def: / before star",
325 },
326 "def_forward_slash_3": {
327 version_dependent: [
328 no_slash,
329 "`*arg` must appear after `/` in a function definition",
330 ],
331 in_cause: "ignored",
332 title: "def: / before star arg",
333 },
334 "def_forward_slash_4": {
335 version_dependent: [
336 no_slash,
337 "You can only use `/` once in a function definition",
338 ],
339 in_cause: "ignored",
340 title: "def: / used twice",
341 },
342 "def_function_name_invalid": {
343 in_cause: "The name of a function must be a valid Python identifier",
344 title: "def: non-identifier as a function name",
345 },
346 "def_function_name_string": {
347 in_cause: "use a string as a function name",
348 title: "def: using a string as a function name",
349 },
350 "def_keyword_as_arg_1": {
351 in_cause: "as an argument in the definition of a function",
352 title: "def: keyword cannot be argument in def - 1",
353 },
354 "def_keyword_as_arg_2": {
355 in_cause: "as an argument in the definition of a function",
356 title: "def: keyword cannot be argument in def - 2",
357 },
358 "def_keyword_as_arg_3": {
359 in_cause: "as an argument in the definition of a function",
360 title: "def: keyword cannot be argument in def - 3",
361 },
362 "def_keyword_as_arg_4": {
363 in_cause: "as an argument in the definition of a function",
364 title: "def: keyword cannot be argument in def - 4",
365 },
366 "def_keyword_as_name": {
367 in_cause: "You tried to use the Python keyword",
368 title: "def: Python keyword as function name",
369 },
370 "def_list_as_arg_1": {
371 in_cause: "You cannot have explicit lists as function arguments",
372 title: "def: list as argument - 1",
373 },
374 "def_list_as_arg_2": {
375 in_cause: "You cannot have explicit lists as function arguments",
376 title: "def: list as argument - 2",
377 },
378 "def_missing_colon": {
379 version_dependent: [
380 "but forgot to add a colon `:` at the end",
381 "Did you forget to write a colon",
382 ],
383 in_cause: "ignored",
384 title: "def: missing colon",
385 },
386 "def_missing_comma": {
387 in_cause: "Did you forget a comma",
388 title: "def: missing comma between function args",
389 },
390 "def_missing_parens": {
391 in_cause: "Did you forget parentheses?",
392 title: "def: missing parentheses",
393 },
394 "def_missing_parens_2": {
395 in_cause: "Did you forget parentheses?",
396 title: "def: missing parentheses around arguments",
397 },
398 "def_missing_name": {
399 in_cause: "forgot to name your function",
400 title: "def: missing function name",
401 },
402 "def_name_is_parameter_and_global": {
403 in_cause: "is a variable defined outside a function.",
404 title: "def: name is parameter and global",
405 },
406 "def_non_default_after_default": {
407 in_cause: "define functions with only positional arguments",
408 title: "def: non-default argument follows default argument",
409 },
410 "def_number_as_arg": {
411 in_cause: "You used a number as an argument",
412 title: "Single number used as arg in function def",
413 },
414 "def_operator_after_2star": {
415 in_cause: "The `**` operator needs to be followed by an identifier",
416 title: "Operator after ``**``",
417 },
418 "def_operator_instead_of_comma": {
419 in_cause: "Did you mean to write a comma",
420 title: "def: operator instead of comma",
421 },
422 "def_operator_instead_of_equal": {
423 in_cause: "Did you mean to write an equal sign",
424 title: "def: operator instead of equal",
425 },
426 "def_operator_instead_of_name": {
427 in_cause: "If you replace it by a unique variable name",
428 title: "def: operator instead of name",
429 },
430 "def_positional_after_keyword_arg": {
431 in_cause: "call functions with only positional arguments",
432 title: "def: positional argument follows keyword argument",
433 },
434 "def_semi_colon_instead_of_colon": {
435 in_cause: "You wrote `;` instead of a colon",
436 title: "def: semicolon instead of colon",
437 },
438 "def_set_as_arg": {
439 in_cause: "You cannot have any explicit dict or set as function arguments",
440 title: "def: set as argument",
441 },
442 "def_star_arg_before_slash": {
443 version_dependent: [
444 "This symbol can only be used with Python versions",
445 "`*arg` must appear after `/` ",
446 ],
447 in_cause: "ignored",
448 title: "def: ``*arg`` before /",
449 },
450 "def_star_used_only_once": {
451 in_cause: "can only use `*` once in a function definition",
452 title: "def: ``*`` used twice",
453 also_in_cause: ["`*arg`"],
454 },
455 "def_star_used_only_once_1": {
456 in_cause: "can only use `*` once in a function definition",
457 title: "def: ``*`` used twice",
458 },
459 "def_star_used_only_once_2": {
460 in_cause: "can only use `*` once in a function definition",
461 title: "def: ``*`` used twice",
462 also_in_cause: ["`*arg`", "`*other`"],
463 },
464 "def_star_after_2star": {
465 in_cause: "can only use `*` once in a function definition",
466 title: "def: ``*`` after ``**``",
467 also_in_cause: ["`**kw`"],
468 not_in_cause: ["`*` operator"],
469 },
470 "def_star_after_2star_2": {
471 in_cause: "can only use `*` once in a function definition",
472 title: "def: ``*`` after ``**``",
473 also_in_cause: ["`**kw`", "`*` operator"],
474 },
475 "def_string_as_arg": {
476 in_cause: "You used a string as an argument",
477 title: "Single string used as arg in function def",
478 },
479 "def_tuple_as_arg_1": {
480 in_cause: "You cannot have explicit tuples as function arguments.",
481 title: "def: tuple as function argument",
482 },
483 "def_tuple_as_arg_2": {
484 in_cause: "You cannot have explicit tuples as function arguments.",
485 title: "def: tuple as function argument - 2",
486 },
487 "del_paren_star_1": {
488 in_cause: "The star operator `*`",
489 title: "Deleting star expression - 1",
490 also_in_cause: [
491 "You can only delete names of objects, or items in mutable containers"
492 ],
493 },
494 "del_paren_star_2": {
495 in_cause: "The star operator `*`",
496 title: "Deleting star expression - 2",
497 also_in_cause: [
498 "You can only delete names of objects, or items in mutable containers"
499 ],
500 },
501 "delete_constant_keyword": {
502 in_cause: "You cannot delete the constant",
503 title: "Cannot delete a constant",
504 also_in_cause: [
505 "You can only delete names of objects, or items in mutable containers"
506 ],
507 },
508 "delete_expression": {
509 in_cause: "You cannot delete the expression",
510 title: "Cannot delete expression",
511 also_in_cause: [
512 "You can only delete names of objects, or items in mutable containers"
513 ],
514 },
515 "delete_function_call": {
516 in_cause: "instead of deleting the function's name",
517 title: "Cannot delete function call",
518 },
519 "delete_named_expression": {
520 in_cause: "You cannot delete the named expression",
521 version_dependent: [
522 "You cannot delete the named expression",
523 "walrus operator",
524 ],
525 title: "Cannot delete named expression",
526 },
527 "delete_names_or_items": {
528 in_cause: "You can only delete names of objects, or items in mutable containers",
529 title: "Delete only names or items",
530 },
531 "delete_string_literal": {
532 in_cause: "You cannot delete the literal",
533 title: "Deleting string literal",
534 also_in_cause: [
535 "You can only delete names of objects, or items in mutable containers"
536 ],
537 },
538 "dict_value_missing_1": {
539 in_cause: "wrote a dict key without writing the corresponding value",
540 title: "Value missing in dict - 1",
541 },
542 "dict_value_missing_2": {
543 in_cause: "Perhaps you forgot to write a value after a colon.",
544 title: "Value missing in dict - 2",
545 },
546 "dict_value_missing_3": {
547 in_cause: "wrote a dict key without writing the corresponding value",
548 title: "Value missing in dict - 3",
549 },
550 "dict_value_missing_4": {
551 in_cause: "Perhaps you forgot to write a value after a colon.",
552 title: "Value missing in dict - 4",
553 },
554 "different_operators_in_a_row": {
555 in_cause: "You cannot have these two operators, `*` and `/`",
556 title: "Different operators in a row",
557 },
558 "dot_before_paren": {
559 in_cause: "dot `.` followed by `(`",
560 title: "Dot followed by parenthesis",
561 },
562 "duplicate_token": {
563 in_cause: "wrote `,` twice in a row by mistake",
564 title: "Extra token",
565 },
566 "elif_not_matching_if": {
567 in_cause: "The `elif` keyword does not begin a code block that matches",
568 title: "elif with no matching if",
569 },
570 "ellipsis_extra_dot": {
571 in_cause: "It looks like you meant to write `...` but added an extra `.` by mistake",
572 title: "Ellipsis written with extra dot"
573 },
574 "else_no_matching_statement": {
575 in_cause: "The `else` keyword does not begin a code block that matches",
576 title: "else with no matching statement",
577 },
578 "else_if_instead_of_elif": {
579 in_cause: "wrote `else if` instead",
580 title: "Write elif, not else if",
581 },
582 "elseif_instead_of_elif": {
583 in_cause: "wrote `elseif` instead",
584 title: "Write elif, not elseif",
585 },
586 "eol_string_literal": {
587 in_cause: "ended the string with another quote",
588 title: "EOL while scanning string literal",
589 },
590 "equal_sign_instead_of_colon": {
591 in_cause: "used an equal sign `=` instead of a colon `:`",
592 title: "Used equal sign instead of colon",
593 },
594 "except_multiple_exceptions": {
595 in_cause: "with multiple exception types.",
596 title: "Parens around multiple exceptions",
597 },
598 "except_no_try": {
599 in_cause: "The `except` keyword does not begin a code block that matches",
600 title: "except with no matching try",
601 },
602 "except_or_finally": {
603 in_cause: "finally:",
604 title: "except or finally missing",
605 },
606 "extra_token": {in_cause: "wrote `==` by mistake", title: "Extra token"},
607 "f_string_assign_value": { # Python < 3.8
608 in_cause: "You are likely trying to assign a value within an f-string.",
609 title: "Cannot assign a value within an fstring",
610 },
611 "f_string_binary": {
612 in_cause: "`bf` is an illegal string prefix.",
613 title: "Binary f-string not allowed",
614 },
615 "f_string_curly_not_allowed": {
616 in_cause: "You have written an f-string which has an unmatched `}`",
617 title: "f-string: closing } not allowed",
618 },
619 "f_string_expected_curly": {
620 in_cause: "You have written an f-string which has an unmatched `{`.",
621 title: "f-string: missing closing }",
622 },
623 "f_string_unterminated": {
624 in_cause: "you have another string, which starts with either",
625 title: "f-string: unterminated string",
626 },
627 "f_string_with_backslash": {
628 in_cause: "you can replace the part that contains a backslash",
629 title: "f-string with backslash",
630 },
631 "finally_no_try": {
632 in_cause: "The `finally` keyword does not begin a code block that matches",
633 title: "finally with no matching try",
634 },
635 "for_missing_terms": {
636 in_cause: "A `for` loop is an iteration over a sequence",
637 title: "Missing terms in for statement",
638 },
639 "future_braces": {
640 in_cause: "from __future__ import braces",
641 title: "Not a chance!",
642 },
643 "future_import_star": {
644 in_cause: "you must import specific named features",
645 title: "Do not import * from __future__",
646 },
647 "future_must_be_first": {
648 in_cause: "It must appear at the beginning of the file.",
649 title: "__future__ at beginning",
650 },
651 "future_typo": {
652 in_cause: "Did you mean `division`",
653 title: "Typo in __future__",
654 },
655 "future_unknown": {
656 in_cause: "print_function",
657 title: "Unknown feature in __future__",
658 },
659 "generator_expression_parens": {
660 in_cause: "must add parentheses enclosing",
661 title: "Parenthesis around generator expression",
662 },
663 "hyphen_instead_of_underscore": {
664 in_cause: "Did you mean `a_b`",
665 title: "Space between names",
666 },
667 "if_missing_condition": {
668 in_cause: "An `if` statement requires a condition",
669 title: "Missing condition in if statement",
670 },
671 "imaginary_i": {
672 in_cause: "Did you mean `3.0j`",
673 title: "use j instead of i",
674 },
675 "import_from": {
676 in_cause: "from turtle import pen",
677 title: "Import inversion: import X from Y",
678 },
679 "import_from_2": {
680 in_cause: "from math import sin, cos",
681 title: "Import inversion: import X, Y from Z",
682 },
683 "import_from_3": {
684 in_cause: "from (...) import (...)",
685 title: "Import inversion: import a.b.c from d.e.f",
686 },
687 "indentation_error_1": {
688 in_cause: "expected to begin a new indented block",
689 title: "IndentationError: expected an indented block",
690 },
691 "indentation_error_2": {
692 in_cause: "is more indented than expected",
693 title: "IndentationError: unexpected indent",
694 },
695 "indentation_error_3": {
696 in_cause: "is less indented than expected",
697 title: "IndentationError: unindent does not match ...",
698 },
699 "indentation_error_4": {
700 in_cause: "meant to include a continuation character",
701 title: "IndentationError: missing continuation line",
702 },
703 "integer_with_leading_zero_1": {
704 in_cause: "Did you mean `0o1`",
705 title: "Forgot 'o' for octal",
706 },
707 "integer_with_leading_zero_2": {
708 in_cause: "Did you mean `123_456`",
709 title: "Integer with leading zeros",
710 },
711 "invalid_character_in_identifier": {
712 in_cause: "unicode character",
713 title: "Invalid character in identifier",
714 },
715 "invalid_decimal_literal1": {
716 in_cause: "Valid names cannot begin with a number",
717 title: "Invalid decimal literal - 1",
718 },
719 "invalid_encoding": {
720 in_cause: "The encoding of the file was not valid.",
721 title: "Invalid encoding",
722 },
723 "invalid_hexadecimal": {
724 in_cause: "Did you made a mistake in writing an hexadecimal integer",
725 title: "Invalid hexadecimal number",
726 },
727 "invalid_identifier": {
728 in_cause: "Valid names cannot begin with a number",
729 title: "Valid names cannot begin with a number",
730 not_in_cause: ["complex"],
731 },
732 "invalid_identifier_2": {
733 in_cause: "Perhaps you forgot a multiplication operator",
734 title: "Valid names cannot begin with a number - 2",
735 not_in_cause: ["complex"],
736 },
737 "invalid_identifier_3": {
738 in_cause: "Perhaps you forgot a multiplication operator",
739 title: "Valid names cannot begin with a number - 3",
740 also_in_cause: ["complex"],
741 },
742 "invalid_identifier_4": {
743 in_cause: "Valid names cannot begin with a number",
744 title: "Valid names cannot begin with a number - 4",
745 not_in_cause: ["multiplication operator"],
746 },
747 "invalid_identifier_5": {
748 in_cause: "Valid names cannot begin with a number",
749 title: "Valid names cannot begin with a number - 5",
750 also_in_cause: ["complex", "multiplication operator"],
751 },
752 "invalid_keyword_argument": {
753 in_cause: "where `invalid` is not a valid ",
754 title: "Keyword can't be an expression",
755 },
756 "invalid_keyword_argument_2": {
757 in_cause: "You cannot assign a value to `True`.",
758 title: "Named argument can't be a Python keyword",
759 },
760 "invalid_non_printable_char": {
761 in_cause: "Your code contains the invalid non-printable character",
762 title: "Invalid non printable character"
763 },
764 "invalid_octal": {
765 in_cause: "Did you made a mistake in writing an octal integer",
766 title: "Invalid octal number",
767 },
768 "inverted_operators": {
769 in_cause: "Did you write operators in an incorrect order?",
770 title: "Inverted operators 1",
771 },
772 "inverted_operators_2": {
773 in_cause: "Did you write operators in an incorrect order?",
774 title: "Inverted operators 2",
775 also_in_cause: ["all the syntax errors in the code you wrote"],
776 },
777 "iteration_unpacking_in_comprehension": {
778 in_cause: "You cannot use the `*` operator to unpack the iteration variable",
779 title: "Iteration variable unpacking in comprehension",
780 },
781 "keyword_arg_repeated": {
782 in_cause: "keyword argument should appear only once in a function call",
783 title: "Keyword arg only once in function call",
784 },
785 "keyword_as_attribute": {
786 in_cause: "keyword `pass` as an attribute",
787 title: "Keyword as attribute",
788 },
789 "lambda_with_parens": {
790 in_cause: "`lambda` does not allow parentheses ",
791 title: "lambda with parentheses around arguments",
792 },
793 "lambda_with_tuple_argument": {
794 in_cause: "You cannot have explicit tuples as arguments.",
795 title: "lambda with tuple as argument",
796 },
797 "literal_in_for_loop": {
798 in_cause: "where `...` must contain only identifiers",
799 title: "Assign to literal in for loop",
800 },
801 "missing_code_block": { # May differ depending on Python version
802 version_dependent: [
803 "expected an indented block",
804 "it reached the end of the file and expected more content.",
805 ],
806 in_cause: "it reached the end of the file and expected more content.",
807 title: "IndentationError/SyntaxError depending on version",
808 },
809 "missing_code_block_2": {
810 version_dependent: [
811 "unexpected EOF while parsing",
812 # do not include 'indented' below as this results in the test
813 # assuming that an Indention error is raised, which is not
814 # true for earlier Python versions.
815 # Also do not include line number shown in the message
816 # as it can be off by 1 on Github automated tests for this case.
817 "identified above was expected to begin a",
818 ],
819 in_cause: "ignored",
820 title: "IndentationError/SyntaxError depending on version - 2",
821 },
822 "missing_colon_if": {
823 version_dependent: [
824 "Did you forget a colon",
825 "`if` but forgot to add a colon `:`",
826 ],
827 in_cause: "ignored",
828 title: "Missing colon - if",
829 },
830 "missing_colon_while": {
831 version_dependent: ["Did you forget a colon", "wrote a `while` loop but"],
832 in_cause: "ignored",
833 title: "Missing colon - while",
834 },
835 "missing_comma_in_dict": {
836 in_cause: "forgot a comma",
837 title: "Missing comma in a dict",
838 },
839 "missing_comma_in_dict_2": {
840 in_cause: "I am guessing that you forgot a comma between two strings",
841 title: "Missing comma between strings in a dict",
842 },
843 "missing_comma_in_list": {
844 in_cause: "The following lines of code",
845 title: "Missing comma in a list",
846 },
847 "missing_comma_in_set": {
848 in_cause: "The following lines of code",
849 title: "Missing comma in a set",
850 },
851 "missing_comma_in_tuple": {
852 in_cause: "The following lines of code",
853 title: "Missing comma in a tuple",
854 },
855 "missing_in_with_for": {
856 in_cause: "Did you forget to write `in`?",
857 title: "For loop missing 'in' operator",
858 },
859 "missing_index": {
860 in_cause: "[1, 2, 3][0]",
861 title: "Missing index"
862 },
863 "missing_parens_for_range": {
864 in_cause: "you forgot to use to use parenthesis with `range`",
865 title: "Missing parenthesis for range",
866 },
867 "misspelled_keyword": {
868 in_cause: "if i in range(3)",
869 title: "Misspelled Python keyword",
870 },
871 "name_is_global_and_nonlocal": {
872 in_cause: "You declared `xy` as being both a global and nonlocal",
873 title: "Name is global and nonlocal",
874 },
875 "name_is_param_and_nonlocal": {
876 in_cause: "You used `x` as a parameter for a function",
877 title: "Name is parameter and nonlocal",
878 },
879 "no_binding_for_nonlocal": {
880 in_cause: "nonlocal variable but it cannot be found.",
881 title: "nonlocal variable not found",
882 },
883 "nonlocal_at_module": {
884 in_cause: "You used the nonlocal keyword at a module level",
885 title: "nonlocal variable not found at module level",
886 },
887 "operator_twice_in_a_row": {
888 in_cause: "You cannot have write the same operator, `**`, twice in a row",
889 title: "Same operator twice in a row",
890 },
891 "pip_install_1": {
892 in_cause: "`pip` is a command that needs to run in a terminal",
893 title: "Using pip from interpreter",
894 },
895 "pip_install_2": {
896 in_cause: "`pip` is a command that needs to run in a terminal",
897 title: "Using pip from interpreter 2",
898 },
899 "print_is_a_function": {
900 in_cause: "In older version of Python, `print` was a keyword",
901 title: "print is a function",
902 },
903 "print_is_a_function_2": {
904 in_cause: "In older version of Python, `print` was a keyword",
905 title: "print is a function 2",
906 },
907 "print_is_a_function_3": {
908 in_cause: "In older version of Python, `print` was a keyword",
909 title: "print is a function 3",
910 },
911 "print_is_a_function_4": {
912 in_cause: "In older version of Python, `print` was a keyword",
913 title: "print is a function 4",
914 also_in_cause: ["print(...)"],
915 },
916 "print_is_a_function_5": {
917 in_cause: "In older version of Python, `print` was a keyword",
918 title: "print is a function 5",
919 },
920 "print_non_paren_non_string1": {
921 in_cause: "In older version of Python, `print` was a keyword",
922 title: "print is a function 6",
923 },
924 "print_non_paren_non_string2": {
925 in_cause: "In older version of Python, `print` was a keyword",
926 title: "print is a function 7",
927 },
928 "python_interpreter": {
929 in_cause: " attempting to use Python to run a program",
930 title: "Calling python from interpreter",
931 },
932 "python_not_interpreter": {
933 in_cause: "Did you forget something between `a` and `b`",
934 title: "problem with assigning a variable to Python",
935 },
936 "quote_inside_string": {
937 in_cause: "Perhaps you forgot to escape a quote character",
938 title: "Quote inside a string",
939 },
940 "raise_multiple_exceptions": {
941 in_cause: "trying to raise an exception using Python 2 syntax.",
942 title: "Raising multiple exceptions",
943 },
944 "return_outside_function": {
945 in_cause: "You can only use a `return`",
946 title: "Cannot use return outside function",
947 },
948 "scientific_notation_missing_exponent": {
949 in_cause: "Did you mean `1.5e0`",
950 title: "Missing exponent for scientific notation"
951 },
952 "semi_colon_instead_of_colon": {
953 in_cause: "You wrote a semicolon, `;`, where a colon was expected.",
954 title: "Semicolon instead of colon",
955 },
956 "semi_colon_instead_of_comma_1": {
957 in_cause: "You wrote a semicolon, `;`, where a comma was expected.",
958 title: "Semicolon instead of comma - 1",
959 },
960 "semi_colon_instead_of_comma_2": {
961 in_cause: "You wrote semicolons, `;`, where commas were expected.",
962 title: "Semicolon instead of commas - 2",
963 },
964 "semi_colon_instead_of_comma_3": {
965 in_cause: "You wrote semicolons, `;`, where commas were expected.",
966 title: "Semicolon instead of commas - 3",
967 },
968 "should_be_comprehension": {
969 in_cause: "You cannot have separate code blocks inside list comprehensions.",
970 title: "Code block inside comprehension",
971 },
972 "single_equal_with_if": {
973 in_cause: "Perhaps you needed `==`",
974 title: "Single = instead of double == with if",
975 },
976 "single_equal_with_elif": {
977 in_cause: "Perhaps you needed `==`",
978 title: "Single = instead of double == with elif",
979 },
980 "single_equal_with_while": {
981 in_cause: "Perhaps you needed `==`",
982 title: "Single = instead of double == with while",
983 },
984 "space_between_operators_1": {
985 in_cause: "meant to write `**` as a single operator",
986 title: "Space between operators 1",
987 },
988 "space_between_operators_2": {
989 in_cause: "meant to write `/=` as a single operator",
990 title: "Space between operators 2",
991 },
992 "space_in_variable_name": {
993 in_cause: "You cannot have spaces in identifiers (variable names).",
994 title: "Space in variable name",
995 },
996 "star_assignment_target": {
997 in_cause: "list_or_tuple",
998 title: "Wrong target for star assignment",
999 },
1000 "too_many_nested_blocks": {
1001 in_cause: "you need to reduce the number",
1002 title: "Too many nested blocks",
1003 # If the word "indented" appears in "cause" for unit tests, we expect
1004 # that this signal an indentation error.
1005 also_in_cause: ["indented code blocks"],
1006 },
1007 "too_many_parentheses": {
1008 in_cause: "you need to reduce the number of parentheses",
1009 title: "Too many nested parentheses.",
1010 },
1011 "trailing_comma_in_import": {
1012 in_cause: "However, if you remove the last comma, there will be no syntax error",
1013 title: "Trailing comma in import statement",
1014 },
1015 "triple_equal": {
1016 in_cause: "the exact same object, use the operator `is`",
1017 title: "Triple-equal sign",
1018 },
1019 "unclosed_bracket": {
1020 in_cause: "The opening square bracket `[`",
1021 title: "Unclosed bracket",
1022 },
1023 "unclosed_paren_1": {
1024 in_cause: "The opening parenthesis `(` on line",
1025 title: "Unclosed parenthesis - 1",
1026 },
1027 "unclosed_paren_2": {
1028 in_cause: "The opening parenthesis `(` on line",
1029 title: "Unclosed parenthesis - 2",
1030 },
1031 "unclosed_paren_3": {
1032 in_cause: "The opening parenthesis `(` on line 5 is not closed",
1033 title: "Unclosed parenthesis - 3",
1034 },
1035 "unclosed_paren_4": {
1036 in_cause: "The opening parenthesis `(` on line 2 is not closed",
1037 title: "Unclosed parenthesis - 4",
1038 },
1039 "unexpected_after_continuation_character": {
1040 in_cause: "using the continuation character",
1041 title: "Content passed continuation line character",
1042 },
1043 "unexpected_eof": {
1044 in_cause: "The opening square bracket `[`",
1045 title: "Unexpected EOF while parsing",
1046 },
1047 "unicode_fraction": {
1048 in_cause: "that you meant to write the fraction",
1049 title: "Invalid character (unicode fraction 3/4)",
1050 },
1051 "unicode_fraction2": {
1052 in_cause: "that you meant to write the fraction",
1053 title: "Invalid character (unicode fraction 1/2)",
1054 },
1055 "unicode_fraction3": {
1056 in_cause: "but is different from the division operator",
1057 title: "Invalid character (unicode fraction slash)",
1058 },
1059 "unicode_quote": {
1060 in_cause: "fancy unicode quotation mark",
1061 title: "Invalid character (unicode quote)",
1062 },
1063 "unicode_quote2": {
1064 in_cause: "fancy unicode quotation mark",
1065 title: "Invalid character (unicode quote2)",
1066 not_in_cause: ["you meant to write a less than sign"],
1067 },
1068 "unicode_quote3": {
1069 in_cause: "fancy unicode quotation mark",
1070 title: "Invalid character (mistaken <)",
1071 also_in_cause: ["you meant to write a less than sign"],
1072 },
1073 "unicode_quote4": {
1074 in_cause: "fancy unicode quotation mark",
1075 title: "Invalid character (mistaken >)",
1076 also_in_cause: ["you meant to write a greater than sign"],
1077 },
1078 "unicode_quote5": {
1079 in_cause: "fancy unicode quotation mark",
1080 title: "Invalid character (mistaken comma)",
1081 also_in_cause: ["you meant to write a comma"],
1082 },
1083 "unmatched_closing_curly": {
1084 in_cause: "The closing curly bracket `}` on",
1085 title: "Unmatched closing curly bracket",
1086 },
1087 "unmatched_closing_paren": {
1088 in_cause: "The closing parenthesis `)` on",
1089 title: "Unmatched closing parenthesis",
1090 },
1091 "unmatched_closing_bracket_1": {
1092 in_cause: "The closing square bracket `]` on line",
1093 title: "Mismatched brackets - 1",
1094 },
1095 "unmatched_closing_bracket_2": {
1096 in_cause: "The closing square bracket `]` on line",
1097 title: "Mismatched brackets - 2",
1098 },
1099 "unmatched_closing_bracket_3": {
1100 in_cause: "The closing square bracket `]` on line",
1101 title: "Unmatched brackets - 3",
1102 },
1103 "unpacking_dict_value": {
1104 in_cause: "It looks like you tried to use a starred expression as a dict value",
1105 title: "Unpacking a dict value",
1106 },
1107 "unterminated_triple_quote_string": {
1108 in_cause: "You started writing a triple-quoted string",
1109 title: "Unterminated triple quoted string",
1110 },
1111 "tab_error": {
1112 in_cause: "A `TabError` indicates that you have used",
1113 title: "TabError",
1114 },
1115 "typo_in_except": {
1116 in_cause: "except Exception:",
1117 title: "Wrong word instead of expect",
1118 },
1119 "typo_in_finally": {
1120 in_cause: "finally:",
1121 title: "Typo in finally",
1122 },
1123 "unescaped_backslash": {
1124 in_cause: "Did you forget to escape a backslash character",
1125 title: "EOL unescaped backslash",
1126 },
1127 "use_backquote": {
1128 in_cause: "use the function `repr(x)`.",
1129 title: "Using the backquote character",
1130 },
1131 "unicode_error": {
1132 in_cause: "one backslash character, `\\` followed by an uppercase `U`",
1133 title: "unicode error",
1134 },
1135 "walrus_does_not_exist": { # Python < 3.8
1136 in_cause: "walrus operator",
1137 title: "Walrus operator does not exist - yet",
1138 },
1139 "walrus_instead_of_equal": {
1140 version_dependent: [
1141 "walrus operator",
1142 "You use the augmented assignment operator `:=` where",
1143 ],
1144 in_cause: "ignored",
1145 title: "Walrus instead of equal",
1146 also_in_cause: ["the normal assignment operator `=` was required."],
1147 },
1148 "while_missing_condition": {
1149 in_cause: "A `while` loop requires a condition",
1150 title: "Missing condition in while statement",
1151 },
1152 "would_be_type_declaration_1": {
1153 in_cause: "You do not need to declare variables in Python.",
1154 title: "Would-be variable declaration",
1155 },
1156 "would_be_type_declaration_2": {
1157 in_cause: "You do not need to declare variables in Python.",
1158 title: "Would-be variable declaration - 2",
1159 },
1160 "yield_outside_function": {
1161 in_cause: "You can only use a `yield`",
1162 title: "Cannot use yield outside function",
1163 },
1164 }
1165
1166 if sys.version_info >= (3, 8):
1167 del descriptions["f_string_assign_value"]
1168 del descriptions["debug_fstring_not_supported"] # introduced in Python 3.8
1169 del descriptions["walrus_does_not_exist"] # := introduced in Python 3.8
1170
1171 if sys.version_info < (3, 9):
1172 del descriptions["too_many_parentheses"] # will be a memory error instead
1173
1174 if sys.version_info < (3, 10):
1175 del descriptions["except_or_finally"]
1176 del descriptions["typo_in_finally"]
1177 del descriptions["typo_in_except"]
1178
1179 if sys.version_info >= (3, 12):
1180 descriptions["f_string_unterminated"]= {
1181 in_cause: "never ended the string with another quote on that line",
1182 title: "unterminated string literal",
1183 }
1184 del descriptions["f_string_with_backslash"] # not a syntax error for Python 3.12