@biffo/cli 0.317.0 → 0.317.1
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.
|
@@ -204,7 +204,57 @@ class Branch:
|
|
|
204
204
|
label: str
|
|
205
205
|
|
|
206
206
|
def key(self) -> str:
|
|
207
|
-
|
|
207
|
+
"""The ratchet's identity for this branch. Must not collide (#2026).
|
|
208
|
+
|
|
209
|
+
Two textually-identical branches in one file — two different
|
|
210
|
+
functions each with a bare `except ValueError:` — are common: the
|
|
211
|
+
vocabulary of exception type names is finite and heavily reused, and
|
|
212
|
+
`label` for a `fallback` is truncated to 50 chars on top of that. A
|
|
213
|
+
key of `path:kind:label` alone collapses both onto one entry, so a
|
|
214
|
+
second, genuinely new, never-executed branch sharing a label with an
|
|
215
|
+
already-baselined one in the same file was silently absorbed into
|
|
216
|
+
that entry: it was printed (the analyser saw it) but never marked
|
|
217
|
+
NEW, and `--check` exited 0 over an unverified branch nobody had
|
|
218
|
+
looked at. Confirmed live: a second unexecuted `except ValueError`
|
|
219
|
+
added in the same file as an already-baselined one produced no NEW
|
|
220
|
+
marker and exit 0, while a distinctly-labeled addition in the same
|
|
221
|
+
run was correctly flagged — isolating the cause to the missing
|
|
222
|
+
position, not to anything else about the change.
|
|
223
|
+
|
|
224
|
+
`line` is included to close that gap, chosen deliberately over an
|
|
225
|
+
occurrence ordinal among same-labeled branches in the file (e.g.
|
|
226
|
+
"2nd `except ValueError` in this file"). Both carry a cost and
|
|
227
|
+
neither is free:
|
|
228
|
+
|
|
229
|
+
- **Line number** (chosen): a new branch cannot collide with an
|
|
230
|
+
existing key at all, short of landing on the exact line number a
|
|
231
|
+
deleted branch used to occupy — vanishingly unlikely, since that
|
|
232
|
+
requires a line-count-preserving edit that puts an unrelated new
|
|
233
|
+
branch at that exact spot. The cost is churn: an unrelated edit
|
|
234
|
+
that shifts a baselined branch down a few lines (an import added
|
|
235
|
+
above it, a docstring reflowed) makes its key change too, so it
|
|
236
|
+
reads as NEW and the gate cries wolf until `--write` re-accepts
|
|
237
|
+
it. `unexecuted()`'s own docstring already documents that this
|
|
238
|
+
script's line-based coverage join is shift-sensitive in exactly
|
|
239
|
+
this way, so this does not introduce a new fragility, only extends
|
|
240
|
+
an existing one from the coverage join into the baseline key.
|
|
241
|
+
- **Occurrence ordinal** (rejected): stable under a line shift
|
|
242
|
+
elsewhere in the file, but ambiguous under reordering. If a
|
|
243
|
+
baselined branch is removed and an unrelated new same-labeled
|
|
244
|
+
branch appears earlier in the file than a survivor, the survivor's
|
|
245
|
+
ordinal shifts onto the new branch's — reproducing this exact
|
|
246
|
+
issue by a different route, because an ordinal is still a
|
|
247
|
+
position, just a fragile relative one instead of a stable
|
|
248
|
+
absolute one.
|
|
249
|
+
|
|
250
|
+
Level reached: 3 (fail-closed) rather than 4 (detect-only) — a
|
|
251
|
+
distinct line number for every distinct AST node means a genuinely
|
|
252
|
+
new branch cannot be absorbed into an existing entry at all, not
|
|
253
|
+
merely flagged more often. Changing this format means every
|
|
254
|
+
instance's committed baseline must be regenerated; see the PR that
|
|
255
|
+
introduced this comment for the exact command.
|
|
256
|
+
"""
|
|
257
|
+
return f"{self.path}:{self.line}:{self.kind}:{self.label}"
|
|
208
258
|
|
|
209
259
|
|
|
210
260
|
def _handler_label(node: ast.ExceptHandler) -> str:
|
|
@@ -204,7 +204,57 @@ class Branch:
|
|
|
204
204
|
label: str
|
|
205
205
|
|
|
206
206
|
def key(self) -> str:
|
|
207
|
-
|
|
207
|
+
"""The ratchet's identity for this branch. Must not collide (#2026).
|
|
208
|
+
|
|
209
|
+
Two textually-identical branches in one file — two different
|
|
210
|
+
functions each with a bare `except ValueError:` — are common: the
|
|
211
|
+
vocabulary of exception type names is finite and heavily reused, and
|
|
212
|
+
`label` for a `fallback` is truncated to 50 chars on top of that. A
|
|
213
|
+
key of `path:kind:label` alone collapses both onto one entry, so a
|
|
214
|
+
second, genuinely new, never-executed branch sharing a label with an
|
|
215
|
+
already-baselined one in the same file was silently absorbed into
|
|
216
|
+
that entry: it was printed (the analyser saw it) but never marked
|
|
217
|
+
NEW, and `--check` exited 0 over an unverified branch nobody had
|
|
218
|
+
looked at. Confirmed live: a second unexecuted `except ValueError`
|
|
219
|
+
added in the same file as an already-baselined one produced no NEW
|
|
220
|
+
marker and exit 0, while a distinctly-labeled addition in the same
|
|
221
|
+
run was correctly flagged — isolating the cause to the missing
|
|
222
|
+
position, not to anything else about the change.
|
|
223
|
+
|
|
224
|
+
`line` is included to close that gap, chosen deliberately over an
|
|
225
|
+
occurrence ordinal among same-labeled branches in the file (e.g.
|
|
226
|
+
"2nd `except ValueError` in this file"). Both carry a cost and
|
|
227
|
+
neither is free:
|
|
228
|
+
|
|
229
|
+
- **Line number** (chosen): a new branch cannot collide with an
|
|
230
|
+
existing key at all, short of landing on the exact line number a
|
|
231
|
+
deleted branch used to occupy — vanishingly unlikely, since that
|
|
232
|
+
requires a line-count-preserving edit that puts an unrelated new
|
|
233
|
+
branch at that exact spot. The cost is churn: an unrelated edit
|
|
234
|
+
that shifts a baselined branch down a few lines (an import added
|
|
235
|
+
above it, a docstring reflowed) makes its key change too, so it
|
|
236
|
+
reads as NEW and the gate cries wolf until `--write` re-accepts
|
|
237
|
+
it. `unexecuted()`'s own docstring already documents that this
|
|
238
|
+
script's line-based coverage join is shift-sensitive in exactly
|
|
239
|
+
this way, so this does not introduce a new fragility, only extends
|
|
240
|
+
an existing one from the coverage join into the baseline key.
|
|
241
|
+
- **Occurrence ordinal** (rejected): stable under a line shift
|
|
242
|
+
elsewhere in the file, but ambiguous under reordering. If a
|
|
243
|
+
baselined branch is removed and an unrelated new same-labeled
|
|
244
|
+
branch appears earlier in the file than a survivor, the survivor's
|
|
245
|
+
ordinal shifts onto the new branch's — reproducing this exact
|
|
246
|
+
issue by a different route, because an ordinal is still a
|
|
247
|
+
position, just a fragile relative one instead of a stable
|
|
248
|
+
absolute one.
|
|
249
|
+
|
|
250
|
+
Level reached: 3 (fail-closed) rather than 4 (detect-only) — a
|
|
251
|
+
distinct line number for every distinct AST node means a genuinely
|
|
252
|
+
new branch cannot be absorbed into an existing entry at all, not
|
|
253
|
+
merely flagged more often. Changing this format means every
|
|
254
|
+
instance's committed baseline must be regenerated; see the PR that
|
|
255
|
+
introduced this comment for the exact command.
|
|
256
|
+
"""
|
|
257
|
+
return f"{self.path}:{self.line}:{self.kind}:{self.label}"
|
|
208
258
|
|
|
209
259
|
|
|
210
260
|
def _handler_label(node: ast.ExceptHandler) -> str:
|