Fix coverage gap in serialize_sequence_value continue statement#14933
Merged
tiangolo merged 3 commits intomodern-typesfrom Feb 17, 2026
Merged
Fix coverage gap in serialize_sequence_value continue statement#14933tiangolo merged 3 commits intomodern-typesfrom
tiangolo merged 3 commits intomodern-typesfrom
Conversation
Updated test_serialize_sequence_value_with_none_first_in_union to use Union[None, list[str]] instead of list[str] | None to ensure None appears first in union args, which properly tests the continue statement at line 316 in fastapi/_compat/v2.py. Co-authored-by: tiangolo <[email protected]>
Copilot
AI
changed the title
[WIP] Update typing syntax for Python 3.10
Fix coverage gap in serialize_sequence_value continue statement
Feb 17, 2026
tiangolo
approved these changes
Feb 17, 2026
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.
Line 316 in
fastapi/_compat/v2.pywas untested, causing coverage to fail at 99%. The line is acontinuestatement that skipsNoneTypewhen iterating union args inserialize_sequence_value.Root Cause
Existing tests used
list[str] | None, which orders union args as(list[str], NoneType). The loop processeslist[str]first and breaks, never reaching thecontinuestatement forNoneType.Changes
test_serialize_sequence_value_with_none_first_in_unionto use explicitUnion[None, list[str]]syntaxNoneTypefirst in union args, exercising the continue statement before processing the list typeCoverage now reaches 100%.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.