repwise 3.0.0__tar.gz → 3.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. {repwise-3.0.0/src/repwise.egg-info → repwise-3.1.0}/PKG-INFO +1 -1
  2. {repwise-3.0.0 → repwise-3.1.0}/pyproject.toml +86 -2
  3. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/__init__.py +1 -1
  4. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/app/fetch.py +2 -2
  5. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/app/importing.py +3 -2
  6. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/app/listing.py +3 -2
  7. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/app/report.py +15 -0
  8. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/app/update.py +11 -8
  9. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/checker.py +46 -12
  10. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/cli/__init__.py +15 -1
  11. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/cli/parser.py +1 -2
  12. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/config.py +190 -19
  13. repwise-3.1.0/src/repwise/domain/effort.py +367 -0
  14. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/domain/models.py +120 -6
  15. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/domain/progression.py +83 -39
  16. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/dumps.py +10 -5
  17. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/errors.py +6 -0
  18. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/garmin/catalog.py +4 -3
  19. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/garmin/client.py +11 -6
  20. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/garmin/payloads.py +39 -5
  21. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/importer.py +14 -10
  22. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/log.py +1 -1
  23. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/planner.py +110 -7
  24. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/yamlio.py +16 -6
  25. {repwise-3.0.0 → repwise-3.1.0/src/repwise.egg-info}/PKG-INFO +1 -1
  26. {repwise-3.0.0 → repwise-3.1.0}/src/repwise.egg-info/SOURCES.txt +4 -1
  27. {repwise-3.0.0 → repwise-3.1.0}/tests/test_catalog.py +92 -0
  28. {repwise-3.0.0 → repwise-3.1.0}/tests/test_checker.py +222 -5
  29. {repwise-3.0.0 → repwise-3.1.0}/tests/test_checking.py +1 -1
  30. {repwise-3.0.0 → repwise-3.1.0}/tests/test_config.py +248 -3
  31. {repwise-3.0.0 → repwise-3.1.0}/tests/test_effort.py +182 -17
  32. {repwise-3.0.0 → repwise-3.1.0}/tests/test_fetch.py +66 -4
  33. repwise-3.1.0/tests/test_importing.py +181 -0
  34. repwise-3.1.0/tests/test_listing.py +129 -0
  35. {repwise-3.0.0 → repwise-3.1.0}/tests/test_log.py +3 -3
  36. {repwise-3.0.0 → repwise-3.1.0}/tests/test_main.py +125 -2
  37. {repwise-3.0.0 → repwise-3.1.0}/tests/test_matching.py +10 -1
  38. repwise-3.1.0/tests/test_models.py +177 -0
  39. {repwise-3.0.0 → repwise-3.1.0}/tests/test_payloads.py +39 -0
  40. {repwise-3.0.0 → repwise-3.1.0}/tests/test_planner.py +262 -9
  41. {repwise-3.0.0 → repwise-3.1.0}/tests/test_progression.py +127 -0
  42. {repwise-3.0.0 → repwise-3.1.0}/tests/test_report.py +114 -3
  43. {repwise-3.0.0 → repwise-3.1.0}/tests/test_update.py +138 -2
  44. repwise-3.1.0/tests/test_yamlio.py +126 -0
  45. repwise-3.0.0/src/repwise/domain/effort.py +0 -199
  46. repwise-3.0.0/tests/test_models.py +0 -43
  47. {repwise-3.0.0 → repwise-3.1.0}/LICENSE +0 -0
  48. {repwise-3.0.0 → repwise-3.1.0}/README.md +0 -0
  49. {repwise-3.0.0 → repwise-3.1.0}/setup.cfg +0 -0
  50. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/__main__.py +0 -0
  51. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/app/__init__.py +0 -0
  52. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/app/checking.py +0 -0
  53. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/app/logout.py +0 -0
  54. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/cli/completion.py +0 -0
  55. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/domain/__init__.py +0 -0
  56. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/domain/matching.py +0 -0
  57. {repwise-3.0.0 → repwise-3.1.0}/src/repwise/garmin/__init__.py +0 -0
  58. {repwise-3.0.0 → repwise-3.1.0}/src/repwise.egg-info/dependency_links.txt +0 -0
  59. {repwise-3.0.0 → repwise-3.1.0}/src/repwise.egg-info/entry_points.txt +0 -0
  60. {repwise-3.0.0 → repwise-3.1.0}/src/repwise.egg-info/requires.txt +0 -0
  61. {repwise-3.0.0 → repwise-3.1.0}/src/repwise.egg-info/top_level.txt +0 -0
  62. {repwise-3.0.0 → repwise-3.1.0}/tests/test_cli.py +0 -0
  63. {repwise-3.0.0 → repwise-3.1.0}/tests/test_client.py +0 -0
  64. {repwise-3.0.0 → repwise-3.1.0}/tests/test_completion.py +0 -0
  65. {repwise-3.0.0 → repwise-3.1.0}/tests/test_dumps.py +0 -0
  66. {repwise-3.0.0 → repwise-3.1.0}/tests/test_importer.py +0 -0
  67. {repwise-3.0.0 → repwise-3.1.0}/tests/test_logout.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: repwise
3
- Version: 3.0.0
3
+ Version: 3.1.0
4
4
  Summary: Advance Garmin strength workout targets using double progression
5
5
  Author-email: Adam Żmuda <adam@zmuda.pro>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "repwise"
7
- version = "3.0.0"
7
+ version = "3.1.0"
8
8
  description = "Advance Garmin strength workout targets using double progression"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -67,6 +67,7 @@ release = [
67
67
  ]
68
68
  dev = [
69
69
  { include-group = "release" },
70
+ "coverage==7.16.0",
70
71
  "mypy==2.3.1",
71
72
  "pre-commit==4.6.2",
72
73
  "pytest==9.1.1",
@@ -124,6 +125,23 @@ select = [
124
125
  "BLE", # blind except - the existing noqa comments name this rule
125
126
  "PL", # pylint subset
126
127
  "RUF", # ruff's own
128
+ # Added as ratchets: each was already clean, so it costs nothing today and
129
+ # refuses the first regression. See [[tool.mypy.overrides]] below for the
130
+ # same reasoning applied to types.
131
+ "LOG", # logging misuse: a logger built by hand, warn() on the root
132
+ "PGH", # a bare `noqa` or `type: ignore` that names no rule
133
+ "FURB", # constructs with a plainer spelling
134
+ "A", # an argument or variable shadowing a builtin
135
+ # A boolean argument read at the call site as a bare True is a coin flip
136
+ # for the reader: `connect(settings, False)` says nothing about which of
137
+ # two flags it set. Keyword-only, so the call says what it means. The one
138
+ # exemption is `yamlio._Dumper.increase_indent`, whose signature is
139
+ # PyYAML's rather than ours, and which says so.
140
+ "FBT", # boolean traps
141
+ # `Any` in a signature where a real type exists. Where it has none - a
142
+ # dump, a parsed document - the noqa says so rather than the annotation
143
+ # quietly meaning nothing.
144
+ "ANN401", # dynamically typed signatures
127
145
  ]
128
146
  ignore = [
129
147
  # This is a CLI whose job is printing, and its errors carry the detail a
@@ -138,8 +156,53 @@ ignore = [
138
156
  ]
139
157
 
140
158
  [tool.mypy]
141
- files = ["src", "tests"]
159
+ # tools/ as well: the checks in there are part of the repository and read the
160
+ # same tree, so a wrong assumption about it should fail here rather than in a
161
+ # hook that then reports nonsense.
162
+ files = ["src", "tests", "tools"]
142
163
  python_version = "3.14"
164
+ # A cast that is no longer needed is a leftover from a type that has since
165
+ # improved, and it silently keeps the old shape. Global rather than per-module
166
+ # because mypy offers it nowhere else.
167
+ warn_redundant_casts = true
168
+
169
+ # The shipped package is held to a stricter standard than the tests that drive
170
+ # it. Every flag here was already clean when it was added, so this locks in
171
+ # where the code got to rather than announcing a cleanup nobody is doing - a
172
+ # rule that fails the day it lands teaches people to skip the hook.
173
+ #
174
+ # `disallow_untyped_defs` is the one that matters, and the reason a bare `mypy`
175
+ # is not enough: without it the *bodies* of unannotated functions are never
176
+ # checked, so an unannotated function is a hole rather than a looser check.
177
+ # Deliberately not applied to tests, where 900-odd `def test_x():` signatures
178
+ # would be noise for no safety - the code under test is what has to be right.
179
+ [[tool.mypy.overrides]]
180
+ module = "repwise.*"
181
+ disallow_untyped_defs = true
182
+ disallow_incomplete_defs = true
183
+ disallow_untyped_calls = true
184
+ disallow_untyped_decorators = true
185
+ disallow_subclassing_any = true
186
+ # Comparing two types that can never be equal is always a bug, and the shapes
187
+ # this maps between - Garmin's strings against our enums and ints - are exactly
188
+ # where that happens silently.
189
+ strict_equality = true
190
+ extra_checks = true
191
+ warn_unreachable = true
192
+ # An ignore that stopped being needed is an ignore that now hides something.
193
+ warn_unused_ignores = true
194
+ # A bare `dict` or `list` is Any wearing a container, and this reads YAML and
195
+ # Garmin's JSON into both. Spelling the shape out is what stops Any spreading
196
+ # from the two files that have a reason for it into the ones that do not.
197
+ disallow_any_generics = true
198
+ # The value garminconnect hands back is Any, so without this a function can
199
+ # promise `dict[str, Any]` and return whatever came off the wire unchecked.
200
+ # `garmin/client.py` casts at the boundary instead, which is what an adapter is.
201
+ warn_return_any = true
202
+ # A name is imported from where it is defined, not from the last module that
203
+ # happened to import it - `ActivityNotFound` lives in `errors.py`, whoever else
204
+ # passes it through.
205
+ no_implicit_reexport = true
143
206
 
144
207
  # garminconnect ships no type information. garmin/client.py is the only module
145
208
  # that imports it, which is what keeping the adapter in one place buys.
@@ -150,3 +213,24 @@ ignore_missing_imports = true
150
213
  [tool.pytest.ini_options]
151
214
  pythonpath = ["src"]
152
215
  testpaths = ["tests"]
216
+
217
+ # Coverage is a decay alarm, not a quality bar. It answers "was this line
218
+ # executed", never "would a test notice a wrong answer" - the audit that added
219
+ # these floors found three of its four bugs in covered code, one of them in a
220
+ # module sitting at 100%. So the floors are set at a decent distance below
221
+ # where the suite actually is, and are meant to fire when whole modules arrive
222
+ # untested rather than to be climbed towards. Test strength is a separate
223
+ # question, and mutation testing is what answers it.
224
+ [tool.coverage.run]
225
+ source = ["src"]
226
+ omit = [
227
+ # Three lines that call main() and exit. Reaching them means running the
228
+ # process, which is what tests/test_main.py does through main() itself.
229
+ "src/repwise/__main__.py",
230
+ ]
231
+
232
+ [tool.coverage.report]
233
+ #: The floor for the tree as a whole. Read by `tools/check_coverage.py` as well
234
+ #: as by `coverage report`, so there is one number rather than two that can
235
+ #: disagree.
236
+ fail_under = 90
@@ -1,4 +1,4 @@
1
1
  """Advance Garmin strength workout targets using double progression."""
2
2
 
3
3
  __all__ = ["__version__"]
4
- __version__ = "3.0.0"
4
+ __version__ = "3.1.0"
@@ -10,7 +10,7 @@ from ..domain.models import Config, GarminSettings
10
10
  from ..errors import ExitCode, GarminError
11
11
  from ..garmin import catalog
12
12
  from ..garmin.client import STRENGTH, GarminSession
13
- from ..garmin.payloads import activity_sport
13
+ from ..garmin.payloads import activity_sport, workout_name
14
14
 
15
15
  logger = logging.getLogger(__name__)
16
16
 
@@ -54,7 +54,7 @@ def run_fetch(
54
54
  continue
55
55
 
56
56
  path = dumps.write(payload, config.garmin.dump_dir, dumps.WORKOUT, workout_id)
57
- logger.info(f"Saved {payload.get('workoutName', '(unnamed)')} -> {path}")
57
+ logger.info(f"Saved {workout_name(payload) or '(unnamed)'} -> {path}")
58
58
 
59
59
  return ExitCode.NOTHING_USABLE if failed else ExitCode.OK
60
60
 
@@ -7,6 +7,7 @@ from typing import Any
7
7
 
8
8
  from ..errors import ActivityNotFound, ExitCode, UsageError
9
9
  from ..garmin.client import STRENGTH, GarminSession
10
+ from ..garmin.payloads import workout_name
10
11
  from ..importer import describe_workout, render_config
11
12
  from ..yamlio import write
12
13
 
@@ -33,9 +34,9 @@ def select(session: GarminSession, options: ImportOptions) -> list[dict[str, Any
33
34
  return wanted
34
35
  if options.name:
35
36
  needle = options.name.lower()
36
- wanted = [w for w in workouts if needle in (w.get("workoutName") or "").lower()]
37
+ wanted = [w for w in workouts if needle in (workout_name(w) or "").lower()]
37
38
  if not wanted:
38
- names = ", ".join(repr(w.get("workoutName")) for w in workouts)
39
+ names = ", ".join(repr(workout_name(w)) for w in workouts)
39
40
  raise ActivityNotFound(
40
41
  f"No strength workout matching {options.name!r}. Found: {names}"
41
42
  )
@@ -5,12 +5,13 @@ import logging
5
5
  from ..domain.models import Config
6
6
  from ..errors import ExitCode
7
7
  from ..garmin.client import STRENGTH, GarminSession
8
+ from ..garmin.payloads import workout_name
8
9
 
9
10
  logger = logging.getLogger(__name__)
10
11
 
11
12
 
12
13
  def run_list(
13
- session: GarminSession, config: Config, every_sport: bool = False
14
+ session: GarminSession, config: Config, *, every_sport: bool = False
14
15
  ) -> ExitCode:
15
16
  workouts = session.list_workouts(sport_type=None if every_sport else STRENGTH)
16
17
 
@@ -24,7 +25,7 @@ def run_list(
24
25
  workout_id = str(entry.get("workoutId"))
25
26
  updated = (entry.get("updateDate") or "")[:10]
26
27
  mark = "*" if workout_id in known else " "
27
- name = entry.get("workoutName") or "(unnamed)"
28
+ name = workout_name(entry) or "(unnamed)"
28
29
  if every_sport:
29
30
  kind = (entry.get("sportType") or {}).get("sportTypeKey", "?")
30
31
  name = f"{name} [{kind}]"
@@ -252,6 +252,10 @@ def rows(plan: Plan) -> list[Row]:
252
252
  An exercise the config no longer names has no place among the ones it
253
253
  does, so a removal follows them, and the rest between exercises - which
254
254
  belongs to the whole workout rather than to any one of them - comes last.
255
+
256
+ The workout's own name is not among them. Every row here is something the
257
+ workout contains; the name is what the workout *is*, so it is announced
258
+ with the heading instead - see `report_plan`.
255
259
  """
256
260
  described = {spec.name: spec for spec in plan.workout.exercises}
257
261
  places = {name: place for place, name in enumerate(described, 1)}
@@ -303,6 +307,17 @@ def joins(row: Row) -> str:
303
307
 
304
308
 
305
309
  def report_plan(plan: Plan) -> None:
310
+ # Under the heading the caller has just printed, which is where the workout
311
+ # is being named anyway. It is a fact about the workout rather than about
312
+ # anything in it, and a table of exercises is no place to say it.
313
+ if plan.name:
314
+ logger.info(f"Renaming: {plan.name.was} -> {plan.name.new}")
315
+
316
+ # The blank between the heading and the table belongs here rather than to
317
+ # the caller, so that a rename joins the heading above it instead of being
318
+ # stranded on the far side of the gap.
319
+ logger.info("")
320
+
306
321
  for text in render(rows(plan)):
307
322
  logger.info(text)
308
323
 
@@ -347,7 +347,6 @@ def sync_other_workouts(
347
347
 
348
348
  logger.info("")
349
349
  logger.info(f"Also in {other.key} (workout {other.garmin_workout_id}):")
350
- logger.info("")
351
350
  report_plan(plan)
352
351
  plans.append(plan)
353
352
 
@@ -398,18 +397,16 @@ def shape_untrained(
398
397
  logger.info(
399
398
  f"Shaping: {workout.key} -> workout {workout.garmin_workout_id}"
400
399
  )
401
- logger.info("")
402
400
  report_plan(plan)
403
401
  plans.append(plan)
404
402
 
405
403
  return plans
406
404
 
407
405
 
408
- def advance_trained( # noqa: PLR0913 - each argument is one independent input
406
+ def advance_trained(
409
407
  session: GarminSession,
410
408
  payloads: Payloads,
411
409
  config: Config,
412
- options: UpdateOptions,
413
410
  sessions: list[Trained],
414
411
  *,
415
412
  trusted: Container[str] | None = None,
@@ -430,7 +427,6 @@ def advance_trained( # noqa: PLR0913 - each argument is one independent input
430
427
  logger.info("")
431
428
  logger.info(f"Activity: {activity.get('activityName') or ''} ({activity_id})")
432
429
  logger.info(f"Updating: {workout.key} -> workout {workout.garmin_workout_id}")
433
- logger.info("")
434
430
 
435
431
  sets_payload = session.exercise_sets(activity_id)
436
432
  payload = payloads[garmin_id(workout)]
@@ -536,7 +532,7 @@ def run_update(
536
532
  )
537
533
 
538
534
  trained, usable = advance_trained(
539
- session, payloads, config, options, sessions, trusted=trusted
535
+ session, payloads, config, sessions, trusted=trusted
540
536
  )
541
537
  plans.extend(trained)
542
538
 
@@ -559,6 +555,7 @@ def run_update(
559
555
  unskipped = counted(plans, lambda plan: (c.spec.garmin_name for c in plan.skips))
560
556
  # One per workout however many gap steps it touched: the config says it once.
561
557
  regaps = len({counted_as(plan.workout) for plan in plans if plan.gaps})
558
+ renames = len({counted_as(plan.workout) for plan in plans if plan.name})
562
559
  shaped = counted(plans, lambda plan: ((c.kind, c.name) for c in plan.reshaped))
563
560
  structure = (
564
561
  f", {shaped} exercise(s) would be added, removed or moved" if shaped else ""
@@ -569,6 +566,7 @@ def run_update(
569
566
  if regaps
570
567
  else ""
571
568
  )
569
+ renamed = f", {renames} workout(s) would be renamed" if renames else ""
572
570
  notes = f", {noted} note(s) would be refreshed" if noted else ""
573
571
  rests = f", {rested} rest time(s) would change" if rested else ""
574
572
  skips = (
@@ -581,11 +579,15 @@ def run_update(
581
579
  logger.info("")
582
580
  logger.info(
583
581
  f"Dry run: {updated} step(s) would change"
584
- f"{structure}{counts}{rests}{skips}{between}{notes}. Re-run with --apply."
582
+ f"{structure}{counts}{rests}{skips}{between}{renamed}{notes}."
583
+ f" Re-run with --apply."
585
584
  )
586
585
  return ExitCode.OK
587
586
 
588
- if not (updated or noted or rested or recounted or unskipped or regaps or shaped):
587
+ moved_anything = (
588
+ updated or noted or rested or recounted or unskipped or regaps or renames
589
+ )
590
+ if not (moved_anything or shaped):
589
591
  logger.info("")
590
592
  logger.info("Nothing to write.")
591
593
  return ExitCode.OK
@@ -600,6 +602,7 @@ def run_update(
600
602
  + (f" Set {rested} rest time(s)." if rested else "")
601
603
  + (f" Restored the last rest on {unskipped} step(s)." if unskipped else "")
602
604
  + (f" Set the rest between exercises in {regaps} workout(s)." if regaps else "")
605
+ + (f" Renamed {renames} workout(s)." if renames else "")
603
606
  + (f" Refreshed {noted} note(s)." if noted else "")
604
607
  )
605
608
 
@@ -24,16 +24,18 @@ Sets, rests and the exercise list are left to the command that owns them.
24
24
  Pure: takes a config and payloads, returns findings.
25
25
  """
26
26
 
27
- from dataclasses import dataclass
27
+ from dataclasses import dataclass, replace
28
+ from typing import Any
28
29
 
29
30
  from .domain.effort import (
30
- TOLERATED_SHIFT,
31
+ chosen_step,
31
32
  effective_load,
32
33
  fitting_rep_highs,
33
34
  reset_drop,
35
+ within_tolerance,
34
36
  )
35
37
  from .domain.matching import ExerciseIndex
36
- from .domain.models import ExerciseSpec, Workout
38
+ from .domain.models import READABLE_NOTE, ExerciseSpec, Workout
37
39
  from .garmin.catalog import ExerciseCatalog
38
40
  from .garmin.payloads import (
39
41
  ExerciseBlock,
@@ -140,13 +142,35 @@ def check_catalog(workout: Workout, catalog: ExerciseCatalog) -> list[Finding]:
140
142
  return findings
141
143
 
142
144
 
143
- def check_workout(workout: Workout, payload: dict) -> list[Finding]:
145
+ def check_workout(workout: Workout, payload: dict[str, Any]) -> list[Finding]:
144
146
  """Look for exercises the config cannot name properly."""
145
147
  findings: list[Finding] = []
146
148
 
147
149
  def note(detail: str, severity: str = "warning") -> None:
148
150
  findings.append(Finding(workout.key, detail, severity))
149
151
 
152
+ # `update` writes the config key to Garmin, so it is the name your next
153
+ # session will be logged under - and `activity_prefixes` is what finds it
154
+ # again. A key none of them claims means the sessions you are about to
155
+ # perform match nothing, which is silent until a target stops moving.
156
+ if workout.activity_prefixes and not workout.claims(workout.key):
157
+ listed = ", ".join(repr(prefix) for prefix in workout.activity_prefixes)
158
+ note(
159
+ f"no activity_prefixes entry matches the workout name {workout.key!r}, "
160
+ f"so sessions logged under it would be found by none of {listed}. "
161
+ f"Add {workout.key.lower()!r}, keeping the old ones so past sessions "
162
+ f"still match",
163
+ "error",
164
+ )
165
+
166
+ for spec in workout.exercises:
167
+ if len(spec.note) > READABLE_NOTE:
168
+ note(
169
+ f"{spec.name}: its note comes to {len(spec.note)} characters, past "
170
+ f"the {READABLE_NOTE} a watch shows, so the end of it is simply "
171
+ f"never read"
172
+ )
173
+
150
174
  index: ExerciseIndex[ExerciseBlock] = ExerciseIndex()
151
175
  for entry in iter_exercise_blocks(payload):
152
176
  index.add(
@@ -217,7 +241,7 @@ def _suggestion(spec: ExerciseSpec, weight: float, bodyweight: float) -> str:
217
241
 
218
242
 
219
243
  def check_programming(
220
- workout: Workout, payload: dict, bodyweight: float | None = None
244
+ workout: Workout, payload: dict[str, Any], bodyweight: float | None = None
221
245
  ) -> list[Finding]:
222
246
  """Look for rep ranges that do not fit what their weight step is worth.
223
247
 
@@ -261,11 +285,21 @@ def check_programming(
261
285
  continue
262
286
 
263
287
  carried = bodyweight or 0.0
264
- shift = reset_drop(spec, target.weight, carried)
265
- if shift is None or abs(shift) <= TOLERATED_SHIFT:
288
+ # Judge the step rule 3 will actually take. Where the equipment offers
289
+ # a choice of increments, that is the one `chosen_step` picks for this
290
+ # weight, not the smallest the load type happens to name - reporting
291
+ # the 1.25 kg increment as a wall on a 60 kg stack would be a finding
292
+ # about a jump the tool was never going to prescribe.
293
+ stepped = replace(
294
+ spec,
295
+ weight_step=chosen_step(spec, target.weight, carried),
296
+ tiers=(),
297
+ )
298
+ shift = reset_drop(stepped, target.weight, carried)
299
+ if shift is None or within_tolerance(shift):
266
300
  continue
267
301
 
268
- load = effective_load(spec, target.weight, carried)
302
+ load = effective_load(stepped, target.weight, carried)
269
303
  # The sign is the whole diagnosis, so it decides every word that
270
304
  # follows: which way the range is wrong, which way to move it, and
271
305
  # what it costs you to leave it alone.
@@ -274,13 +308,13 @@ def check_programming(
274
308
  settle = "accept the sawtooth"
275
309
  else:
276
310
  gives, costs = "gives back less", f"{-shift:.0%} jump in effort"
277
- settle = "micro-load"
278
- fix = _suggestion(spec, target.weight, carried)
311
+ settle = "take a smaller step"
312
+ fix = _suggestion(stepped, target.weight, carried)
279
313
  findings.append(
280
314
  Finding(
281
315
  workout.key,
282
- f"{spec.name}: +{spec.weight_step:g} kg on {load:g} kg is "
283
- f"{spec.weight_step / load:.1%}, but resetting "
316
+ f"{spec.name}: +{stepped.weight_step:g} kg on {load:g} kg is "
317
+ f"{stepped.weight_step / load:.1%}, but resetting "
284
318
  f"{spec.rep_high}->{spec.rep_low} reps {gives}, so the weight "
285
319
  f"increase is a {costs} ({fix}, or {settle})",
286
320
  )
@@ -127,7 +127,7 @@ HANDLERS: dict[str, Handler] = {
127
127
  def main(argv: list[str] | None = None) -> int:
128
128
  parser = build_parser()
129
129
  args = parser.parse_args(argv)
130
- configure(args.verbose)
130
+ configure(verbose=args.verbose)
131
131
 
132
132
  # Answered here rather than through HANDLERS below, because the config is
133
133
  # loaded to reach those and this command must run without one: the way to
@@ -148,6 +148,20 @@ def main(argv: list[str] | None = None) -> int:
148
148
  if exc.advice:
149
149
  logger.error(exc.advice)
150
150
  return exc.exit_code
151
+ except KeyboardInterrupt:
152
+ # Not a bug, so not a traceback. A run is stopped from the keyboard
153
+ # most often while it waits on Garmin, and a stack trace through the
154
+ # HTTP library says nothing about what happened or what to do next.
155
+ #
156
+ # Re-running is the answer, and it is a safe one: `update` recomputes
157
+ # every plan from what Garmin holds now, so the workouts that were
158
+ # already written are simply found up to date.
159
+ logger.warning("")
160
+ logger.warning(
161
+ "Stopped. Anything already written to Garmin is still there, and "
162
+ "re-running picks up from it."
163
+ )
164
+ return ExitCode.INTERRUPTED
151
165
 
152
166
 
153
167
  if __name__ == "__main__":
@@ -10,7 +10,6 @@ reads them and this parser to write its scripts.
10
10
  """
11
11
 
12
12
  import argparse
13
- from typing import Any
14
13
 
15
14
  from .. import __version__
16
15
 
@@ -28,7 +27,7 @@ SHELLS = ("bash", "zsh")
28
27
 
29
28
 
30
29
  def add_verbose(
31
- parser: argparse.ArgumentParser, default: Any = argparse.SUPPRESS
30
+ parser: argparse.ArgumentParser, *, default: bool | str = argparse.SUPPRESS
32
31
  ) -> None:
33
32
  """Accept -v on this parser, so it reads either side of the command.
34
33