Skip to content

Commit 80fdfbe

Browse files
Technologicatclaude
andcommitted
the[]: restore the intent-documenting nuance
I had rewritten "optional, although allowed (to explicitly document intent)" into a preference for the shorter form, on the grounds that the docstring disagreed with `CLAUDE.md`. That resolved the tension in the wrong direction: an explicit mark on an auto-captured LHS is mechanically redundant but can still tell a *reader* which value the test is about, and that is sometimes worth the characters. The original wording said exactly this, so it is restored. The "Common mistakes" list keeps only the cases that are actually wrong — the three that capture a value nobody wants to see. The redundant-LHS case is not one of them, and is left to the passage above, which permits it. Also prefixes the changelog entry with the module it concerns. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent be00126 commit 80fdfbe

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
**Fixed**:
1010

11-
- `the[]`'s docstring now covers the common `the[]` mistakes — marking the whole assertion (which captures the boolean and hides the value you wanted), and under-marking a chained comparison — with the fix for each. Previously these were written down only in the project's own `CLAUDE.md`, where library users never see them.
11+
- `unpythonic.test.fixtures`: `the[]`'s docstring now covers the common `the[]` mistakes — marking the whole assertion (which captures the boolean and hides the value you wanted), and under-marking a chained comparison — with the fix for each. Previously these were written down only in the project's own `CLAUDE.md`, where library users never see them.
1212
- The macro documentation now warns that `begin`/`begin0` are not recognized by the macro layer, so macro-enabled code should sequence with `do[]`/`do0[]`. The functions' own docstrings already said so; the macro docs, where a macro user actually reads, did not.
1313
- `env` now documents that it must be imported as `from unpythonic.env import env` — the module shares the class's name, so `from unpythonic import env` yields the module and `env(x=1)` then fails with an error that does not hint at the cause.
1414
- `amb.forall` now points at the `unpythonic.syntax.forall` macro as the clean design of the same feature, and notes that "nondeterministic" here is the `amb` sense (every branch explored) rather than the modern colloquial one (stochastic).

unpythonic/syntax/testingtools.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def the(tree, **kw):
6565
6666
Note the above rules mean that if there is just one interesting
6767
subexpression, and it is the leftmost term of a comparison, `the[...]`
68-
is unnecessary. It is allowed, and has no effect on behavior, but the
69-
shorter form is preferred. These have the same effect::
68+
is optional, although allowed (to explicitly document intent).
69+
These have the same effect::
7070
7171
test[the[computeitem(...)] in myitems]
7272
test[computeitem(...) in myitems]
@@ -87,9 +87,6 @@ def the(tree, **kw):
8787
test[x == 42]
8888
test[the[a] < the[b] < the[c]]
8989
90-
Marking an already-auto-captured LHS, as in ``test[the[x] == 42]``, is
91-
harmless but redundant; prefer ``test[x == 42]``.
92-
9390
The question to ask is *what value would I want to see if this failed?*, then
9491
mark that. The answer is sometimes the container rather than the leaf: in
9592
``test[the[response]["status"] == "ok"]``, auto-capture would report only

0 commit comments

Comments
 (0)