Skip to content

rx.Var.create(x)._replace(_var_data=...) raises "TypeError: dataclasses.replace() got multiple values for keyword argument '_var_data'" #7256

Description

@masenf

Describe the bug

Var._replace documents _var_data as a replaceable field, but passing it raises because _replace already supplies _var_data (merged from the existing var) to dataclasses.replace() and the caller's keyword is passed a second time.

To Reproduce

import reflex as rx
from reflex.vars import VarData

v = rx.Var.create(5)
v._replace(_var_data=VarData(imports={}))
# TypeError: dataclasses.replace() got multiple values for keyword argument '_var_data'

rx.Var.create(5, _var_data=VarData(...)) works.

Expected behavior

_replace(_var_data=...) replaces (or merges) the var data, or the signature rejects the keyword with a message that points at merge_var_data / Var.create(..., _var_data=...).

Specifics

  • Reflex 0.9.12a1 (reflex-base 0.9.12a1); pre-existing, identical on 0.9.11.post1
  • Python 3.11.15

Additional context

0.9.12a1 pre-release QA, vars_typing cluster, observation O5 in vars_typing/NOTES.md. Related: #3531 tightened the accepted _replace kwargs.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions