Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Implement __radd__ for ListConfig #849

Closed
Jasha10 opened this issue Jan 21, 2022 · 0 comments · Fixed by #850
Closed

Implement __radd__ for ListConfig #849

Jasha10 opened this issue Jan 21, 2022 · 0 comments · Fixed by #850
Labels
easy enhancement New feature or request good first issue Good for newcomers listconfig

Comments

@Jasha10
Copy link
Collaborator

Jasha10 commented Jan 21, 2022

Is your feature request related to a problem? Please describe.
Currently this works:

>>> cfg = OmegaConf.create([1, 2])
>>> cfg + [3]
[1, 2, 3]

But this does not work:

>>> cfg = OmegaConf.create([1, 2])
>>> [3] + cfg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "ListConfig") to list

Describe the solution you'd like
The second case above could be made to work by implementing ListConfig.__radd__.
The __radd__ dunder method handles "adding from the right".

Additional context
This came up in discussion #848.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
easy enhancement New feature or request good first issue Good for newcomers listconfig
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant