[mojo][stdlib] Use SomeTypeList where appropriate#6477
Open
christoph-schlumpf wants to merge 5 commits into
Open
[mojo][stdlib] Use SomeTypeList where appropriate#6477christoph-schlumpf wants to merge 5 commits into
christoph-schlumpf wants to merge 5 commits into
Conversation
Signed-off-by: Christoph Schlumpf <[email protected]>
Signed-off-by: Christoph Schlumpf <[email protected]>
Signed-off-by: Christoph Schlumpf <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Mojo stdlib to prefer *SomeTypeList[...] for variadic packs when the named type list isn’t otherwise reused, and documents that guidance in the style guide.
Changes:
- Add a style guide section recommending
*SomeTypeList[...]over named type lists when the type list is not reused. - Refactor multiple stdlib APIs (e.g.,
print,Writer.write, logging helpers, formatting helpers) to use*SomeTypeList[...]and remove now-redundantTsparameter docstrings. - Apply the same pattern to a few internal/builtin helpers (
debug_assert,Errorvariadic ctor, closure keepalive helper).
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| mojo/stdlib/std/utils/index.mojo | Refactors Index(...) variadic pack to *SomeTypeList[Intable] and drops Ts docs. |
| mojo/stdlib/std/testing/suite.mojo | Refactors _writeln to use *SomeTypeList[Writable]. |
| mojo/stdlib/std/tempfile/tempfile.mojo | Refactors NamedTemporaryFile.write variadic pack and removes Ts doc section. |
| mojo/stdlib/std/python/python_object.mojo | Refactors list-literal PythonObject.__init__ variadic pack to *SomeTypeList[...]. |
| mojo/stdlib/std/logger/logger.mojo | Refactors logging methods to accept *SomeTypeList[Writable] and removes Ts doc sections. |
| mojo/stdlib/std/io/io.mojo | Refactors print and _printf_cpu variadic packs to *SomeTypeList[...] and removes Ts docs. |
| mojo/stdlib/std/io/file.mojo | Refactors FileHandle.write variadic pack and removes Ts doc section. |
| mojo/stdlib/std/format/_utils.mojo | Refactors _SequenceWriter.write variadic pack to *SomeTypeList[Writable]. |
| mojo/stdlib/std/format/init.mojo | Updates Writer.write to accept *SomeTypeList[Writable] and removes Ts docs. |
| mojo/stdlib/std/collections/string/string_slice.mojo | Refactors StringSlice.format variadic pack and removes Ts doc section. |
| mojo/stdlib/std/collections/string/string.mojo | Refactors String.format variadic pack and removes Ts doc section. |
| mojo/stdlib/std/collections/string/format.mojo | Refactors _FormatUtils.format variadic pack and removes Ts docs for that API. |
| mojo/stdlib/std/builtin/string_literal.mojo | Refactors StringLiteral.format variadic pack and removes Ts doc section. |
| mojo/stdlib/std/builtin/error.mojo | Refactors variadic Error.__init__ to *SomeTypeList[Writable] and removes Ts docs. |
| mojo/stdlib/std/builtin/debug_assert.mojo | Refactors variadic message packs to *SomeTypeList[Writable] and removes Ts docs. |
| mojo/stdlib/std/builtin/_closure.mojo | Refactors __ownership_keepalive variadic pack to *SomeTypeList[AnyType]. |
| mojo/stdlib/docs/style-guide.md | Adds guidance for when to use *SomeTypeList[...] vs named type lists. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Contributor
|
!sync |
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.
Summary
Added a style guide section on
*SomeTypeList[]and refactored the stdlib accordingly.This removes many unneeded parameter declarations and corresponding docstrings.
Assisted-by: AI
Testing
There are no functional changes to the code so the current tests must still work unchanged.
Checklist
sequence of smaller PRs
./bazelw run formatto format my changesAssisted-by:trailer in my commit message or this PR description(see AI Tool Use Policy)