Skip to content

Commit 1c6ac9d

Browse files
committed
Use max line length.
1 parent 6328d02 commit 1c6ac9d

38 files changed

+213
-99
lines changed

ppci/arch/encoding.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,15 @@ def __init__(self, *args, **kwargs):
140140
# Set parameters:
141141
if len(args) != len(formal_args):
142142
raise TypeError(
143-
f"{len(args)} arguments given, but {self.__class__} expects {len(formal_args)}"
143+
f"{len(args)} arguments given, but "
144+
+ f"{self.__class__} expects {len(formal_args)}"
144145
)
145146
for farg, arg in zip(formal_args, args):
146147
if not isinstance(arg, farg._cls): # pragma: no cover
147148
# Create some nice looking error:
148149
raise TypeError(
149-
f'{type(self)} expected {farg._cls}, but got "{arg}" of type {type(arg)}'
150+
f"{type(self)} expected {farg._cls}, "
151+
+ f'but got "{arg}" of type {type(arg)}'
150152
)
151153
setattr(self, farg._name, arg)
152154

ppci/arch/jvm/nodes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ def __init__(self, opcode, args):
129129
self.args = args
130130

131131
def __repr__(self):
132-
return f"instruction(opcode={self.mnemonic} (0x{self.opcode:0X}), args={self.args})"
132+
return (
133+
f"instruction(opcode={self.mnemonic} (0x{self.opcode:0X}), "
134+
+ f"args={self.args})"
135+
)
133136

134137

135138
class Manifest:

ppci/binutils/dbg/cli.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,16 @@ def print_file_line(stdout, filename, lineno):
6161
elif i > len(lines):
6262
stdout.write("\n")
6363
elif i == lineno:
64-
s = f"\033[33m\033[1m{str(i).rjust(4)}\033[32m->{lines[i - 1]}\033[0m\033[39m\n"
64+
s = (
65+
f"\033[33m\033[1m{str(i).rjust(4)}\033[32m->"
66+
+ f"{lines[i - 1]}\033[0m\033[39m\n"
67+
)
6568
stdout.write(s)
6669
else:
67-
s = f"\033[33m\033[1m{str(i).rjust(4)}\033[0m\033[39m {lines[i - 1]}\n"
70+
s = (
71+
f"\033[33m\033[1m{str(i).rjust(4)}\033[0m\033[39m "
72+
+ f"{lines[i - 1]}\n"
73+
)
6874
stdout.write(s)
6975

7076

ppci/binutils/dbg/ptcli.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
# Check version of prompt toolkit:
88
if not ptk_version.startswith("3."):
9-
print(
10-
f"We require prompt toolkit version 3.x, we currently have: {ptk_version}"
11-
)
9+
print(f"We require prompt toolkit 3.x, we have: {ptk_version}")
1210

1311
from prompt_toolkit import Application
1412
from prompt_toolkit.buffer import Buffer

ppci/binutils/debuginfo.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,10 @@ def __init__(
229229
self.variables = list(variables)
230230

231231
def __repr__(self):
232-
return f"DBGFNC[ {self.name} {self.loc} begin={self.begin}, end={self.end} ]"
232+
return (
233+
f"DBGFNC[ {self.name} {self.loc} "
234+
+ f"begin={self.begin}, end={self.end} ]"
235+
)
233236

234237
def add_variable(self, variable):
235238
self.variables.append(variable)

ppci/binutils/objectfile.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ def is_function(self):
6363
return self.typ == "func"
6464

6565
def __repr__(self):
66-
return f"Symbol({self.name}, binding={self.binding}, val={self.value} section={self.section} typ={self.typ} size={self.size})"
66+
return (
67+
f"Symbol({self.name}, binding={self.binding}, "
68+
+ f"val={self.value} section={self.section} "
69+
+ f"typ={self.typ} size={self.size})"
70+
)
6771

6872
def __eq__(self, other):
6973
return (
@@ -125,7 +129,10 @@ def size(self):
125129
return len(self.data)
126130

127131
def __repr__(self):
128-
return f"SECTION {self.name} size=0x{self.size:x} address=0x{self.address:x}"
132+
return (
133+
f"SECTION {self.name} size=0x{self.size:x} "
134+
+ f"address=0x{self.address:x}"
135+
)
129136

130137
def __eq__(self, other):
131138
return (

ppci/cli/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
from ..utils.reporting import TextReportGenerator
1313

1414

15-
version_text = f"ppci {__version__} on {platform.python_implementation()} {platform.python_version()} on {platform.platform()}"
15+
version_text = (
16+
f"ppci {__version__}"
17+
+ f" on {platform.python_implementation()} {platform.python_version()}"
18+
+ f" on {platform.platform()}"
19+
)
1620

1721

1822
def log_level(s):

ppci/codegen/burg.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,8 @@ def emit_record(self, rule, state_var):
343343
)
344344
self.print(
345345
4,
346-
(
347-
f"c = sum(x.state.get_cost(y) for x, y in zip(kids, nts)) + {rule.cost}"
348-
),
346+
"c = sum(x.state.get_cost(y) for x, y in zip(kids, nts)) "
347+
+ f"+ {rule.cost}",
349348
)
350349
self.print(
351350
4,
@@ -355,7 +354,8 @@ def emit_record(self, rule, state_var):
355354
self.print(4, f"# Chain rule: {cr}")
356355
self.print(
357356
4,
358-
f'tree.state.set_cost("{cr.non_term}", c + {cr.cost}, {cr.nr})',
357+
f'tree.state.set_cost("{cr.non_term}", c'
358+
+ f" + {cr.cost}, {cr.nr})",
359359
)
360360

361361
def emit_state(self):

ppci/codegen/registerallocator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def alloc_frame(self, frame: Frame):
264264
max_spill_rounds = 30
265265
if spill_rounds > max_spill_rounds:
266266
raise RuntimeError(
267-
f"Give up: more than {max_spill_rounds} spill rounds done!"
267+
f"Give up after {max_spill_rounds} spill rounds!"
268268
)
269269

270270
# Rewrite program now.
@@ -724,15 +724,15 @@ def rewrite_program(self, node):
724724
code = self.spill_gen.gen_load(self.frame, vreg2, slot)
725725
if self.verbose:
726726
self.reporter.message(
727-
f"Load code before instruction: {list(map(str, code))}"
727+
f"Load code before: {list(map(str, code))}"
728728
)
729729
self.frame.insert_code_before(instruction, code)
730730

731731
if instruction.writes_register(vreg2):
732732
code = self.spill_gen.gen_store(self.frame, vreg2, slot)
733733
if self.verbose:
734734
self.reporter.message(
735-
f"Store code after instruction: {list(map(str, code))}"
735+
f"Store code after: {list(map(str, code))}"
736736
)
737737
self.frame.insert_code_after(instruction, code)
738738

ppci/ir.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,10 @@ def stats(self):
223223
num_functions = len(self.functions)
224224
num_blocks = sum(len(f.blocks) for f in self.functions)
225225
num_instructions = sum(f.num_instructions() for f in self.functions)
226-
return f"functions: {num_functions}, blocks: {num_blocks}, instructions: {num_instructions}"
226+
return (
227+
f"functions: {num_functions}, blocks: {num_blocks}, "
228+
+ f"instructions: {num_instructions}"
229+
)
227230

228231

229232
class Value:
@@ -965,7 +968,10 @@ def __init__(self, a, operation, b, name, ty):
965968
self.operation = operation
966969

967970
def __str__(self):
968-
return f"{self.ty} {self.name} = {self.a.name} {self.operation} {self.b.name}"
971+
return (
972+
f"{self.ty} {self.name} = "
973+
+ f"{self.a.name} {self.operation} {self.b.name}"
974+
)
969975

970976

971977
def add(a, b, name, ty):
@@ -1059,7 +1065,10 @@ def __init__(self, name: str, amount: int, alignment: int):
10591065
self.alignment = alignment
10601066

10611067
def __str__(self):
1062-
return f"{self.ty} {self.name} = alloc {self.amount} bytes aligned at {self.alignment}"
1068+
return (
1069+
f"{self.ty} {self.name} = "
1070+
+ f"alloc {self.amount} bytes aligned at {self.alignment}"
1071+
)
10631072

10641073

10651074
class CopyBlob(Instruction):
@@ -1105,7 +1114,10 @@ def __init__(self, name, binding, amount, alignment, value=None):
11051114
self.value = value
11061115

11071116
def __str__(self):
1108-
return f"{self.binding} variable {self.name} ({self.amount} bytes aligned at {self.alignment})"
1117+
return (
1118+
f"{self.binding} variable {self.name} "
1119+
+ f"({self.amount} bytes aligned at {self.alignment})"
1120+
)
11091121

11101122

11111123
class Parameter(LocalValue):
@@ -1337,7 +1349,10 @@ def __init__(self, a, cond, b, lab_yes, lab_no):
13371349
self.lab_no = lab_no
13381350

13391351
def __str__(self):
1340-
return f"cjmp {self.a.name} {self.cond} {self.b.name} ? {self.lab_yes.name} : {self.lab_no.name}"
1352+
return (
1353+
f"cjmp {self.a.name} {self.cond} {self.b.name} ? "
1354+
+ f"{self.lab_yes.name} : {self.lab_no.name}"
1355+
)
13411356

13421357

13431358
class JumpTable(JumpBase):

0 commit comments

Comments
 (0)