+\h RdZddlmZddlmZddlmZmZmZm Z m Z Gdde Z y)z/Tools for representing JavaScript code in BSON.) annotations)Mapping)AnyrOptionalTypeUnioncveZdZUdZdZded< d ddZeddZdd Z dd Z dZ ded <dd Z y)CodeaGBSON's JavaScript code type. Raises :class:`TypeError` if `code` is not an instance of :class:`str` or `scope` is not ``None`` or an instance of :class:`dict`. Scope variables can be set by passing a dictionary as the `scope` argument or by using keyword arguments. If a variable is set as a keyword argument it will override any setting for that variable in the `scope` dictionary. :param code: A string containing JavaScript code to be evaluated or another instance of Code. In the latter case, the scope of `code` becomes this Code's :attr:`scope`. :param scope: dictionary representing the scope in which `code` should be evaluated - a mapping from identifiers (as strings) to values. Defaults to ``None``. This is applied after any scope associated with a given `code` above. :param kwargs: scope variables can also be passed as keyword arguments. These are applied after `scope` and `code`. .. versionchanged:: 3.4 The default value for :attr:`scope` is ``None`` instead of ``{}``. zUnion[Mapping[str, Any], None] _Code__scopeNrc t|tstdt|tj ||} |j |_|Vt|tstdt||j |j j|n||_|r0|j |j j||S||_|S#t$r d|_YwxYw)Nz%code must be an instance of str, not z'scope must be an instance of dict, not ) isinstancestr TypeErrortype__new__scoper AttributeError_Mappingupdate)clscoderkwargsselfs L/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/bson/code.pyrz Code.__new__4s $$CDJ<PQ Q{{3% ::DL  eX."I$u+ WXX||' ##E*$ ||' ##F+  &  # DL sCC/.C/c|jS)z/Scope dictionary for this instance or ``None``.)r rs rrz Code.scopeTs||cNdtj|d|jdS)NzCode(z, ))r__repr__r rs rr!z Code.__repr__Ys&s||D)*"T\\,>rct|tr/|jt|f|jt|fk(Sy)NF)rr r rrothers r__eq__z Code.__eq__\s4 eT "LL#d),E 0KK Kr__hash__c||k( SNr#s r__ne__z Code.__ne__cs5=  rr() rz Type[Code]rzUnion[str, Code]rOptional[Mapping[str, Any]]rrreturnr )r,r+)r,r)r$rr,bool) __name__ __module__ __qualname____doc__ _type_marker__annotations__rpropertyrr!r%r&r*r)rrr r s|4L ++ .2 +   @? Hc!rr N) r1 __future__rcollections.abcrrtypingrrrrrr r)rrr8s$6"/66N!3N!r