Skip to content

gh-56593: Document the difflib Match named tuple - #155598

Draft
Khan3K wants to merge 2 commits into
python:mainfrom
Khan3K:difflib-docs-match
Draft

gh-56593: Document the difflib Match named tuple#155598
Khan3K wants to merge 2 commits into
python:mainfrom
Khan3K:difflib-docs-match

Conversation

@Khan3K

@Khan3K Khan3K commented Aug 12, 2026

Copy link
Copy Markdown

The docs and docstrings described the results of SequenceMatcher.find_longest_match() and SequenceMatcher.get_matching_blocks() as plain (i, j, k) triples even though they are Match named tuples, and Match itself was not documented at all.

Changes:

  • Add a Match named tuple description to Doc/library/difflib.rst (fields a, b, size), mirroring how other named tuple types like struct_time are documented.
  • State the Match return type explicitly at the top of find_longest_match() and get_matching_blocks() in both the docs and the docstrings, and describe the no-match case as Match(alo, blo, 0).
  • Replace "lists of strings" with "sequences of strings" in the docs for make_file, make_table, context_diff, ndiff, and unified_diff, matching the actual behavior and the existing docstrings.

Linked PRs

@bedevere-app

bedevere-app Bot commented Aug 12, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@python-cla-bot

python-cla-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@read-the-docs-community

read-the-docs-community Bot commented Aug 12, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34030935 | 📁 Comparing a34e08c against main (ee68f5f)

  🔍 Preview build  

2 files changed
± library/difflib.html
± whatsnew/changelog.html

@StanFromIreland

Copy link
Copy Markdown
Member

You must sign the CLA before we can review.

@StanFromIreland
StanFromIreland marked this pull request as draft August 12, 2026 09:11
Khan3K added 2 commits August 12, 2026 19:23
The docs and docstrings described the results of SequenceMatcher's
find_longest_match() and get_matching_blocks() as plain (i, j, k)
triples even though they are Match named tuples, and Match itself was
not documented.  Add a description of Match to the docs, state the
return type explicitly in both methods, and clarify that the diff
functions accept sequences of strings rather than lists.
@Khan3K
Khan3K force-pushed the difflib-docs-match branch from 5c6dc38 to a34e08c Compare August 12, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants