Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: pre-commit autoupdate #605

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
exclude: template
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
rev: v0.8.1
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -35,7 +35,7 @@ repos:
test/test_util_path.py
)$
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v3.4.0
rev: v3.6.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
Expand Down
9 changes: 3 additions & 6 deletions src/taskgraph/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ def _run(self):
all_tasks, Graph(frozenset(full_task_set.graph.nodes), frozenset(edges))
)
logger.info(
"Full task graph contains %d tasks and %d dependencies"
% (len(full_task_set.graph.nodes), len(edges))
f"Full task graph contains {len(full_task_set.graph.nodes)} tasks and {len(edges)} dependencies"
)
yield self.verify("full_task_graph", full_task_graph, graph_config, parameters)

Expand All @@ -356,8 +355,7 @@ def _run(self):
Graph(frozenset(target_tasks), frozenset()),
)
logger.info(
"Filter %s pruned %d tasks (%d remain)"
% (fltr.__name__, old_len - len(target_tasks), len(target_tasks))
f"Filter {fltr.__name__} pruned {old_len - len(target_tasks)} tasks ({len(target_tasks)} remain)"
)

yield self.verify("target_task_set", target_task_set, graph_config, parameters)
Expand All @@ -375,8 +373,7 @@ def _run(self):
else:
always_target_tasks = set()
logger.info(
"Adding %d tasks with `always_target` attribute"
% (len(always_target_tasks) - len(always_target_tasks & target_tasks)) # type: ignore
f"Adding {len(always_target_tasks) - len(always_target_tasks & target_tasks)} tasks with `always_target` attribute" # type: ignore
)
requested_tasks = target_tasks | always_target_tasks # type: ignore
target_graph = full_task_graph.graph.transitive_closure(requested_tasks)
Expand Down
4 changes: 2 additions & 2 deletions src/taskgraph/transforms/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,11 @@ def create_fetch_url_task(config, name, fetch):
"--sha256",
fetch["sha256"],
"--size",
"%d" % fetch["size"],
f"{fetch['size']}",
]

if fetch.get("strip-components"):
args.extend(["--strip-components", "%d" % fetch["strip-components"]])
args.extend(["--strip-components", f'{fetch["strip-components"]}'])

if fetch.get("add-prefix"):
args.extend(["--add-prefix", fetch["add-prefix"]])
Expand Down
2 changes: 1 addition & 1 deletion src/taskgraph/util/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def _quote(s):
not enclosed in quotes.
"""
if isinstance(s, int):
return "%d" % s
return f"{s}"

# Empty strings need to be quoted to have any significance
if s and not SHELL_QUOTE_RE.search(s) and not s.startswith("~"):
Expand Down
2 changes: 1 addition & 1 deletion test/test_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def test_get_subgraph(monkeypatch, graph, kwargs, exp_subgraph, exp_label_to_tas
4. The expected label_to_taskid.
"""
monkeypatch.setattr(
optimize_mod, "slugid", partial(next, ("tid%d" % i for i in range(1, 10)))
optimize_mod, "slugid", partial(next, (f"tid{i}" for i in range(1, 10)))
)

kwargs.setdefault("removed_tasks", set())
Expand Down
8 changes: 4 additions & 4 deletions test/test_util_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ class TestArchive(unittest.TestCase):
def _create_files(self, root):
files = {}
for i in range(10):
p = os.path.join(root, "file%02d" % i)
p = os.path.join(root, f"file{i:02d}")
with open(p, "wb") as fh:
fh.write(b"file%02d" % i)
# Need to set permissions or umask may influence testing.
os.chmod(p, MODE_STANDARD)
files["file%02d" % i] = p
files[f"file{i:02d}"] = p

for i in range(10):
files["file%02d" % (i + 10)] = io.BytesIO(b"file%02d" % (i + 10))
files[f"file{i + 10:02d}"] = io.BytesIO(b"file%02d" % (i + 10))

return files

def _verify_basic_tarfile(self, tf):
self.assertEqual(len(tf.getmembers()), 20)

names = ["file%02d" % i for i in range(20)]
names = [f"file{i:02d}" for i in range(20)]
self.assertEqual(tf.getnames(), names)

for ti in tf.getmembers():
Expand Down
4 changes: 2 additions & 2 deletions test/test_util_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def test_create_context_extra_directory(self):
extra = os.path.join(tmp, "extra")
os.mkdir(extra)
for i in range(3):
p = os.path.join(extra, "file%d" % i)
p = os.path.join(extra, f"file{i}")
with open(p, "wb") as fh:
fh.write(b"file%d" % i)
os.chmod(p, MODE_STANDARD)
Expand Down Expand Up @@ -249,7 +249,7 @@ def test_stream_context_tar(self):
extra = os.path.join(tmp, "extra")
os.mkdir(extra)
for i in range(3):
p = os.path.join(extra, "file%d" % i)
p = os.path.join(extra, f"file{i}")
with open(p, "wb") as fh:
fh.write(b"file%d" % i)
os.chmod(p, MODE_STANDARD)
Expand Down
4 changes: 2 additions & 2 deletions test/test_util_parameterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_timestamps_appears_with_other_keys():
@pytest.fixture
def assert_task_refs():
def inner(input, output):
taskid_for_edge_name = {"edge%d" % n: "tid%d" % n for n in range(1, 4)}
taskid_for_edge_name = {f"edge{n}": f"tid{n}" for n in range(1, 4)}
assert (
resolve_task_references(
"subject",
Expand Down Expand Up @@ -151,7 +151,7 @@ def assert_artifact_refs(monkeypatch):
def inner(input, output):
# Clear memoized function
get_root_url.cache_clear()
taskid_for_edge_name = {"edge%d" % n: "tid%d" % n for n in range(1, 4)}
taskid_for_edge_name = {f"edge{n}": f"tid{n}" for n in range(1, 4)}
assert (
resolve_task_references(
"subject", input, "tid-self", "tid-decision", taskid_for_edge_name
Expand Down
Loading