Sindbad~EG File Manager
a
��g<] � @ s
d dl Z d dlZd dlZd dlmZmZmZmZ d dl m
Z
d dlmZ g d�Z
g d�Zg d�Zg d�Zd d
dd�Zg d
�Zeed�dd�Zeeeeeee f f eee ee f d�dd�Zee
�\ZZee�\ZZee�\ZZee�\ZZG dd� dej�ZdS )� N)�Any�Union�Iterable�Tuple)�dedent)�support( )Zannotated_assignmentzx: int = 42)Zannotated_assignment_with_tuplezx: tuple = 1, 2)Z annotated_assignment_with_parensz(paren): int = 3+2)Zannotated_assignment_with_yieldzx: int = yield 42)Zannotated_no_assignmentzx: int)Zannotation_with_multiple_parensz((parens)): int)Zannotation_with_parensz
(parens): int)Zannotated_assignment_with_attrza.b: int)Z#annotated_assignment_with_subscriptz a[b]: int)Z)annotated_assignment_with_attr_and_parensz
(a.b): int)Z.annotated_assignment_with_subscript_and_parensz(a[b]): int)�assertzassert a)Zassert_messagezassert a, b)Zassignment_falsez a = False)Zassignment_noneza = None)Zassignment_trueza = True)Zassignment_parenz(a) = 42)Zassignment_paren_multiplez(a, b) = (0, 1))Zasyncforz1
async for i in a:
pass
)Zattribute_callza.b())Zattribute_multiple_nameszabcd.efg.hij)Zattribute_simpleza.b)Zattributes_subscriptza.b[0])Zaugmented_assignmentzx += 42)Zaugmented_assignment_attributeza.b.c += 42)Zaugmented_assignment_parenz (x) += 42)Z$augmented_assignment_paren_subscriptz(x[0]) -= 42)Z binop_addz1 + 1)Zbinop_add_multiplez
1 + 1 + 1 + 1)Z binop_allz1 + 2 * 5 + 3 ** 2 - -3)Zbinop_boolop_compz"1 + 1 == 2 or 1 + 1 == 3 and not b)Z boolop_orza or b)Zboolop_or_multipleza or b or c)Zclass_def_basesz.
class C(A, B):
pass
)Zclass_def_decoratorsz3
@a
class C:
pass
)Z#class_def_decorator_with_expressionz>
@lambda x: 42
class C:
pass
)Z.class_def_decorator_with_expression_and_walruszA
@x:=lambda x: 42
class C:
pass
)Zclass_def_keywordsz:
class C(keyword=a+b, **c):
pass
)Zclass_def_mixedz>
class C(A, B, keyword=0, **a):
pass
)Zclass_def_simplez(
class C:
pass
)Zclass_def_starred_and_kwargz7
class C(A, B, *x, **y):
pass
)Zclass_def_starred_in_kwargsz>
class C(A, x=2, *[B, C], y=3):
pass
)Zcall_attributezf().b)Zcall_genexpzf(i for i in a))Zcall_mixed_argszf(a, b, *c, **d))Zcall_mixed_args_namedzf(a, b, *c, d=4, **v))Zcall_one_argzf(a))Zcall_posarg_genexpzf(a, (i for i in a)))Zcall_simplezf())Zcall_subscriptzf()[0])�compza == b)Z
comp_multipleza == b == c)Zcomp_paren_endz
a == (b-1))Zcomp_paren_startz
(a-1) == b)� decoratorz3
@a
def f():
pass
)Zdecorator_asyncz9
@a
async def d():
pass
)Zdecorator_with_expressionz>
@lambda x: 42
def f():
pass
)Z$decorator_with_expression_and_walruszA
@x:=lambda x: 42
def f():
pass
)Z
del_attributezdel a.b)Zdel_call_attributez del a().c)Zdel_call_genexp_attributezdel a(i for i in b).c)Z del_emptyzdel())Zdel_listz
del a, [b, c])Z del_mixedzdel a[0].b().c)Zdel_multiplezdel a, b)Zdel_multiple_calls_attributezdel a()().b)Z del_parenzdel(a,b))Zdel_paren_single_targetzdel(a))Zdel_subscript_attributez
del a[0].b)Z del_tuplez
del a, (b, c))�deletezdel a)�dictzO
{
a: 1,
b: 2,
c: 3
}
)Z dict_compz{x:1 for x in a})Zdict_comp_ifz{x:1+2 for x in a if b})Z
dict_emptyz{})Zempty_line_after_linecontz+
pass
\
pass
)�forz+
for i in a:
pass
)Zfor_elsezJ
for i in a:
pass
else:
pass
)Zfor_star_target_in_parenzfor (a) in b: pass)Zfor_star_targets_attributezfor a.b in c: pass)Zfor_star_targets_call_attributezfor a().c in b: pass)Zfor_star_targets_emptyzfor () in a: pass)Zfor_star_targets_mixedzfor a[0].b().c in d: pass)Zfor_star_targets_mixed_starredz7
for a, *b, (c, d) in e:
pass
)Zfor_star_targets_multiplezfor a, b in c: pass)Zfor_star_targets_nested_starredzfor *[*a] in b: pass)Zfor_star_targets_starredzfor *a in b: pass)Z$for_star_targets_subscript_attributezfor a[0].b in c: pass)Zfor_star_targets_trailing_commaz4
for a, (b, c), in d:
pass
)Zfor_star_targets_tuplezfor a, (b, c) in d: pass)Zfor_underscorez+
for _ in a:
pass
)Zfunction_return_typez/
def f() -> Any:
pass
)zf-string_slicez f'{x[2]}')zf-string_slice_upperzf'{x[2:3]}')zf-string_slice_stepzf'{x[2:3:-2]}')zf-string_constantzf'{42}')zf-string_boolopzf'{x and y}')zf-string_named_exprzf'{(x:=42)}')zf-string_binopzf'{x+y}')zf-string_unaryopz
f'{not x}')�f-string_lambdaz6f'{(lambda x, /, y, y2=42 , *z, k1, k2=34, **k3: 42)}')zf-string_lambda_callzf'{(lambda: 2)(2)}')zf-string_ifexprzf'{x if y else z}')z
f-string_dictzf'{ {2:34, 3:34} }')zf-string_setzf'{ {2,-45} }')z
f-string_listzf'{ [2,-45] }')zf-string_tuplezf'{ (2,-45) }')zf-string_listcompzf'{[x for x in y if z]}')zf-string_setcompzf'{ {x for x in y if z} }')zf-string_dictcompzf'{ {x:x for x in y if z} }')zf-string_genexprzf'{ (x for x in y if z) }')zf-string_yieldzf'{ (yield x) }')zf-string_yieldfromzf'{ (yield from x) }')zf-string_awaitzf'{ await x }')zf-string_comparez
f'{ x == y }')z
f-string_callzf'{ f(x,y,z) }')zf-string_attributezf'{ f.x.y.z }')zf-string_starredz
f'{ *x, }')zf-string_doublestarredzf'{ {**x} }')zf-string_escape_bracezf'{{Escape')zf-string_escape_closing_bracezf'Escape}}')zf-string_multilinez/
f'''
{hello}
'''
)zf-string_multiline_in_exprzA
f'''
{
hello
}
'''
)zf-string_multiline_in_callzJ
f'''
{f(
a, b, c
)}
'''
)�globalzglobal a, b)�groupz (yield a))Zif_elifzF
if a:
pass
elif b:
pass
)Zif_elif_elifzg
if a:
pass
elif b:
pass
elif c:
pass
)Zif_elif_elsezd
if a:
pass
elif b:
pass
else:
pass
)Zif_elsezD
if a:
pass
else:
pass
)Z if_simplez
if a: pass)�importzimport a)Zimport_aliasz
import a as b)Z
import_dottedz
import a.b)Zimport_dotted_aliaszimport a.b as c)Zimport_dotted_multicharzimport ab.cd)Zimport_fromzfrom a import b)Zimport_from_aliaszfrom a import b as c)Zimport_from_dottedzfrom a.b import c)Zimport_from_dotted_aliaszfrom a.b import c as d)Zimport_from_multiple_aliaseszfrom a import b as c, d as e)Zimport_from_one_dotzfrom .a import b)Zimport_from_one_dot_aliaszfrom .a import b as c)Zimport_from_starzfrom a import *)Zimport_from_three_dotszfrom ...a import b)Zimport_from_trailing_commazfrom a import (b,))�kwargz+
def f(**a):
pass
)Zkwonly_argsz/
def f(*, a, b):
pass
)Zkwonly_args_with_defaultz1
def f(*, a=2, b):
pass
)Zlambda_kwargzlambda **a: 42)Zlambda_kwonly_argszlambda *, a, b: 42)Zlambda_kwonly_args_with_defaultzlambda *, a=2, b: 42)Zlambda_mixed_argszlambda a, /, b, *, c: 42)Zlambda_mixed_args_with_defaultz%lambda a, b=2, /, c=3, *e, f, **g: 42)Zlambda_no_argsz
lambda: 42)Zlambda_pos_argszlambda a,b: 42)Zlambda_pos_args_with_defaultzlambda a, b=2: 42)Zlambda_pos_only_argszlambda a, /: 42)Z!lambda_pos_only_args_with_defaultzlambda a=0, /: 42)Zlambda_pos_posonly_argszlambda a, b, /, c, d: 42)Z$lambda_pos_posonly_args_with_defaultzlambda a, b=0, /, c=2: 42)Z
lambda_varargz
lambda *a: 42)Zlambda_vararg_kwonly_argszlambda *a, b: 42)�listz [1, 2, a])Z list_compz[i for i in a])Zlist_comp_ifz[i for i in a if b])Zlist_trailing_commaz[1+2, a, 3+4,])Z
mixed_argsz5
def f(a, /, b, *, c):
pass
)Zmixed_args_with_defaultzB
def f(a, b=2, /, c=3, *e, f, **g):
pass
)Zmultipart_string_byteszb"Hola" b"Hello" b"Bye")Zmultipart_string_triplez"""Something here""" "and now")Z#multipart_string_different_prefixesz(u"Something" "Other thing" r"last thing")Zmultiple_assignmentszx = y = z = 42)Zmultiple_assignments_with_yieldzx = y = z = yield 42)Z
multiple_passz&
pass; pass
pass
)Z namedexprz(x := [1, 2, 3]))Znamedexpr_falsez(x := False))Znamedexpr_nonez(x := None))Znamedexpr_truez(x := True))�nonlocalz
nonlocal a, b)Znumber_complexz -2.234+1j)Znumber_floatz-34.2333)Znumber_imaginary_literalz1.1234j)Znumber_integerz-234)Znumber_underscoresZ 1_234_567)�passr )Zpos_argsz,
def f(a, b):
pass
)Zpos_args_with_defaultz.
def f(a, b=2):
pass
)Z
pos_only_argsz,
def f(a, /):
pass
)Zpos_only_args_with_defaultz.
def f(a=0, /):
pass
)Zpos_posonly_argsz5
def f(a, b, /, c, d):
pass
)Zpos_posonly_args_with_defaultz6
def f(a, b=0, /, c=2):
pass
)Z
primary_mixedza.b.c().d[0])�raiser )Zraise_ellipsisz raise ...)Z
raise_exprzraise a)Z
raise_fromzraise a from b)�returnr )Zreturn_exprzreturn a)�setz
{1, 2+4, 3+5})Zset_compz{i for i in a})Zset_trailing_commaz
{1, 2, 3,})Zsimple_assignmentzx = 42)Zsimple_assignment_with_yieldzx = yield 42)Zstring_byteszb"hello")Zstring_concatenation_byteszb"hello" b"world")Zstring_concatenation_simplez
"abcd" "efgh")Zstring_format_simplezf"hello")Z"string_format_with_formatted_valuezf"hello {world}")Z
string_simplez"hello")Zstring_unicodezu"hello")Zsubscript_attributeza[0].b)Zsubscript_callza[b]())Zsubscript_multiple_slicesza[0:a:2, 1])Zsubscript_simpleza[0])Zsubscript_single_element_tupleza[0,])Zsubscript_trailing_commaza[0, 1, 2,])Zsubscript_tuplez
a[0, 1, 2])Zsubscript_whole_slicez
a[0+1:b:c])Z
try_exceptzE
try:
pass
except:
pass
)Ztry_except_elsezd
try:
pass
except:
pass
else:
pass
)Ztry_except_else_finallyz�
try:
pass
except:
pass
else:
pass
finally:
pass
)Ztry_except_exprzG
try:
pass
except a:
pass
)Ztry_except_expr_targetzL
try:
pass
except a as b:
pass
)Ztry_except_finallyzg
try:
pass
except:
pass
finally:
pass
)Ztry_finallyzF
try:
pass
finally:
pass
)Zunpacking_binopz[*([1, 2, 3] + [3, 4, 5])])Zunpacking_callz[*b()])Zunpacking_comparez
[*(x < y)])Zunpacking_constantz[*3])Zunpacking_dictz[*{1: 2, 3: 4}])Zunpacking_dict_comprehensionz[*{x:y for x,y in z}])Zunpacking_ifexprz[*([1, 2, 3] if x else y)])Zunpacking_listz
[*[1,2,3]])Zunpacking_list_comprehensionz[*[x for x in y]])Zunpacking_namedexprz[*(x:=[1, 2, 3])])Z
unpacking_setz
[*{1,2,3}])Zunpacking_set_comprehensionz[*{x for x in y}])Zunpacking_stringz[*"myvalue"])Zunpacking_tuplez
[*(1,2,3)])Zunpacking_unaryopz[*(not [1, 2, 3])])Zunpacking_yieldz
[*(yield 42)])Zunpacking_yieldfromz[*(yield from x)])�tuplez (1, 2, 3))�varargz*
def f(*a):
pass
)Zvararg_kwonly_argsz-
def f(*a, b):
pass
)�whilez(
while a:
pass
)Z
while_elsezG
while a:
pass
else:
pass
)�withz'
with a:
pass
)Zwith_asz,
with a as b:
pass
)Z
with_as_parenz.
with a as (b):
pass
)Z
with_as_emptyzwith a as (): pass)Zwith_list_recursivez6
with a as [x, [y, z]]:
pass
)Zwith_tuple_recursivez6
with a as ((x, y), z):
pass
)Zwith_tuple_targetz1
with a as (x, y):
pass
)Zwith_list_targetz1
with a as [x, y]:
pass
)�yieldr )Z
yield_exprzyield a)Z
yield_fromzyield from a)#)Zannotation_multiple_targetsz(a, b): int = 42)Zannotation_nested_tuplez
((a, b)): int)Zannotation_listz[a]: int)Zannotation_lambdazlambda: int = 42)Zannotation_tuplez (a,): int)Zannotation_tuple_without_parenza,: int)Zassignment_keywordza = if)Zaugmented_assignment_listz[a, b] += 1)Zaugmented_assignment_tuplez a, b += 1)Z augmented_assignment_tuple_parenz(a, b) += (1, 2))Zcomprehension_lambdaz(a for a in lambda: b))Zcomprehension_elsez(a for a in b if c else d)Zdel_callzdel a())Zdel_call_genexpzdel a(i for i in b))Zdel_subscript_callz
del a[b]())Zdel_attribute_callz del a.b())Zdel_mixed_callzdel a[0].b().c.d())Zfor_star_targets_callzfor a() in b: pass)Zfor_star_targets_subscript_callzfor a[b]() in c: pass)Zfor_star_targets_attribute_callzfor a.b() in c: pass)Zfor_star_targets_mixed_callzfor a[0].b().c.d() in e: pass)Zfor_star_targets_inzfor a, in in b: pass)zf-string_assignmentzf'{x = 42}')zf-string_emptyzf'{}')zf-string_function_defzf'{def f(): pass}')r zf'{lambda x: 42}')zf-string_singe_bracezf'{')zf-string_single_closing_bracezf'}')Zfrom_import_invalidzfrom import import a)Zfrom_import_trailing_commazfrom a import b,)Zimport_non_ascii_syntax_erroru import ä £)zinvalid indentationz.
def f():
a
a
)Znot_terminated_stringza = 'example)Ztry_except_attribute_targetzJ
try:
pass
except Exception as a.b:
pass
)Ztry_except_subscript_targetzK
try:
pass
except Exception as a[0]:
pass
))zf(x, y, z=1, **b, *az>iterable argument unpacking follows keyword argument unpacking)zf(x, y=1, *z, **a, bz6positional argument follows keyword argument unpacking)zf(x, y, z=1, a=2, bz,positional argument follows keyword argument)zTrue = 1zcannot assign to True)za() = 1zcannot assign to function call)z(a, b): intz/only single target (not tuple) can be annotated)z[a, b]: intz.only single target (not list) can be annotated)za(): intzillegal target for annotation)z1 += 1z;'literal' is an illegal expression for augmented assignment)z
pass
passzunexpected indent)z
def f():
passzexpected an indented block)zdef f(*): pass�"named arguments must follow bare *)zdef f(*,): passr )zdef f(*, **a): passr )zlambda *: passr )zlambda *,: passr )zlambda *, **a: passr )zf(g()=2�=expression cannot contain assignment, perhaps you meant "=="?)zf(a, b, *c, d.e=2r )zf(*a, **b, c=0, d[1]=3)r ))Zstring_concatenation_formatz%f"{hello} world" f"again {and_again}")Zstring_concatenation_multiplez5
f"hello" f"{world} again" f"and_again"
)zf-string_multiline_compzI
f'''
{(i for i in a
if b)}
'''
)z<
f'''
{a$b}
'''
z(a$b)
)z<
f'''
{a$b
}'''
z(a$b
)z<
f'''
{
a$b}'''
za$b)
)Z'multiline_fstrings_same_line_with_braceZ$multiline_fstring_brace_on_next_lineZ(multiline_fstring_brace_on_previous_line))Zexpression_addz1+1)Zexpression_add_2za+b)Zexpression_callzf(a, b=2, **kw))Zexpression_tuplez1, 2, 3)Zexpression_tuple_one_valuez1,)�sourcer c C s@ t | t�rt| �}n(t | ttf�s.d�| �}ntd| � ���|S )N�
zInvalid type for test source: )�
isinstance�strr r r �join� TypeError)r �result� r'