Skip to content

Commit 5b5385c

Browse files
author
StunxFS
committed
chore: format python code
1 parent 5f79325 commit 5b5385c

File tree

5 files changed

+45
-27
lines changed

5 files changed

+45
-27
lines changed

rivetc/src/checker.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,8 +1210,9 @@ def check_expr(self, expr):
12101210
f"instead of using tuple indexing, use array indexing: `expr[{expr.field_name}]`"
12111211
)
12121212
expr.left_typ = left_typ
1213-
if isinstance(expr.left_typ, type.Ptr) and expr.left_typ.nr_level(
1214-
) > 1 and not expr.is_indirect:
1213+
if isinstance(
1214+
expr.left_typ, type.Ptr
1215+
) and expr.left_typ.nr_level() > 1 and not expr.is_indirect:
12151216
report.error(
12161217
"fields of an multi-level pointer cannot be accessed directly",
12171218
expr.pos
@@ -1274,10 +1275,17 @@ def check_expr(self, expr):
12741275
elif isinstance(self.cur_fn.ret_typ, type.Result):
12751276
expr_typ = self.check_expr(expr.expr)
12761277
expr_typ_sym = expr_typ.symbol()
1277-
if not (expr_typ_sym.implement_trait(
1278-
self.comp.throwable_sym) or expr_typ_sym == self.comp.throwable_sym):
1279-
report.error("using an invalid value as an error to throw", expr.expr.pos)
1280-
report.note(f"in order to use that value, type `{expr_typ}` should implement the `Throwable` trait")
1278+
if not (
1279+
expr_typ_sym.implement_trait(self.comp.throwable_sym)
1280+
or expr_typ_sym == self.comp.throwable_sym
1281+
):
1282+
report.error(
1283+
"using an invalid value as an error to throw",
1284+
expr.expr.pos
1285+
)
1286+
report.note(
1287+
f"in order to use that value, type `{expr_typ}` should implement the `Throwable` trait"
1288+
)
12811289
report.note(
12821290
f"in throw argument of {self.cur_fn.typeof()} `{self.cur_fn.name}`"
12831291
)
@@ -1286,7 +1294,9 @@ def check_expr(self, expr):
12861294
f"{self.cur_fn.typeof()} `{self.cur_fn.name}` cannot throw errors",
12871295
expr.expr.pos
12881296
)
1289-
report.note("if you want to throw errors, add `!` in front of the return type")
1297+
report.note(
1298+
"if you want to throw errors, add `!` in front of the return type"
1299+
)
12901300
expr.typ = self.comp.never_t
12911301
return expr.typ
12921302
elif isinstance(expr, ast.Block):

rivetc/src/codegen/__init__.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,11 +1327,11 @@ def gen_expr(self, expr, custom_tmp = None):
13271327
args.append(self.gen_expr_with_cast(arg.typ, arg.expr))
13281328
else:
13291329
var_arg = expr.sym.args[-1]
1330-
if variadic_count == 1 and len(
1331-
expr.args
1332-
) > 0 and isinstance(
1333-
expr.args[-1].expr.typ, type.Variadic
1334-
):
1330+
if variadic_count == 1 and len(expr.args
1331+
) > 0 and isinstance(
1332+
expr.args[-1].expr.typ,
1333+
type.Variadic
1334+
):
13351335
arg = expr.args[-1]
13361336
args.append(self.gen_expr_with_cast(arg.typ, arg.expr))
13371337
elif variadic_count > 0:
@@ -1445,8 +1445,8 @@ def gen_expr(self, expr, custom_tmp = None):
14451445
ir.Name("err")
14461446
),
14471447
ir.Selector(
1448-
self.ir_type(self.comp.throwable_t), res_value,
1449-
ir.Name("err")
1448+
self.ir_type(self.comp.throwable_t),
1449+
res_value, ir.Name("err")
14501450
)
14511451
)
14521452
self.cur_fn.add_ret(tmp2)
@@ -1467,10 +1467,11 @@ def gen_expr(self, expr, custom_tmp = None):
14671467
expr.err_handler.varname, err_ir_name
14681468
)
14691469
self.cur_fn.inline_alloca(
1470-
self.ir_type(self.comp.throwable_t), err_ir_name,
1470+
self.ir_type(self.comp.throwable_t),
1471+
err_ir_name,
14711472
ir.Selector(
1472-
self.ir_type(self.comp.throwable_t), res_value,
1473-
ir.Name("err")
1473+
self.ir_type(self.comp.throwable_t),
1474+
res_value, ir.Name("err")
14741475
)
14751476
)
14761477
if err_handler_is_void:
@@ -2376,8 +2377,7 @@ def gen_expr(self, expr, custom_tmp = None):
23762377
self.gen_expr(expr.expr)
23772378
)
23782379
self.gen_defer_stmts(
2379-
True,
2380-
ir.Selector(ir.BOOL_T, expr_, ir.Name("is_err"))
2380+
True, ir.Selector(ir.BOOL_T, expr_, ir.Name("is_err"))
23812381
)
23822382
self.cur_fn.add_ret(expr_)
23832383
return ir.Skip()
@@ -2503,8 +2503,9 @@ def result_error(self, typ, expr_t, expr):
25032503
ir.IntLit(ir.BOOL_T, "1")
25042504
)
25052505
self.cur_fn.store(
2506-
ir.Selector(self.ir_type(self.comp.throwable_t), tmp, ir.Name("err")),
2507-
self.trait_value(expr, expr_t, self.comp.throwable_t)
2506+
ir.Selector(
2507+
self.ir_type(self.comp.throwable_t), tmp, ir.Name("err")
2508+
), self.trait_value(expr, expr_t, self.comp.throwable_t)
25082509
)
25092510
return tmp
25102511

@@ -2864,7 +2865,9 @@ def ir_type(self, typ, gen_self_arg = False):
28642865
if is_void else self.ir_type(typ.typ)
28652866
),
28662867
ir.Field("is_err", ir.BOOL_T),
2867-
ir.Field("err", self.ir_type(self.comp.throwable_t))
2868+
ir.Field(
2869+
"err", self.ir_type(self.comp.throwable_t)
2870+
)
28682871
]
28692872
)
28702873
)

rivetc/src/codegen/c.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
'auto', 'bool', 'case', 'char', 'complex', 'default', 'delete', 'do',
1919
'double', 'export', 'float', 'goto', 'inline', 'int', 'long', 'namespace',
2020
'new', 'register', 'restrict', 'short', 'signed', 'sizeof', 'small',
21-
'static', 'typedef', 'typename', 'union', 'unsigned', 'void',
22-
'volatile', 'template', 'far', 'near', 'huge', 'linux', 'unix'
21+
'static', 'typedef', 'typename', 'union', 'unsigned', 'void', 'volatile',
22+
'template', 'far', 'near', 'huge', 'linux', 'unix'
2323
]
2424

2525
def c_escape(kw):

tests/run_b_invalid_tests.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ def run_fail_tests():
4141
if fail > 0:
4242
utils.eprint(utils.bold(utils.red(f"{fail} failed")) + ", ", end = "")
4343
if skip > 0:
44-
utils.eprint(utils.bold(utils.yellow(f"{skip} skipped")) + ", ", end = "")
44+
utils.eprint(
45+
utils.bold(utils.yellow(f"{skip} skipped")) + ", ", end = ""
46+
)
4547
utils.eprint(utils.bold(f"{len(FAIL_FILES)} total."))
4648

4749
return exit_code

tests/run_invalid_tests.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def run_fail_tests():
3434
utils.eprint("Exit code: 0")
3535
except FileNotFoundError:
3636
utils.eprint(
37-
start, file, utils.bold(utils.yellow("-> SKIP (.out file not found)"))
37+
start, file,
38+
utils.bold(utils.yellow("-> SKIP (.out file not found)"))
3839
)
3940
skip += 1
4041
utils.eprint(utils.bold("Summary for all tests: "), end = "")
@@ -43,7 +44,9 @@ def run_fail_tests():
4344
if fail > 0:
4445
utils.eprint(utils.bold(utils.red(f"{fail} failed")) + ", ", end = "")
4546
if skip > 0:
46-
utils.eprint(utils.bold(utils.yellow(f"{skip} skipped")) + ", ", end = "")
47+
utils.eprint(
48+
utils.bold(utils.yellow(f"{skip} skipped")) + ", ", end = ""
49+
)
4750
utils.eprint(utils.bold(f"{len(FAIL_FILES)} total."))
4851

4952
return exit_code

0 commit comments

Comments
 (0)