Skip to content

Conversation

@BobTheBuidler
Copy link
Contributor

Built on top of, and blocked by, #19970.
Will rebase once 19970 is merged and then mark this one as ready.

@BobTheBuidler BobTheBuidler marked this pull request as ready for review January 18, 2026 13:04
def g() -> str:
return FMT_D.format(400 + 20, "roll" + "up")
def h() -> str:
return FMT_S.format(400 + 20, "roll" + "up")
Copy link
Collaborator

Choose a reason for hiding this comment

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

In Python, {:s} appears to only support str values. There is no implicit conversion to strings:

>>> '{:s}'.format(2)
Traceback (most recent call last):
  File "<python-input-7>", line 1, in <module>
    '{:s}'.format(2)
    ~~~~~~~~~~~~~^^^
ValueError: Unknown format code 's' for object of type 'int'

I think we should have similar checks to support :s in a compatible way, or apply the optimization if the static type of the corresponding operand is builtins.str perhaps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, how's this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants