
    @h                    R    S r SSKJr  SSKJr  SSKJrJrJrJ	r	J
r
   " S S\5      rg)z/Tools for representing JavaScript code in BSON.    )annotations)Mapping)Anyr   OptionalTypeUnionc                      \ rS rSr% SrSrS\S'    S         SS jjr\SS	 j5       r	SS
 jr
SS jrSrS\S'   SS jrSrg)Code   a  BSON'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 ``{}``.

   zUnion[Mapping[str, Any], None]_Code__scopeNr   c                   [        U[        5      (       d  [        S[        U5       35      e[        R	                  X5      n UR
                  Ul        Ub[  [        U[        5      (       d  [        S[        U5       35      eUR                  b  UR                  R                  U5        OX$l        U(       a0  UR                  b  UR                  R                  U5        U$ X4l        U$ ! [         a
    S Ul         Nf = f)Nz%code must be an instance of str, not z'scope must be an instance of dict, not )

isinstancestr	TypeErrortype__new__scoper   AttributeError_Mappingupdate)clscoder   kwargsselfs        NC:\Suresh\moveshuttle\MDcreated\moveengine\venv\Lib\site-packages\bson/code.pyr   Code.__new__4   s     $$$CDJ<PQQ{{3%	 ::DL eX.."I$u+ WXX||'##E*$||'##F+   &#  	 DL	 s   C+ +C?>C?c                    U R                   $ )z/Scope dictionary for this instance or ``None``.)r   r   s    r   r   
Code.scopeT   s     ||    c                P    S[         R                  U 5       SU R                  < S3$ )NzCode(z, ))r   __repr__r   r   s    r   r$   Code.__repr__Y   s&    s||D)*"T\\,<A>>r!   c                    [        U[        5      (       a/  U R                  [        U 5      4UR                  [        U5      4:H  $ g)NF)r   r
   r   r   r   others     r   __eq__Code.__eq__\   s7    eT""LL#d),E
0KKKr!   __hash__c                    X:X  + $ N r'   s     r   __ne__Code.__ne__c   s      r!   )__scoper-   )
r   z
Type[Code]r   zUnion[str, Code]r   Optional[Mapping[str, Any]]r   r   returnr
   )r3   r2   )r3   r   )r(   r   r3   bool)__name__
__module____qualname____firstlineno____doc___type_marker__annotations__r   propertyr   r$   r)   r+   r/   __static_attributes__r.   r!   r   r
   r
      s|    4 L++
 .2 + 	
 
@  ?
 Hc!r!   r
   N)r9   
__future__r   collections.abcr   r   typingr   r   r   r   r   r
   r.   r!   r   <module>rA      s$    6 " / 6 6N!3 N!r!   