Use Sequence instead of list in compose[_to_dict] - #966
Merged
Conversation
maddenp-cu
marked this pull request as ready for review
August 24, 2026 23:16
maddenp-cu
requested review from
christinaholtNOAA and
elcarpenterNOAA
as code owners
August 24, 2026 23:16
elcarpenterNOAA
approved these changes
Aug 24, 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.
Synopsis
I've run into a typing issue a couple of times now, most recently in AIGFS work, that looks something like this:
demo.pyHere,
mypyinfers the type ofconfigsto belist[str]. Fair enough. But alistis mutable, and type type on the other side of the call islist[str | Path], which means that the called code could e.g.But the calling code believes that all the items in its
listarestrobjects, so that it could be able to e.g.But
Pathdoes not have a.swapcase. Somypyflags this as an error.The
Sequencetype doesn't claim to support mutating operations (e.g..append), so typingconfigs: Sequence[str | Path]is a promise to not mutateconfigs, while solves the issuemypyis flagging.In short, this makes the
composeandcompose_to_dictfunctions friendlier to users by making it less likely for typechecking they might perform to flag a (probably non-existent) issue.Type
Impact
Checklist