Repository navigation
fix(snippets): number terminal snippets from their first line - #637
Merged
Bachmann1234 merged 1 commit intoSep 25, 2026
Merged
Conversation
Pygments' TerminalFormatter ignores linenostart, so --show-uncovered printed every snippet as starting at line 1. Render without line numbers and add them here, in the same 0001: form. Fixes Bachmann1234#283
Owner
|
Thanks for the fix! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #283.
--show-uncoveredprints each snippet with line numbers, but in the terminal they always started at0001, while the HTML and Markdown reports number the same snippet from its real first line.Snippet.terminal()passeslinenostartto Pygments'TerminalFormatter, and that formatter ignores the option (it is only honoured by the HTML formatter). Checked with the current Pygments, 2.21.0:This renders the snippet with
TerminalFormatterbut without line numbers, and adds them interminal()in the same%04d:form, starting at the snippet's first line. The output is otherwise unchanged, including the trailing numbered empty line thatshow_uncovered_lines_console.txtexpects, so the existing integration test passes as is.Tests:
test_terminal_numbers_lines_from_start_linebuilds a snippet that starts at line 217 and checks that its lines are0217:,0218:,0219:. Onmainit fails:A second test pins the numbering for a snippet at the top of the file.
Full suite in a clean container: 389 passed with the change and 387 on
main. The same 18TestDiffQualityIntegrationtests fail on both, because that environment does not have the quality tools (pylint, pyflakes and so on) installed.