typing: relax ChangelogSourceDict / ChangelogChangeSectionsDict to allow arbitrary section keys#4500
Draft
Copilot wants to merge 2 commits into
Draft
typing: relax ChangelogSourceDict / ChangelogChangeSectionsDict to allow arbitrary section keys#4500Copilot wants to merge 2 commits into
ChangelogSourceDict / ChangelogChangeSectionsDict to allow arbitrary section keys#4500Copilot wants to merge 2 commits into
Conversation
✅ Deploy Preview for nifty-bassi-e26446 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…ogDict Agent-Logs-Url: https://github.com/envoyproxy/toolshed/sessions/d7835675-0801-4fe7-a03a-3facaa53ff97 Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Relax ChangelogSourceDict and ChangelogChangeSectionsDict typing
typing: relax May 11, 2026
ChangelogSourceDict / ChangelogChangeSectionsDict to allow arbitrary section keys
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.
ChangelogSourceDictandChangelogChangeSectionsDicthard-coded the seven current changelog section names asTypedDictfields, blocking a per-entry directory reader where sections are arbitrary runtime-validated strings.Changes
ChangelogSourceDict→dict[str, Any]TypedDictcannot mix a required typeddatefield with arbitrary string keys, so a plain alias is the correct shape.ChangelogChangeSectionsDict→dict[str, ChangeList]Section name → list-of-entries mapping with no hard-coded keys.
ChangelogDict→dict[str, Any]Previously inherited from both
BaseChangelogDictandChangelogChangeSectionsDict;TypedDictcannot inherit from a plain dict alias, so collapsed to a dict alias. Thecast(typing.ChangelogDict, …)site inAChangelog.get_data()is unaffected.Removed the
# This should match envoy:changelogs/sections.yamlcomments; section validation is now a runtime concern.Purely a typing change — no behavioural impact.
Original prompt
Toolshed PR 1 — Relax
ChangelogSourceDict/ChangelogChangeSectionsDicttypingThis is the first PR in the implementation plan for per-entry changelog layout support (see issue #4498 and plan at
plans/per-entry-changelog-4498.md, PR #4499 for full context).Background
Envoy is migrating from a single monolithic
changelogs/current.yamlto a per-entry layout:Where
<section>must match a key inchangelogs/sections.yaml. To support this in toolshed, the section names need to be treated as arbitrary runtime-validated strings rather than hard-coded type system keys.Problem
In
py/envoy.base.utils/envoy/base/utils/typing.py:ChangelogSourceDictis aTypedDictthat hard-codes the seven current section names (changes,behavior_changes,minor_behavior_changes,bug_fixes,removed_config_or_runtime,new_features,deprecated) plusdate.ChangelogChangeSectionsDictrepeats the same hard-coded set.# This should match envoy:changelogs/sections.yaml.With per-entry files, sections become arbitrary directory names that are validated at runtime against
changelogs/sections.yaml. Hard-coding them in the type system blocks PR 2 (the per-entry directory reader) which produces aChangelogDictwhose section keys are not statically known.Required changes
In
py/envoy.base.utils/envoy/base/utils/typing.py:ChangelogChangeSectionsDictso it represents an arbitrary mapping of section name → list ofChangelogChangeDict. The cleanest approach is a type alias:typing.Dict/Listvs PEP 585dict/list— matches the rest of the file.)ChangelogSourceDictso it carries a requireddatefield plus arbitrary section keys mapping toList[ChangelogChangeDict]. SinceTypedDictcannot mix a typeddatefield with arbitrary string keys, the simplest correct shape is also a plain mapping alias, e.g.:TypedDictwith onlydatetyped and rely on the runtime parser to validate sections. Pick whichever is least disruptive to existing call sites; the goal is simply that arbitrary section names no longer trigger type errors.# This should match envoy:changelogs/sections.yamlcomment (or rephrase it to point at the runtime validator).Verify the only consumer of these types — the
cast(ChangelogSourceDict, ...)site inAChangelog.get_data()around line 135 ofpy/envoy.base.utils/envoy/base/utils/abstract/project/changelog.py— still type-checks. No behavioural change is expected.Run
mypyoverpy/envoy.base.utilsand fix any fallout (there should be none beyond the cast site).Constraints
changelog.pyparsing logic — that comes in PR 2.TypedDictshape (it shouldn't).envoy.base.utils) must remain green.Acceptance criteria
ChangelogSourceDictandChangelogChangeSectionsDictno longer enumerate the seven hard-coded section keys.mypypasses forpy/envoy.base.utils.py/envoy.base.utilstests pass unchanged.envoy:changelogs/sections.yamlis removed or updated.Reference
plans/per-entry-changelog-4498.md(PR 1 section)py/envoy.base.utils/envoy/base/utils/typing.pypy/envoy.base.utils/envoy/base/utils/abstract/project/changelog.py(verify cast site only)The following is the prior conversation context from the user's chat exploration (may be truncated):
User: seems like we have a plan @envoyproxy/toolshed/files/plans/per-entry-changelog-4498.md
see also @envoyproxy/toolshed/pull/4499 @envoyproxy/toolshed/issues/4498
where do we start
Assistant: Per the plan's suggested landing order, you start with Toolshed PR 1: relax the TypedDict typing in
py/envoy.base.utils/envoy/base/utils/typing.py.Why start there
It's the safest, most isolated change:
ChangelogSourceDict/ChangelogChangeSectionsDictto not hard-code the seven section keys, since with per-entry files sections become arbitrary directory names validated againstchangelogs/sections.yamlat runtime.cast()target inAChangelog.get_data()(line 135 ofchangelog.py); parsed values are unchanged.What PR 1...
This pull request was created from Copilot chat.