mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed E128, E741 flake8 warnings.
This commit is contained in:
parent
e6ec76d245
commit
0668164b4a
11 changed files with 94 additions and 78 deletions
|
@ -42,17 +42,29 @@ class JsTokensTest(SimpleTestCase):
|
|||
(r"a=/\//,1", ["id a", "punct =", r"regex /\//", "punct ,", "dnum 1"]),
|
||||
|
||||
# next two are from https://www-archive.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions # NOQA
|
||||
("""for (var x = a in foo && "</x>" || mot ? z:/x:3;x<5;y</g/i) {xyz(x++);}""",
|
||||
["keyword for", "punct (", "keyword var", "id x", "punct =", "id a", "keyword in",
|
||||
"id foo", "punct &&", 'string "</x>"', "punct ||", "id mot", "punct ?", "id z",
|
||||
"punct :", "regex /x:3;x<5;y</g", "punct /", "id i", "punct )", "punct {",
|
||||
"id xyz", "punct (", "id x", "punct ++", "punct )", "punct ;", "punct }"]),
|
||||
("""for (var x = a in foo && "</x>" || mot ? z/x:3;x<5;y</g/i) {xyz(x++);}""",
|
||||
["keyword for", "punct (", "keyword var", "id x", "punct =", "id a", "keyword in",
|
||||
"id foo", "punct &&", 'string "</x>"', "punct ||", "id mot", "punct ?", "id z",
|
||||
"punct /", "id x", "punct :", "dnum 3", "punct ;", "id x", "punct <", "dnum 5",
|
||||
"punct ;", "id y", "punct <", "regex /g/i", "punct )", "punct {",
|
||||
"id xyz", "punct (", "id x", "punct ++", "punct )", "punct ;", "punct }"]),
|
||||
(
|
||||
"""for (var x = a in foo && "</x>" || mot ? z:/x:3;x<5;y</g/i) {xyz(x++);}""",
|
||||
[
|
||||
"keyword for", "punct (", "keyword var", "id x", "punct =",
|
||||
"id a", "keyword in", "id foo", "punct &&", 'string "</x>"',
|
||||
"punct ||", "id mot", "punct ?", "id z", "punct :",
|
||||
"regex /x:3;x<5;y</g", "punct /", "id i", "punct )", "punct {",
|
||||
"id xyz", "punct (", "id x", "punct ++", "punct )", "punct ;",
|
||||
"punct }"
|
||||
],
|
||||
),
|
||||
(
|
||||
"""for (var x = a in foo && "</x>" || mot ? z/x:3;x<5;y</g/i) {xyz(x++);}""",
|
||||
[
|
||||
"keyword for", "punct (", "keyword var", "id x", "punct =",
|
||||
"id a", "keyword in", "id foo", "punct &&", 'string "</x>"',
|
||||
"punct ||", "id mot", "punct ?", "id z", "punct /", "id x",
|
||||
"punct :", "dnum 3", "punct ;", "id x", "punct <", "dnum 5",
|
||||
"punct ;", "id y", "punct <", "regex /g/i", "punct )",
|
||||
"punct {", "id xyz", "punct (", "id x", "punct ++", "punct )",
|
||||
"punct ;", "punct }",
|
||||
],
|
||||
),
|
||||
|
||||
# Various "illegal" regexes that are valid according to the std.
|
||||
(r"""/????/, /++++/, /[----]/ """, ["regex /????/", "punct ,", "regex /++++/", "punct ,", "regex /[----]/"]),
|
||||
|
@ -65,46 +77,50 @@ class JsTokensTest(SimpleTestCase):
|
|||
(r"""/a[\]]b/""", [r"""regex /a[\]]b/"""]),
|
||||
(r"""/[\]/]/gi""", [r"""regex /[\]/]/gi"""]),
|
||||
(r"""/\[[^\]]+\]/gi""", [r"""regex /\[[^\]]+\]/gi"""]),
|
||||
(r"""
|
||||
rexl.re = {
|
||||
NAME: /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/,
|
||||
UNQUOTED_LITERAL: /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/,
|
||||
QUOTED_LITERAL: /^'(?:[^']|'')*'/,
|
||||
NUMERIC_LITERAL: /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/,
|
||||
SYMBOL: /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/
|
||||
};
|
||||
""", # NOQA
|
||||
["id rexl", "punct .", "id re", "punct =", "punct {",
|
||||
"id NAME", "punct :", r"""regex /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/""", "punct ,",
|
||||
"id UNQUOTED_LITERAL", "punct :", r"""regex /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/""",
|
||||
"punct ,",
|
||||
"id QUOTED_LITERAL", "punct :", r"""regex /^'(?:[^']|'')*'/""", "punct ,",
|
||||
"id NUMERIC_LITERAL", "punct :", r"""regex /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/""", "punct ,",
|
||||
"id SYMBOL", "punct :", r"""regex /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/""", # NOQA
|
||||
"punct }", "punct ;"
|
||||
]),
|
||||
|
||||
(r"""
|
||||
rexl.re = {
|
||||
NAME: /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/,
|
||||
UNQUOTED_LITERAL: /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/,
|
||||
QUOTED_LITERAL: /^'(?:[^']|'')*'/,
|
||||
NUMERIC_LITERAL: /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/,
|
||||
SYMBOL: /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/
|
||||
};
|
||||
str = '"';
|
||||
""", # NOQA
|
||||
["id rexl", "punct .", "id re", "punct =", "punct {",
|
||||
"id NAME", "punct :", r"""regex /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/""", "punct ,",
|
||||
"id UNQUOTED_LITERAL", "punct :", r"""regex /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/""",
|
||||
"punct ,",
|
||||
"id QUOTED_LITERAL", "punct :", r"""regex /^'(?:[^']|'')*'/""", "punct ,",
|
||||
"id NUMERIC_LITERAL", "punct :", r"""regex /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/""", "punct ,",
|
||||
"id SYMBOL", "punct :", r"""regex /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/""", # NOQA
|
||||
"punct }", "punct ;",
|
||||
"id str", "punct =", """string '"'""", "punct ;",
|
||||
]),
|
||||
|
||||
(
|
||||
r"""
|
||||
rexl.re = {
|
||||
NAME: /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/,
|
||||
UNQUOTED_LITERAL: /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/,
|
||||
QUOTED_LITERAL: /^'(?:[^']|'')*'/,
|
||||
NUMERIC_LITERAL: /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/,
|
||||
SYMBOL: /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/
|
||||
};
|
||||
""", # NOQA
|
||||
[
|
||||
"id rexl", "punct .", "id re", "punct =", "punct {",
|
||||
"id NAME", "punct :", r"""regex /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/""", "punct ,",
|
||||
"id UNQUOTED_LITERAL", "punct :", r"""regex /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/""",
|
||||
"punct ,",
|
||||
"id QUOTED_LITERAL", "punct :", r"""regex /^'(?:[^']|'')*'/""", "punct ,",
|
||||
"id NUMERIC_LITERAL", "punct :", r"""regex /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/""", "punct ,",
|
||||
"id SYMBOL", "punct :", r"""regex /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/""", # NOQA
|
||||
"punct }", "punct ;"
|
||||
],
|
||||
),
|
||||
(
|
||||
r"""
|
||||
rexl.re = {
|
||||
NAME: /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/,
|
||||
UNQUOTED_LITERAL: /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/,
|
||||
QUOTED_LITERAL: /^'(?:[^']|'')*'/,
|
||||
NUMERIC_LITERAL: /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/,
|
||||
SYMBOL: /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/
|
||||
};
|
||||
str = '"';
|
||||
""", # NOQA
|
||||
[
|
||||
"id rexl", "punct .", "id re", "punct =", "punct {",
|
||||
"id NAME", "punct :", r"""regex /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/""", "punct ,",
|
||||
"id UNQUOTED_LITERAL", "punct :", r"""regex /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/""",
|
||||
"punct ,",
|
||||
"id QUOTED_LITERAL", "punct :", r"""regex /^'(?:[^']|'')*'/""", "punct ,",
|
||||
"id NUMERIC_LITERAL", "punct :", r"""regex /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/""", "punct ,",
|
||||
"id SYMBOL", "punct :", r"""regex /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/""", # NOQA
|
||||
"punct }", "punct ;",
|
||||
"id str", "punct =", """string '"'""", "punct ;",
|
||||
],
|
||||
),
|
||||
(r""" this._js = "e.str(\"" + this.value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\")"; """,
|
||||
["keyword this", "punct .", "id _js", "punct =", r'''string "e.str(\""''', "punct +", "keyword this",
|
||||
"punct .", "id value", "punct .", "id replace", "punct (", r"regex /\\/g", "punct ,", r'string "\\\\"',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue