Repository navigation
Python: Make Content base64 documentation examples runnable - #9467
Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits intoOct 22, 2026
Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
Conversation
Contributor
Author
|
@microsoft-github-policy-service agree |
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Oct 22, 2026
Eduard van Valkenburg (eavanvalkenburg)
left a comment
Member
There was a problem hiding this comment.
The corrected examples are valid across the supported Python versions: the base64 string decodes to the PNG signature, media-type detection succeeds, and the simplified data-URI f-string is runnable with the required import.
This branch was successfully 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.
Motivation & Context
The
Content.from_data()documentation example raisesValueError: Invalid base64 data provided.when copied because its placeholder is truncated. This follow-up completes the same documentation repair already in this PR: thefrom_uri()example also needed its detector import, a supported f-string, and decodable example data.Description & Review Guide
from_data()example and thefrom_uri()prose. The combined PR also importsdetect_media_type_from_base64and assigns the media type before constructing the URI.Fresh verification against this PR's previous published head reproduces one genuine
from_data()failure. The existing completefrom_uri()and metadata predicate examples pass as positive controls; their behavior was not changed. All three final docstring examples execute using public imports and compile under real Python 3.10 and 3.11 interpreters. All 478 owning tests inpackages/core/tests/core/test_types.py -m "not integration"pass with no failures or skips. Scoped checks and the real source commit's normal pre-commit hook pass. The full workspace test suite and image decoding were not run. Exact follow-up source verification.The original URI syntax/import reproduction belongs to the earlier verification. The fresh result above does not count those earlier failures again.
Related Issue
N/A - trivial change. This is an obvious correction to broken documentation examples, with no runtime behavior change. The complete open-PR changed-path audit and matching diffs contain no competing repair beyond this existing PR.
AI Assistance
AI assistance details: OpenAI Codex assisted with diagnosis, documentation corrections, regression verification, and this description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) - a workflow keeps the label and title prefix in sync automatically.