aws / aws/chalice

Set list as an item in MultiDict

Open
#2,105 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
11.1k
Forks
1k
Avg merge
1d 22h
Merged PRs (30d)
2

Description

It would be nice if there can be a way to set a list as an item in a MultiDict object.

This is currently only possible if you re-create the object.

Examples

```
from chalice.app import MultiDict
m = MultiDict(None)
m["a"] = ["a1", "a2"]
print(m)
// MultiDict({'a': [['a1', 'a2']]}) # list is inserted in a list
```

```
from chalice.app import MultiDict
m = MultiDict({"a": ["a1", "a2"]})
print(m)
// MultiDict({'a': ['a1', 'a2']}) # list is OK, as it was provided during object creation
```

So maybe the correct functionality for `__setitem__` would be the following:
```
from chalice.app import MultiDict
m = MultiDict(None)
m["a"] = ["a1", "a2"]
print(m)
// MultiDict({'a': ['a1', 'a2']})
```

Contributor guide

Open the contributing guide

Research direction

Start with the MultiDict class in chalice.app and inspect its current __setitem__ behavior alongside construction from an initial mapping. Reproduce the examples in the issue, then add or update a regression test covering assignment of a list and confirming the resulting values match construction-time behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.