Skip to content

Commit 82467f7

Browse files
committed
chore: ruff format .
1 parent 0a7b733 commit 82467f7

File tree

114 files changed

+6171
-3693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+6171
-3693
lines changed

benchmark/benchmark.py

Lines changed: 27 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ def run_command(self, cmd: str) -> str:
109109

110110
if proc.returncode != 0:
111111
self.print(f"ERROR: command returned {proc.returncode}")
112-
raise Exception(
113-
f"Command failed ({proc.returncode}): {cmd!r}, output was:\n{output}"
114-
)
112+
raise Exception(f"Command failed ({proc.returncode}): {cmd!r}, output was:\n{output}")
115113

116114
return output.strip()
117115

@@ -318,9 +316,7 @@ def run_with_coverage(self, env: Env, cov_ver: Coverage) -> float:
318316
with self.tweak_coverage_settings(cov_ver.tweaks):
319317
self.pre_check(env) # NOTE: Not properly factored, and only used from here.
320318
duration = self.run_tox(env, env.pyver.toxenv, "--skip-pkg-install")
321-
self.post_check(
322-
env
323-
) # NOTE: Not properly factored, and only used from here.
319+
self.post_check(env) # NOTE: Not properly factored, and only used from here.
324320
return duration
325321

326322

@@ -333,9 +329,7 @@ def run_with_coverage(self, env: Env, cov_ver: Coverage) -> float:
333329
raise Exception("This doesn't work because options changed to tweaks")
334330
covenv = env.pyver.toxenv + "-cov" # type: ignore[unreachable]
335331
self.run_tox(env, covenv, "--notest")
336-
env.shell.run_command(
337-
f".tox/{covenv}/bin/python -m pip install {cov_ver.pip_args}"
338-
)
332+
env.shell.run_command(f".tox/{covenv}/bin/python -m pip install {cov_ver.pip_args}")
339333
if cov_ver.tweaks:
340334
replace = ("# reference: https", f"[run]\n{cov_ver.tweaks}\n#")
341335
else:
@@ -499,9 +493,7 @@ def run_with_coverage(self, env: Env, cov_ver: Coverage) -> float:
499493
)
500494
with self.tweak_coverage_settings(cov_ver.tweaks):
501495
self.pre_check(env) # NOTE: Not properly factored, and only used here.
502-
duration = self.run_tox(
503-
env, env.pyver.toxenv, "--skip-pkg-install -- --cov"
504-
)
496+
duration = self.run_tox(env, env.pyver.toxenv, "--skip-pkg-install -- --cov")
505497
self.post_check(env) # NOTE: Not properly factored, and only used here.
506498
return duration
507499

@@ -542,9 +534,7 @@ def run_no_coverage(self, env: Env) -> float:
542534

543535
def run_with_coverage(self, env: Env, cov_ver: Coverage) -> float:
544536
env.shell.run_command(f"{env.python} -m pip install {cov_ver.pip_args}")
545-
env.shell.run_command(
546-
f"{env.python} -m coverage run -m unittest tests.test_suite"
547-
)
537+
env.shell.run_command(f"{env.python} -m coverage run -m unittest tests.test_suite")
548538
duration = env.shell.last_duration
549539
report = env.shell.run_command(f"{env.python} -m coverage report --precision=6")
550540
print("Results:", report.splitlines()[-1])
@@ -598,19 +588,21 @@ def run_with_coverage(self, env: Env, cov_ver: Coverage) -> float:
598588
class ProjectMypy(ToxProject):
599589
git_url = "https://github.com/python/mypy"
600590

601-
SLOW_TESTS = " or ".join([
602-
"PythonCmdline",
603-
"PEP561Suite",
604-
"PythonEvaluation",
605-
"testdaemon",
606-
"StubgenCmdLine",
607-
"StubgenPythonSuite",
608-
"TestRun",
609-
"TestRunMultiFile",
610-
"TestExternal",
611-
"TestCommandLine",
612-
"ErrorStreamSuite",
613-
])
591+
SLOW_TESTS = " or ".join(
592+
[
593+
"PythonCmdline",
594+
"PEP561Suite",
595+
"PythonEvaluation",
596+
"testdaemon",
597+
"StubgenCmdLine",
598+
"StubgenPythonSuite",
599+
"TestRun",
600+
"TestRunMultiFile",
601+
"TestExternal",
602+
"TestCommandLine",
603+
"ErrorStreamSuite",
604+
]
605+
)
614606

615607
FAST = f"-k 'not ({SLOW_TESTS})'"
616608

@@ -713,9 +705,7 @@ def tweak_toml_coverage_settings(toml_file: str, tweaks: TweaksType) -> Iterator
713705
class AdHocProject(ProjectToTest):
714706
"""A standalone program to run locally."""
715707

716-
def __init__(
717-
self, python_file: str, cur_dir: str | None = None, pip_args: str = ""
718-
):
708+
def __init__(self, python_file: str, cur_dir: str | None = None, pip_args: str = ""):
719709
super().__init__()
720710
self.python_file = Path(python_file)
721711
if not self.python_file.exists():
@@ -821,9 +811,7 @@ def __init__(self, slug: str = "nocov"):
821811
class CoveragePR(Coverage):
822812
"""A version of coverage.py from a pull request."""
823813

824-
def __init__(
825-
self, number: int, tweaks: TweaksType = None, env_vars: Env_VarsType = None
826-
):
814+
def __init__(self, number: int, tweaks: TweaksType = None, env_vars: Env_VarsType = None):
827815
url = f"https://github.com/nedbat/coveragepy.git@refs/pull/{number}/merge"
828816
url_must_exist(url)
829817
super().__init__(
@@ -837,9 +825,7 @@ def __init__(
837825
class CoverageCommit(Coverage):
838826
"""A version of coverage.py from a specific commit."""
839827

840-
def __init__(
841-
self, sha: str, tweaks: TweaksType = None, env_vars: Env_VarsType = None
842-
):
828+
def __init__(self, sha: str, tweaks: TweaksType = None, env_vars: Env_VarsType = None):
843829
url = f"https://github.com/nedbat/coveragepy.git@{sha}"
844830
url_must_exist(url)
845831
super().__init__(
@@ -915,18 +901,11 @@ def load_results(self) -> dict[ResultKey, list[float]]:
915901
if self.results_file.exists():
916902
with self.results_file.open("r", encoding="utf-8") as f:
917903
data: dict[str, list[float]] = json.load(f)
918-
return {
919-
(k.split()[0], k.split()[1], k.split()[2]): v for k, v in data.items()
920-
}
904+
return {(k.split()[0], k.split()[1], k.split()[2]): v for k, v in data.items()}
921905
return {}
922906

923907
def run(self, num_runs: int = 3) -> None:
924-
total_runs = (
925-
len(self.projects)
926-
* len(self.py_versions)
927-
* len(self.cov_versions)
928-
* num_runs
929-
)
908+
total_runs = len(self.projects) * len(self.py_versions) * len(self.cov_versions) * num_runs
930909
total_run_nums = iter(itertools.count(start=1))
931910

932911
all_runs = []
@@ -962,10 +941,7 @@ def run(self, num_runs: int = 3) -> None:
962941
for proj, pyver, cov_ver, env in all_runs:
963942
result_key = (proj.slug, pyver.slug, cov_ver.slug)
964943
total_run_num = next(total_run_nums)
965-
if (
966-
result_key in self.result_data
967-
and len(self.result_data[result_key]) >= num_runs
968-
):
944+
if result_key in self.result_data and len(self.result_data[result_key]) >= num_runs:
969945
print(f"Skipping {result_key} as results already exist.")
970946
continue
971947

@@ -1100,9 +1076,7 @@ def run_experiment(
11001076
if any(rslug not in slugs for rslug in ratio_slugs):
11011077
raise Exception(f"Ratio slug doesn't match a slug: {ratio_slugs}, {slugs}")
11021078
if set(rows + [column]) != set(DIMENSION_NAMES):
1103-
raise Exception(
1104-
f"All of these must be in rows or column: {', '.join(DIMENSION_NAMES)}"
1105-
)
1079+
raise Exception(f"All of these must be in rows or column: {', '.join(DIMENSION_NAMES)}")
11061080

11071081
print(f"Removing and re-making {PERF_DIR}")
11081082
remake(PERF_DIR)

benchmark/empty.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@
77
],
88
cov_versions=[
99
Coverage("701", "coverage==7.0.1"),
10-
Coverage(
11-
"701.dynctx", "coverage==7.0.1", [("dynamic_context", "test_function")]
12-
),
10+
Coverage("701.dynctx", "coverage==7.0.1", [("dynamic_context", "test_function")]),
1311
Coverage("702", "coverage==7.0.2"),
14-
Coverage(
15-
"702.dynctx", "coverage==7.0.2", [("dynamic_context", "test_function")]
16-
),
12+
Coverage("702.dynctx", "coverage==7.0.2", [("dynamic_context", "test_function")]),
1713
],
1814
projects=[
1915
EmptyProject("empty", [1.2, 3.4]),

benchmark/fake.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from benchmark import *
22

3+
34
class ProjectSlow(EmptyProject):
45
def __init__(self):
56
super().__init__(slug="slow", fake_durations=[23.9, 24.2])
67

8+
79
class ProjectOdd(EmptyProject):
810
def __init__(self):
911
super().__init__(slug="odd", fake_durations=[10.1, 10.5, 9.9])
@@ -13,7 +15,7 @@ def __init__(self):
1315
py_versions=[
1416
Python(3, 10),
1517
Python(3, 11),
16-
# Python(3, 12),
18+
# Python(3, 12),
1719
],
1820
cov_versions=[
1921
Coverage("753", "coverage==7.5.3"),
@@ -27,6 +29,6 @@ def __init__(self):
2729
column="pyver",
2830
ratios=[
2931
("11 vs 10", "python3.11", "python3.10"),
30-
# ("12 vs 11", "python3.12", "python3.11"),
32+
# ("12 vs 11", "python3.12", "python3.11"),
3133
],
3234
)

benchmark/run.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
action="store_true",
1010
dest="clean",
1111
default=False,
12-
help="Delete the results.json file before running benchmarks"
12+
help="Delete the results.json file before running benchmarks",
1313
)
1414
options, args = parser.parse_args()
1515

@@ -52,13 +52,9 @@
5252
],
5353
cov_versions=[
5454
Coverage("701", "coverage==7.0.1"),
55-
Coverage(
56-
"701.dynctx", "coverage==7.0.1", [("dynamic_context", "test_function")]
57-
),
55+
Coverage("701.dynctx", "coverage==7.0.1", [("dynamic_context", "test_function")]),
5856
Coverage("702", "coverage==7.0.2"),
59-
Coverage(
60-
"702.dynctx", "coverage==7.0.2", [("dynamic_context", "test_function")]
61-
),
57+
Coverage("702.dynctx", "coverage==7.0.2", [("dynamic_context", "test_function")]),
6258
],
6359
projects=[
6460
ProjectAttrs(),
@@ -88,8 +84,7 @@
8884
rows=["cov", "proj"],
8985
column="pyver",
9086
ratios=[
91-
(f"3.{b} vs 3.{a}", f"python3.{b}", f"python3.{a}")
92-
for a, b in zip(vers, vers[1:])
87+
(f"3.{b} vs 3.{a}", f"python3.{b}", f"python3.{a}") for a, b in zip(vers, vers[1:])
9388
],
9489
)
9590

@@ -107,8 +102,8 @@
107102
CoverageSource(slug="sysmon", env_vars={"COVERAGE_CORE": "sysmon"}),
108103
],
109104
projects=[
110-
ProjectPillow(), #"-k test_pickle"),
111-
ProjectPillowBranch(), #"-k test_pickle"),
105+
ProjectPillow(), # "-k test_pickle"),
106+
ProjectPillowBranch(), # "-k test_pickle"),
112107
# ProjectSphinx(), # Works, slow
113108
# ProjectPygments(), # Doesn't work on 3.14
114109
# ProjectRich(), # Doesn't work
@@ -165,8 +160,8 @@
165160
),
166161
],
167162
projects=[
168-
ProjectMashumaro(), # small: "-k ck"
169-
ProjectOperator(), # small: "-k irk"
163+
ProjectMashumaro(), # small: "-k ck"
164+
ProjectOperator(), # small: "-k irk"
170165
],
171166
rows=["pyver", "proj"],
172167
column="cov",

ci/comment_on_fixes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616

1717
# Get the first entry in the changelog:
1818
for etitle, sections in changelog.entries().items():
19-
version = etitle.split()[1] # particular to our title format.
19+
version = etitle.split()[1] # particular to our title format.
2020
text = "\n".join(sections)
2121
break
2222

2323
comment = (
24-
f"This is now released as part of [coverage {version}]" +
25-
f"(https://pypi.org/project/coverage/{version})."
24+
f"This is now released as part of [coverage {version}]"
25+
+ f"(https://pypi.org/project/coverage/{version})."
2626
)
2727
print(f"Comment will be:\n\n{comment}\n")
2828

2929
repo_owner = sys.argv[1]
30-
url_matches = re.finditer(fr"https://github.com/{repo_owner}/(issues|pull)/(\d+)", text)
30+
url_matches = re.finditer(rf"https://github.com/{repo_owner}/(issues|pull)/(\d+)", text)
3131
urls = set((m[0], m[1], m[2]) for m in url_matches)
3232

3333
for url, kind, number in urls:

ci/session.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
_SESSIONS = {}
1212

13+
1314
def get_session(env="GITHUB_TOKEN"):
1415
"""Get a properly authenticated requests Session.
1516

coverage/bytecode.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ def branch_trails(code: CodeType) -> TBranchTrails:
116116
arc from the original instruction's line to the new source line.
117117
118118
"""
119-
the_trails: TBranchTrails = collections.defaultdict(
120-
lambda: collections.defaultdict(set)
121-
)
119+
the_trails: TBranchTrails = collections.defaultdict(lambda: collections.defaultdict(set))
122120
iwalker = InstructionWalker(code)
123121
for inst in iwalker.walk(follow_jumps=False):
124122
if not inst.jump_target:

0 commit comments

Comments
 (0)