Skip to content

Commit e93c816

Browse files
committed
Reformat the code with Ruff (./run format).
This reformats all the code with the Ruff Python formatter. pyproject.toml contains the configuration for the formatter.
1 parent 00d73a3 commit e93c816

File tree

10 files changed

+1227
-556
lines changed

10 files changed

+1227
-556
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.coverage
2+
.ruff_cache
23
build
34
dist
45
*.pyc

benchmarks/run.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
def main():
3636
parser = argparse.ArgumentParser()
3737
parser.add_argument('--pure', action='store_true')
38-
parser.add_argument('-n', '--num-iterations', default=DEFAULT_ITERATIONS,
39-
type=int)
38+
parser.add_argument(
39+
'-n', '--num-iterations', default=DEFAULT_ITERATIONS, type=int
40+
)
4041
parser.add_argument('benchmarks', nargs='*')
4142
args = parser.parse_args()
4243
if not args.benchmarks:
@@ -47,7 +48,6 @@ def main():
4748
with open(f, encoding='utf-8') as fp:
4849
file_contents.append(fp.read())
4950

50-
5151
# json.decoder.c_scanstring = py_scanstring
5252
def py_maker(*args, **kwargs):
5353
del args
@@ -81,20 +81,28 @@ def py_maker(*args, **kwargs):
8181
if json5_time and json_time:
8282
if json5_time > json_time:
8383
avg = json5_time / json_time
84-
print(f"{fname:-%20s}: JSON was {avg:5.1f}x faster "
85-
f"({json_time:.6f} to {json5_time:.6fs}")
84+
print(
85+
f'{fname:-%20s}: JSON was {avg:5.1f}x faster '
86+
f'({json_time:.6f} to {json5_time:.6fs}'
87+
)
8688
else:
8789
avg = json_time / json5_time
88-
print(f"{fname:-%20s}: JSON5 was {avg:5.1f}x faster "
89-
f"({json5_time:.6f} to {json_time:.6fs}")
90+
print(
91+
f'{fname:-%20s}: JSON5 was {avg:5.1f}x faster '
92+
f'({json5_time:.6f} to {json_time:.6fs}'
93+
)
9094
elif json5_time:
91-
print(f"{fname:-20s}: JSON5 took {json5_time:.6f} secs, "
92-
f"JSON was too fast to measure")
95+
print(
96+
f'{fname:-20s}: JSON5 took {json5_time:.6f} secs, '
97+
f'JSON was too fast to measure'
98+
)
9399
elif json_time:
94-
print(f"{fname:-20s}: JSON took {json_time:.6f} secs, "
95-
f"JSON5 was too fast to measure")
100+
print(
101+
f'{fname:-20s}: JSON took {json_time:.6f} secs, '
102+
f'JSON5 was too fast to measure'
103+
)
96104
else:
97-
print(f"{fname:-20s}: both were too fast to measure")
105+
print(f'{fname:-20s}: both were too fast to measure')
98106

99107
return 0
100108

json5/arg_parser.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ def __init__(self, host, prog, desc, **kwargs):
2929
super().__init__(**kwargs)
3030
self._host = host
3131
self.exit_status = None
32-
self.add_argument('-V', '--version', action='store_true',
33-
help='print the version and exit')
32+
self.add_argument(
33+
'-V',
34+
'--version',
35+
action='store_true',
36+
help='print the version and exit',
37+
)
3438

3539
def parse_args(self, args=None, namespace=None):
3640
try:
@@ -49,8 +53,7 @@ def print_help(self, file=None):
4953
def error(self, message, bailout=True):
5054
self.exit(2, f'{self.prog}: error: {message}\n', bailout=bailout)
5155

52-
def exit(self, status=0, message=None,
53-
bailout=True):
56+
def exit(self, status=0, message=None, bailout=True):
5457
self.exit_status = status
5558
if message:
5659
self._print_message(message, file=self._host.stderr)

0 commit comments

Comments
 (0)