Skip to content

Commit e06517a

Browse files
committed
chore: Shorten the let identifier cap comments
The rationale lives in the commit message, the PR description and the design note. The code only needs the citation and the one fact a reader editing this line must not miss: the cap is flat, so it is not the FEATURE_BUNDLE_1-gated section 7.1 cap. Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
1 parent dc7ba49 commit e06517a

2 files changed

Lines changed: 8 additions & 21 deletions

File tree

‎src/openjd/model/v2023_09/_model.py‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -921,17 +921,9 @@ class ScriptInterpreter(str, Enum):
921921
LET_MAX_BINDINGS = 50
922922
_LET_NAME_RE = re.compile(r"^[a-z_][A-Za-z0-9_]*$")
923923

924-
# §3.6.1: the maximum length of a `let` binding's `<UserIdentifier>`.
925-
#
926-
# Flat 512, deliberately not the §7.1 `<Identifier>` cap that
927-
# `NameIdentifierLengthMixin` and the inline
928-
# `512 if "FEATURE_BUNDLE_1" in context.extensions else 64` checks apply. §3.6.1
929-
# states one maximum for a `<UserIdentifier>` and does not gate it on an
930-
# extension, and the conformance pair proves the flat reading:
931-
# `EXPR/job_templates/3.6--let-boundary-edges.yaml` declares `EXPR` alone and
932-
# requires a 512-character name to be accepted, so borrowing the §7.1 cap would
933-
# limit it to 64 and reject a template the spec permits. EXPR gates whether
934-
# `let` exists at all and moves neither cap.
924+
# §3.6.1: maximum length of a `let` binding's `<UserIdentifier>`. Flat, so not
925+
# the §7.1 cap NameIdentifierLengthMixin applies: that one is 64 without
926+
# FEATURE_BUNDLE_1, and a 512-character name must be accepted with EXPR alone.
935927
LET_MAX_IDENTIFIER_LEN = 512
936928

937929

@@ -954,8 +946,7 @@ def parse_let_bindings(value: Any) -> list[tuple[str, str]]:
954946
expr = expr.strip()
955947
if not _LET_NAME_RE.match(name):
956948
raise ValueError(f"A 'let' binding name must be a valid identifier: {name!r}")
957-
# The name is not interpolated into the message: at 513 characters it
958-
# would dwarf the diagnostic.
949+
# Name omitted from the message; at 513 characters it would dwarf it.
959950
if len(name) > LET_MAX_IDENTIFIER_LEN:
960951
raise ValueError(
961952
f"A 'let' binding name must be at most {LET_MAX_IDENTIFIER_LEN} characters long"

‎test/openjd/model_v0/v2023_09/test_let_bindings.py‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def test_script_let(self):
4141
_job([{"name": "S", "script": {"let": ["a = 2"], **_onrun("{{a}}")}}]),
4242
)
4343

44-
# §3.6.1 boundary: 512 characters is the maximum and must be accepted. With
45-
# EXPR alone, because the cap does not depend on FEATURE_BUNDLE_1.
44+
# §3.6.1 boundary: 512 characters is the maximum and must be accepted, with
45+
# EXPR alone, since the cap does not depend on FEATURE_BUNDLE_1.
4646
def test_name_512_chars(self):
4747
name = "a" * 512
4848
_decode(_job([{"name": "S", "let": [f"{name} = 1"], "script": _onrun("hi")}]))
@@ -117,12 +117,8 @@ def test_self_reference(self):
117117
with pytest.raises(DecodeValidationError, match="cannot reference itself"):
118118
_decode(_job([{"name": "S", "let": ["x = x + 1"], "script": _onrun("hi")}]))
119119

120-
# §3.6.1: a `<UserIdentifier>` is at most 512 characters. The cap is flat,
121-
# not the FEATURE_BUNDLE_1-gated §7.1 `<Identifier>` cap, so the accept case
122-
# must hold with EXPR alone. `_job` declares EXPR only by default, which is
123-
# what the conformance fixture
124-
# `EXPR/job_templates/3.6--let-boundary-edges.yaml` asserts; the
125-
# `_with_fb1` variants pin that declaring FEATURE_BUNDLE_1 does not move it.
120+
# §3.6.1 caps a `<UserIdentifier>` at 512 characters. `_job` declares EXPR
121+
# alone, so these pin the cap independently of FEATURE_BUNDLE_1.
126122
def test_name_513_chars(self):
127123
name = "a" * 513
128124
with pytest.raises(DecodeValidationError, match="at most 512 characters"):

0 commit comments

Comments
 (0)