astral-sh/ruff · error
The `{SECTION_CONFIG_SNAPSHOT}` directive does not take a va
Error message
The `{SECTION_CONFIG_SNAPSHOT}` directive does not take a value. What it means
In mdtest files, `<!-- snapshot-diagnostics -->` is a valueless section directive: the parser splits the HTML comment on ':' and rejects the directive when a value was supplied. It is an authoring error in the test markdown, not a behavior of the code under test.
Source
Thrown at crates/mdtest/src/parser.rs:615
const HTML_COMMENT_END: &[u8] = b"-->";
while let Some(first) = self.cursor.bump() {
match first {
'<' if self.cursor.eat_char3('!', '-', '-') => {
if let Some(position) =
memchr::memmem::find(self.cursor.as_bytes(), HTML_COMMENT_END)
{
let html_comment = self.cursor.as_str()[..position].trim();
let (directive, value) = match html_comment.split_once(':') {
Some((directive, value)) => {
(directive.trim(), Some(value.trim().to_string()))
}
None => (html_comment, None),
};
match directive {
SECTION_CONFIG_SNAPSHOT => {
anyhow::ensure!(
value.is_none(),
"The `{SECTION_CONFIG_SNAPSHOT}` directive \
does not take a value."
);
self.process_mdtest_directive(
MdtestDirective::SnapshotDiagnostics,
None,
)?;
}
SECTION_CONFIG_PULLTYPES => {
anyhow::ensure!(
value.is_none(),
"The `{SECTION_CONFIG_PULLTYPES}` directive \
does not take a value."
);
self.process_mdtest_directive(
MdtestDirective::PullTypesSkip,
None,View on GitHub (pinned to 672bb4edf0)
Solutions
- Remove the colon and value: use exactly `<!-- snapshot-diagnostics -->`
- Copy the directive syntax from a nearby passing mdtest file
Example fix
<!-- before --> <!-- snapshot-diagnostics: on --> <!-- after --> <!-- snapshot-diagnostics -->
Defensive patterns
Strategy: validation
Validate before calling
# reject valued forms of the directive in CI
! grep -rnE 'snapshot-diagnostics[[:space:]]*:[[:space:]]*[^[:space:]]' \
crates/ty_python_semantic/resources/mdtest/ || {
echo 'snapshot-diagnostics takes no value' >&2; exit 1;
} Prevention
- Write `<!-- snapshot-diagnostics -->` with no colon or value
- Copy directive syntax from existing passing mdtest files
- Run the mdtest suite locally (cargo nextest run -p ty_python_semantic --test mdtest) before pushing new tests
When it happens
Trigger: Writing `<!-- snapshot-diagnostics: on -->` or any text after a colon in the HTML comment form of the directive.
Common situations: Copy-pasting from keyed directives of other tools; assuming all mdtest directives take values; converting inline comments to HTML comment form and keeping a value.
Related errors
AI-assisted analysis of astral-sh/ruff@672bb4edf0 (2026-08-16).
Data as JSON: /api/errors/8d1f5eccc935c0de.
Report an issue: GitHub.