Skip to content

Commit 4c31d39

Browse files
committed
make the[] error out in invalid position at macro expansion time
1 parent bb434c5 commit 4c31d39

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

unpythonic/syntax/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@
127127

128128
# TODO: Upgrade anaphoric if's `it` into a `mcpyrate` magic variable that errors out at compile time when it appears in an invalid position (i.e. outside any `aif`). Basically, take the `aif` from `mcpyrate`.
129129
# TODO: also let_syntax block, expr
130-
# TODO: also the[] in unpythonic.syntax.testingtools
131130
# TODO: also kw() in unpythonic.syntax.prefix
132131
# TODO: also call_cc[] in unpythonic.syntax.tailtools
133132

unpythonic/syntax/testingtools.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,7 @@ def warn_expr(tree):
357357
# -----------------------------------------------------------------------------
358358
# Expr variants.
359359

360-
# TODO: convert to mcpyrate magic variable (to raise error when in inappropriate position)
361-
def the(*args, **kwargs):
360+
def the(tree, **kw):
362361
"""[syntax, expr] In a test, mark a subexpression as the interesting one.
363362
364363
Only meaningful inside a `test[]`, or inside a `with test` block.
@@ -403,7 +402,7 @@ def the(*args, **kwargs):
403402
404403
For `test_raises` and `test_signals`, the `the[...]` mark is not supported.
405404
"""
406-
pass # pragma: no cover, macro stub
405+
raise SyntaxError("the[] is only meaningful inside a `test[]` or in a `with test` block") # pragma: no cover, not meant to hit the expander
407406

408407
# Destructuring utilities for marking a custom part of the expr
409408
# to be displayed upon test failure, using `the[...]`:

0 commit comments

Comments
 (0)