Skip to content

[mojo][stdlib] Use SomeTypeList where appropriate#6477

Open
christoph-schlumpf wants to merge 5 commits into
modular:mainfrom
christoph-schlumpf:use-SomeTypeList-where-appropriate
Open

[mojo][stdlib] Use SomeTypeList where appropriate#6477
christoph-schlumpf wants to merge 5 commits into
modular:mainfrom
christoph-schlumpf:use-SomeTypeList-where-appropriate

Conversation

@christoph-schlumpf
Copy link
Copy Markdown
Contributor

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

  • PR is small and focused — consider splitting larger changes into a
    sequence of smaller PRs
  • I ran ./bazelw run format to format my changes
  • I added or updated tests to cover my changes
  • If AI tools assisted with this contribution, I have included an
    Assisted-by: trailer in my commit message or this PR description
    (see AI Tool Use Policy)

Copilot AI review requested due to automatic review settings April 30, 2026 18:59
@christoph-schlumpf christoph-schlumpf requested review from a team as code owners April 30, 2026 18:59
@github-actions github-actions Bot added mojo-stdlib Tag for issues related to standard library waiting-on-review labels Apr 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-redundant Ts parameter docstrings.
  • Apply the same pattern to a few internal/builtin helpers (debug_assert, Error variadic 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.

Comment thread mojo/stdlib/std/python/python_object.mojo
Comment thread mojo/stdlib/docs/style-guide.md Outdated
@lsh
Copy link
Copy Markdown
Contributor

lsh commented Apr 30, 2026

!sync

@modularbot modularbot added the imported-internally Signals that a given pull request has been imported internally. label Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

imported-internally Signals that a given pull request has been imported internally. mojo-stdlib Tag for issues related to standard library waiting-on-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants