
    Xj                     l    d dl mZmZmZmZmZmZmZ d dlm	Z	m
Z
mZ dee	   dededede
ee	f   de	fd	Zy
)    )_FIELD_INITVAR_HAS_DEFAULT_FACTORY_POST_INIT_NAMEMISSING
_create_fn_field_init_init_param)AnyDictListfieldsfrozenhas_post_init	self_nameglobals_returnc                    | D ci c]  }d|j                    |j                   }}|j                  t        t        d       g }| D ]$  }t        ||||      }|s|j                  |       & |r6dj                  d | D              }	|j                  | dt         d|	 d       |sdg}| D cg c]  }|j                  st        |       }
}t        |
      d	kD  rd
g|
}
t        d|g|
|||d      S c c}w c c}w )a  Create an __init__ function for a dataclass.

    We create a custom __init__ function for the dataclasses that back
    Strawberry object types to only accept keyword arguments. This allows us to
    avoid the problem where a type cannot define a field with a default value
    before a field that doesn't have a default value.

    An example of the problem:
    https://stackoverflow.com/questions/51575931/class-inheritance-in-python-3-7-dataclasses

    Code is adapted from:
    https://github.com/python/cpython/blob/v3.9.6/Lib/dataclasses.py#L489-L536

    Note: in Python 3.10 and above we use the `kw_only` argument to achieve the
    same result.
    _type_)r   r   ,c              3   Z   K   | ]#  }|j                   t        u s|j                   % y w)N)_field_typer   name).0fs     s/var/www/html/myl_app/scheduler-service/venv/lib/python3.12/site-packages/strawberry/ext/dataclasses/dataclasses.py	<genexpr>z$dataclass_init_fn.<locals>.<genexpr><   s     X8WaffXs   ++.()passr   *__init__N)localsglobalsreturn_type)r   typeupdater   r   r   appendjoinr   initr	   lenr   )r   r   r   r   r   r   locals_
body_linesline
params_str_init_paramss              r   dataclass_init_fnr1      s*   2 399Qx !&&(9G9NN$8	
 J $1fgy9 d#$ XXXfXX
YKq(9:,aHI X
,2=qaffKN=L=
<1+l+	"\" ; :2 >s   !C80C=C=N)dataclassesr   r   r   r   r   r   r	   typingr
   r   r   boolstrr1        r   <module>r8      se   
   # "=I== = 	=
 38n= 	=r7   