Skip to content

Fix str() + Content()#6160

Merged
willmcgugan merged 3 commits into
Textualize:mainfrom
gvx:main
Oct 11, 2025
Merged

Fix str() + Content()#6160
willmcgugan merged 3 commits into
Textualize:mainfrom
gvx:main

Conversation

@gvx

@gvx gvx commented Oct 5, 2025

Copy link
Copy Markdown
Contributor

Content.__radd__ does not currently behave as expected. For example:

>>> from textual.content import Content
>>> Content('foo') + 'bar'  # works as expected
Content('foobar')
>>> 'foo' + Content('bar') # expected: Content('foobar')
Content('barfoo')

The problem is that Content.__radd__ (which implements other + self) returns self + other, which is incorrect for concatenation. This pull requests fixes that and adds tests for it. (Existing tests only test for the empty string, for which a + b == b + a happens to hold, unlike most strings.)

@willmcgugan

Copy link
Copy Markdown
Member

thanks

@willmcgugan willmcgugan merged commit f1c6bec into Textualize:main Oct 11, 2025
22 checks passed
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