mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 21:04:29 +08:00
Add some test files for E30x.
This commit is contained in:
193
test/normalizer_issue_files/E30.py
Normal file
193
test/normalizer_issue_files/E30.py
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
#: E301+4
|
||||||
|
class X:
|
||||||
|
|
||||||
|
def a():
|
||||||
|
pass
|
||||||
|
def b():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
#: E301+5
|
||||||
|
class X:
|
||||||
|
|
||||||
|
def a():
|
||||||
|
pass
|
||||||
|
# comment
|
||||||
|
def b():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
#!python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
def a():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
#: E302+1:0
|
||||||
|
"""Main module."""
|
||||||
|
def _main():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
#: E302+1:0
|
||||||
|
foo = 1
|
||||||
|
def get_sys_path():
|
||||||
|
return sys.path
|
||||||
|
|
||||||
|
|
||||||
|
#: E302+3:0
|
||||||
|
def a():
|
||||||
|
pass
|
||||||
|
|
||||||
|
def b():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
#: E302+5:0
|
||||||
|
def a():
|
||||||
|
pass
|
||||||
|
|
||||||
|
# comment
|
||||||
|
|
||||||
|
def b():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
#: E302+3:0
|
||||||
|
def a():
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def b():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
#: E303+3:0
|
||||||
|
print
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#: E303+3:0 E303+4:0
|
||||||
|
print
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
print
|
||||||
|
#: E303+3:0
|
||||||
|
print
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# comment
|
||||||
|
|
||||||
|
print
|
||||||
|
|
||||||
|
|
||||||
|
#: E303+3 E303+6
|
||||||
|
def a():
|
||||||
|
print
|
||||||
|
|
||||||
|
|
||||||
|
# comment
|
||||||
|
|
||||||
|
|
||||||
|
# another comment
|
||||||
|
|
||||||
|
print
|
||||||
|
|
||||||
|
|
||||||
|
#: E304+1
|
||||||
|
@decorator
|
||||||
|
|
||||||
|
def function():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
#: E303+3
|
||||||
|
#!python
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"""This class docstring comes on line 5.
|
||||||
|
It gives error E303: too many blank lines (3)
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
#: E302+6
|
||||||
|
def a():
|
||||||
|
print
|
||||||
|
|
||||||
|
# comment
|
||||||
|
|
||||||
|
# another comment
|
||||||
|
a()
|
||||||
|
|
||||||
|
|
||||||
|
#: E302+7
|
||||||
|
def a():
|
||||||
|
print
|
||||||
|
|
||||||
|
# comment
|
||||||
|
|
||||||
|
# another comment
|
||||||
|
|
||||||
|
try:
|
||||||
|
a()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
#: E302+4
|
||||||
|
def a():
|
||||||
|
print
|
||||||
|
|
||||||
|
# Two spaces before comments, too.
|
||||||
|
if a():
|
||||||
|
a()
|
||||||
|
|
||||||
|
|
||||||
|
#: E301+3:4
|
||||||
|
def a():
|
||||||
|
x = 1
|
||||||
|
def b():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
#: E301+3:4 E301+5:8
|
||||||
|
def a():
|
||||||
|
x = 2
|
||||||
|
def b():
|
||||||
|
x = 1
|
||||||
|
def c():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
#: E301+4 E301+6
|
||||||
|
def a():
|
||||||
|
x = 1
|
||||||
|
class C:
|
||||||
|
pass
|
||||||
|
x = 2
|
||||||
|
def b():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
#: E302+7
|
||||||
|
# Example from https://github.com/PyCQA/pycodestyle/issues/400
|
||||||
|
foo = 2
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
blah, blah
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
||||||
|
|
||||||
|
# Previously just E272+1:5 E272+4:5
|
||||||
|
#: E302+3 E221:5 E221+3:5
|
||||||
|
async def x():
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def x(y: int = 1):
|
||||||
|
pass
|
||||||
168
test/normalizer_issue_files/E30not.py
Normal file
168
test/normalizer_issue_files/E30not.py
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
# Okay
|
||||||
|
class X:
|
||||||
|
pass
|
||||||
|
# Okay
|
||||||
|
|
||||||
|
def foo():
|
||||||
|
pass
|
||||||
|
# Okay
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
class X:
|
||||||
|
pass
|
||||||
|
# Okay
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
def foo():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# Okay
|
||||||
|
class X:
|
||||||
|
|
||||||
|
def a():
|
||||||
|
pass
|
||||||
|
|
||||||
|
# comment
|
||||||
|
def b():
|
||||||
|
pass
|
||||||
|
|
||||||
|
# This is a
|
||||||
|
# ... multi-line comment
|
||||||
|
|
||||||
|
def c():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# This is a
|
||||||
|
# ... multi-line comment
|
||||||
|
|
||||||
|
@some_decorator
|
||||||
|
class Y:
|
||||||
|
|
||||||
|
def a():
|
||||||
|
pass
|
||||||
|
|
||||||
|
# comment
|
||||||
|
|
||||||
|
def b():
|
||||||
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def c():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
from nonexistent import Bar
|
||||||
|
except ImportError:
|
||||||
|
class Bar(object):
|
||||||
|
"""This is a Bar replacement"""
|
||||||
|
|
||||||
|
|
||||||
|
def with_feature(f):
|
||||||
|
"""Some decorator"""
|
||||||
|
wrapper = f
|
||||||
|
if has_this_feature(f):
|
||||||
|
def wrapper(*args):
|
||||||
|
call_feature(args[0])
|
||||||
|
return f(*args)
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
next
|
||||||
|
except NameError:
|
||||||
|
def next(iterator, default):
|
||||||
|
for item in iterator:
|
||||||
|
return item
|
||||||
|
return default
|
||||||
|
|
||||||
|
|
||||||
|
def a():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Foo():
|
||||||
|
"""Class Foo"""
|
||||||
|
|
||||||
|
def b():
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# comment
|
||||||
|
def c():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# comment
|
||||||
|
|
||||||
|
|
||||||
|
def d():
|
||||||
|
pass
|
||||||
|
|
||||||
|
# This is a
|
||||||
|
# ... multi-line comment
|
||||||
|
|
||||||
|
# And this one is
|
||||||
|
# ... a second paragraph
|
||||||
|
# ... which spans on 3 lines
|
||||||
|
|
||||||
|
|
||||||
|
# Function `e` is below
|
||||||
|
# NOTE: Hey this is a testcase
|
||||||
|
|
||||||
|
def e():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def a():
|
||||||
|
print
|
||||||
|
|
||||||
|
# comment
|
||||||
|
|
||||||
|
print
|
||||||
|
|
||||||
|
print
|
||||||
|
|
||||||
|
# Comment 1
|
||||||
|
|
||||||
|
# Comment 2
|
||||||
|
|
||||||
|
|
||||||
|
# Comment 3
|
||||||
|
|
||||||
|
def b():
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# Okay
|
||||||
|
def foo():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def bar():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Foo(object):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Bar(object):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
foo()
|
||||||
|
# Okay
|
||||||
|
classification_errors = None
|
||||||
|
# Okay
|
||||||
|
defined_properly = True
|
||||||
|
# Okay
|
||||||
|
defaults = {}
|
||||||
|
defaults.update({})
|
||||||
|
# Okay
|
||||||
|
def foo(x):
|
||||||
|
classification = x
|
||||||
|
definitely = not classification
|
||||||
Reference in New Issue
Block a user