mirror of
https://github.com/davidhalter/parso.git
synced 2026-02-09 19:31:24 +08:00
flake8 changes
This commit is contained in:
@@ -135,11 +135,11 @@ class FileModification:
|
||||
# We cannot delete every line, that doesn't make sense to
|
||||
# fuzz and it would be annoying to rewrite everything here.
|
||||
continue
|
||||
l = LineDeletion(random_line())
|
||||
ld = LineDeletion(random_line())
|
||||
elif rand == 2:
|
||||
# Copy / Insertion
|
||||
# Make it possible to insert into the first and the last line
|
||||
l = LineCopy(random_line(), random_line(include_end=True))
|
||||
ld = LineCopy(random_line(), random_line(include_end=True))
|
||||
elif rand in (3, 4):
|
||||
# Modify a line in some weird random ways.
|
||||
line_nr = random_line()
|
||||
@@ -166,9 +166,9 @@ class FileModification:
|
||||
# we really replace the line with something that has
|
||||
# indentation.
|
||||
line = ' ' * random.randint(0, 12) + random_string + '\n'
|
||||
l = LineReplacement(line_nr, line)
|
||||
l.apply(lines)
|
||||
yield l
|
||||
ld = LineReplacement(line_nr, line)
|
||||
ld.apply(lines)
|
||||
yield ld
|
||||
|
||||
def __init__(self, modification_list, check_original):
|
||||
self.modification_list = modification_list
|
||||
|
||||
@@ -81,7 +81,7 @@ def test_modulepickling_simulate_deleted_cache(tmpdir):
|
||||
way.
|
||||
|
||||
__ https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
|
||||
"""
|
||||
""" # noqa
|
||||
grammar = load_grammar()
|
||||
module = 'fake parser'
|
||||
|
||||
|
||||
@@ -1340,7 +1340,7 @@ def test_backslash_issue(differ):
|
||||
pre = (
|
||||
'')
|
||||
\\if
|
||||
''')
|
||||
''') # noqa
|
||||
differ.initialize(code1)
|
||||
differ.parse(code2, parsers=1, copies=1, expect_error_leaves=True)
|
||||
differ.parse(code1, parsers=1, copies=1)
|
||||
@@ -1420,7 +1420,7 @@ def test_with_formfeed(differ):
|
||||
\x0cimport
|
||||
return
|
||||
return ''
|
||||
''')
|
||||
''') # noqa
|
||||
differ.initialize(code1)
|
||||
differ.parse(code2, parsers=ANY, copies=ANY, expect_error_leaves=True)
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ def collect_errors(code):
|
||||
column = int(add_indent or len(match.group(1)))
|
||||
|
||||
code, _, add_line = code.partition('+')
|
||||
l = line_nr + 1 + int(add_line or 0)
|
||||
ln = line_nr + 1 + int(add_line or 0)
|
||||
|
||||
yield WantedIssue(code[1:], l, column)
|
||||
yield WantedIssue(code[1:], ln, column)
|
||||
|
||||
|
||||
def test_normalizer_issue(normalizer_issue_case):
|
||||
|
||||
@@ -135,7 +135,7 @@ def test_wrong_indentation():
|
||||
b
|
||||
a
|
||||
""")
|
||||
#check_p(src, 1)
|
||||
check_p(src, 1)
|
||||
|
||||
src = dedent("""\
|
||||
def complex():
|
||||
|
||||
@@ -193,10 +193,12 @@ def test_no_error_nodes(each_version):
|
||||
def test_named_expression(works_ge_py38):
|
||||
works_ge_py38.parse("(a := 1, a + 1)")
|
||||
|
||||
|
||||
def test_extended_rhs_annassign(works_ge_py38):
|
||||
works_ge_py38.parse("x: y = z,")
|
||||
works_ge_py38.parse("x: Tuple[int, ...] = z, *q, w")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'param_code', [
|
||||
'a=1, /',
|
||||
@@ -211,6 +213,7 @@ def test_extended_rhs_annassign(works_ge_py38):
|
||||
def test_positional_only_arguments(works_ge_py38, param_code):
|
||||
works_ge_py38.parse("def x(%s): pass" % param_code)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'expression', [
|
||||
'a + a',
|
||||
|
||||
@@ -163,13 +163,13 @@ def top_function_three():
|
||||
raise Exception
|
||||
"""
|
||||
|
||||
r = get_raise_stmts(code, 0) # Lists in a simple Function
|
||||
r = get_raise_stmts(code, 0) # Lists in a simple Function
|
||||
assert len(list(r)) == 1
|
||||
|
||||
r = get_raise_stmts(code, 1) # Doesn't Exceptions list in closures
|
||||
r = get_raise_stmts(code, 1) # Doesn't Exceptions list in closures
|
||||
assert len(list(r)) == 1
|
||||
|
||||
r = get_raise_stmts(code, 2) # Lists inside try-catch
|
||||
r = get_raise_stmts(code, 2) # Lists inside try-catch
|
||||
assert len(list(r)) == 2
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ def test_eof_blankline():
|
||||
assert_issue('# foobar\n\n')
|
||||
assert_issue('\n\n')
|
||||
|
||||
|
||||
def test_shebang():
|
||||
assert not issues('#!\n')
|
||||
assert not issues('#!/foo\n')
|
||||
|
||||
@@ -44,7 +44,7 @@ def test_simple_prefix_splitting(string, tokens):
|
||||
else:
|
||||
end_pos = start_pos[0], start_pos[1] + len(expected) + len(pt.spacing)
|
||||
|
||||
#assert start_pos == pt.start_pos
|
||||
# assert start_pos == pt.start_pos
|
||||
assert end_pos == pt.end_pos
|
||||
start_pos = end_pos
|
||||
|
||||
|
||||
@@ -273,10 +273,12 @@ def test_too_many_levels_of_indentation():
|
||||
assert not _get_error_list(build_nested('pass', 49, base=base))
|
||||
assert _get_error_list(build_nested('pass', 50, base=base))
|
||||
|
||||
|
||||
def test_paren_kwarg():
|
||||
assert _get_error_list("print((sep)=seperator)", version="3.8")
|
||||
assert not _get_error_list("print((sep)=seperator)", version="3.7")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'code', [
|
||||
"f'{*args,}'",
|
||||
@@ -330,6 +332,7 @@ def test_trailing_comma(code):
|
||||
errors = _get_error_list(code)
|
||||
assert not errors
|
||||
|
||||
|
||||
def test_continue_in_finally():
|
||||
code = dedent('''\
|
||||
for a in [1]:
|
||||
@@ -341,7 +344,7 @@ def test_continue_in_finally():
|
||||
assert not _get_error_list(code, version="3.8")
|
||||
assert _get_error_list(code, version="3.7")
|
||||
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'template', [
|
||||
"a, b, {target}, c = d",
|
||||
@@ -392,6 +395,7 @@ def test_repeated_kwarg():
|
||||
def test_unparenthesized_genexp(source, no_errors):
|
||||
assert bool(_get_error_list(source)) ^ no_errors
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
('source', 'no_errors'), [
|
||||
('*x = 2', False),
|
||||
|
||||
@@ -108,7 +108,7 @@ def test_tokenize_multiline_I():
|
||||
fundef = '''""""\n'''
|
||||
token_list = _get_token_list(fundef)
|
||||
assert token_list == [PythonToken(ERRORTOKEN, '""""\n', (1, 0), ''),
|
||||
PythonToken(ENDMARKER , '', (2, 0), '')]
|
||||
PythonToken(ENDMARKER, '', (2, 0), '')]
|
||||
|
||||
|
||||
def test_tokenize_multiline_II():
|
||||
@@ -117,7 +117,7 @@ def test_tokenize_multiline_II():
|
||||
fundef = '''""""'''
|
||||
token_list = _get_token_list(fundef)
|
||||
assert token_list == [PythonToken(ERRORTOKEN, '""""', (1, 0), ''),
|
||||
PythonToken(ENDMARKER, '', (1, 4), '')]
|
||||
PythonToken(ENDMARKER, '', (1, 4), '')]
|
||||
|
||||
|
||||
def test_tokenize_multiline_III():
|
||||
@@ -126,7 +126,7 @@ def test_tokenize_multiline_III():
|
||||
fundef = '''""""\n\n'''
|
||||
token_list = _get_token_list(fundef)
|
||||
assert token_list == [PythonToken(ERRORTOKEN, '""""\n\n', (1, 0), ''),
|
||||
PythonToken(ENDMARKER, '', (3, 0), '')]
|
||||
PythonToken(ENDMARKER, '', (3, 0), '')]
|
||||
|
||||
|
||||
def test_identifier_contains_unicode():
|
||||
|
||||
@@ -83,6 +83,7 @@ def test_bytes_to_unicode_failing_encoding(code, errors):
|
||||
else:
|
||||
python_bytes_to_unicode(code, errors=errors)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
('version_str', 'version'), [
|
||||
('3', (3,)),
|
||||
|
||||
Reference in New Issue
Block a user