Skip to content

Commit bb1743b

Browse files
committed
refactor methdo
1 parent 02e775f commit bb1743b

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/_pytask/lock.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ class _PlannedChange:
5252
def is_accept(self) -> bool:
5353
return self.entry is not None
5454

55+
def describe(self) -> str:
56+
if self.is_accept:
57+
return f"Accept recorded state for {self.task_id}"
58+
return f"Remove recorded state for {self.task_id}"
59+
5560

5661
# Task selection.
5762

@@ -190,25 +195,19 @@ def _plan_clean_changes(session: Session) -> list[_PlannedChange]:
190195
# Change application.
191196

192197

193-
def _describe_change(change: _PlannedChange) -> str:
194-
if change.is_accept:
195-
return f"Accept recorded state for {change.task_id}"
196-
return f"Remove recorded state for {change.task_id}"
197-
198-
199198
def _apply_changes(
200199
session: Session, planned_changes: list[_PlannedChange]
201200
) -> list[_PlannedChange]:
202201
if session.config["dry_run"]:
203202
for change in planned_changes:
204-
console.print(f"Would {_describe_change(change).lower()}.")
203+
console.print(f"Would {change.describe().lower()}.")
205204
return planned_changes
206205

207206
accepted = planned_changes
208207
if not session.config["yes"]:
209208
accepted = []
210209
for change in planned_changes:
211-
prompt = f"{_describe_change(change)}?"
210+
prompt = f"{change.describe()}?"
212211
if click.confirm(prompt, default=False):
213212
accepted.append(change)
214213

@@ -227,7 +226,7 @@ def _apply_changes(
227226
state.flush()
228227

229228
for change in accepted:
230-
console.print(f"{_describe_change(change)}.")
229+
console.print(f"{change.describe()}.")
231230

232231
return accepted
233232

0 commit comments

Comments
 (0)