Inline backticks truncate fenced Python examples

Open
#94 1 comment 0 reactions 0 assignees View on GitHub

@vinsymoyya is already working on this.

Since Nov 13, 2026.

  • #95 by @vinsymoyya — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
markdown, python
Domain
testing

Research direction

Start from find_examples(path) and the closing-fence matching it uses to find where a fenced Python block ends. Reproduce with the four-backtick Markdown sample in the issue and check that .source keeps both statements. Done means closing fences match only on their own line, followed only by spaces or tabs, and the four regression cases pass. Pull request #95 is already open against this, so check it before starting.

Written by the indexing model from the issue text.

Description

Reproduced on main at df945f7043cb8c456359b01700f3d664d30fbe44.

A valid fenced Python example is truncated when its source contains inline triple backticks. The closing-marker expression matches those backticks anywhere, including inside a Python string. It also treats a line beginning with backticks followed by non-whitespace text as a closing marker.

Save this Markdown and inspect find_examples(path)[0].source:

```py
value = "```"
assert value == "```"
```

Actual source is value = ", which cannot compile. Expected source includes both complete Python statements. A closing fence must occupy its own line, followed only by spaces/tabs; see the fenced-code contract.

Four new regression cases fail before the fix, while two ordinary-example controls pass. Relevant open and closed extraction patches were compared; the prefix metadata work in #88 does not address closing markers.

Dominant language
Python
Stars
181
Forks
31
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pydantic/pytest-examples

All issues in pydantic/pytest-examples

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.