Not working list[str] field
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
Research direction
Start by running tmp.conao3/04_list.sample.py with poetry run python tmp.conao3/04_list.sample.py to reproduce the failure while defining GrapheneModel. Trace how the list[str] field is converted and ensure the schema can be created and {model {field}} executes without the mutable-default error.
Written by the indexing model from the issue text.
Description
I found graphene-pydantic fails converting list[str] field.
import graphene
import pydantic
import graphene_pydantic
class Model(pydantic.BaseModel):
field: list[str] = []
class GrapheneModel(graphene_pydantic.PydanticObjectType):
class Meta:
model = Model
class Query(graphene.ObjectType):
model = graphene.Field(GrapheneModel)
hello = graphene.String()
@staticmethod
def resolve_model(parent, info):
return Model()
schema = graphene.Schema(query=Query)
print(schema)
print(schema.execute('{model {field}}'))
saved as tmp.conao3/04_list.sample.py and run like this
$ poetry run python tmp.conao3/04_list.sample.py
then, you see error.
Traceback (most recent call last):
File "/home/conao/dev/forks/graphene-pydantic/tmp.conao3/04_list.sample.py", line 11, in <module>
class GrapheneModel(graphene_pydantic.PydanticObjectType):
File "/home/conao/dev/forks/graphene-pydantic/.venv/lib/python3.10/site-packages/graphene/types/objecttype.py", line 45, in __new__
dataclass = make_dataclass(name_, fields, bases=())
File "/usr/lib/python3.10/dataclasses.py", line 1401, in make_dataclass
return dataclass(cls, init=init, repr=repr, eq=eq, order=order,
File "/usr/lib/python3.10/dataclasses.py", line 1185, in dataclass
return wrap(cls)
File "/usr/lib/python3.10/dataclasses.py", line 1176, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash,
File "/usr/lib/python3.10/dataclasses.py", line 956, in _process_class
cls_fields.append(_get_field(cls, name, type, kw_only))
File "/usr/lib/python3.10/dataclasses.py", line 813, in _get_field
raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'list'> for field field is not allowed: use default_factory
I use now main(2fd67a8) and I use Python3.10
- Dominant language
- Python
- Stars
- 249
- Forks
- 47
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from graphql-python/graphene-pydantic
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
graphql-python/graphene-pydantic#116 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
graphql-python/graphene-pydantic#111 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
graphql-python/graphene-pydantic#107 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
All issues in graphql-python/graphene-pydantic
Similar issues
-
[BUG] Container scenario crashes without expected_recovery_time, kube DNS example uses retry_waitOpenneeds-triage
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
krkn-chaos/krkn#1627 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NousResearch/hermes-agent#136483 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
[BUG] LazyStackedTensorDictStore zeroes the last byte of a new key set on the last elementPossibly taken @peterdsharpe claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pytorch/tensordict#2307 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day