Repository navigation
Conversation
MTable(notes=None) renders in LaTeX, Typst and HTML, which all check for None explicitly, but DOCX passed self.notes straight to the symbol translator and python-docx and raised "TypeError: 'NoneType' object is not iterable". DOCX now treats None like an empty note, keeping the (empty) notes row it always adds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
What problem do you want to solve?
MTable(notes=None)works in every format except DOCX.On
main,tex,typstandgtsucceed.docxraisesTypeError: 'NoneType' object is not iterable. The LaTeX renderer (if self.notes is not None), Typst ("" if self.notes is None else ...) and great_tables all handleNoneexplicitly. DOCX passesself.notesstraight to_translate_symbolsand python-docx.Expected: DOCX output also succeeds.
Fix
DOCX treats
Nonelike an empty note. The notes row that DOCX always adds is kept, so the table layout is the same as withnotes="". That matters because the font-size loop identifies the notes row as the last row.Tests
New tests in
tests/api/test_mtable_outputs.py:test_notes_none_is_accepted_by_every_format, parametrized over the four formats;test_docx_notes_none_matches_empty_notes, which checks that the DOCX table is identical fornotes=Noneandnotes="".2 of the 5 cases fail on
main(both DOCX) and all 5 pass with the fix.pre-commit run --files <changed>andty checkare clean.Open question
MTable.__init__annotatesnotes: str, but three renderers already treatNoneas "no notes". Widening the annotation tostr | Nonewould document what the code does. It is left unchanged here to keep this PR to the bug.🤖 Generated with Claude Code