+
    ~viW                       R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
HtHtHtHtHtHtHtHtHtHt ^ RIHt ^ RIHt ^ RIHtHt ^R	IHtHtHtH t  ]PB                  '       d<   ]PD                  ]PF                  ]PH                  ]P                  ,          3,          t%M]P                  t% ! R
 R]&4      t' ! R R]'4      t( ! R R]4      t) ! R R])4      t*]PV                  ! RRR7      t, ! R R]*4      t-R# )z/A base class for objects that are configurable.)annotationsN)deepcopy)dedent)
Any	ContainerDict	HasTraitsInstance	TraitTypedefaultobserveobserve_compatvalidate)warnings)Bunch)indentwrap_paragraphs)ConfigDeferredConfigLazyConfigValue_is_section_keyc                      ] tR t^(tRtR# )ConfigurableError N__name__
__module____qualname____firstlineno____static_attributes__r       ?/usr/lib/python3/dist-packages/traitlets/config/configurable.pyr   r   (       r    r   c                      ] tR t^,tRtR# )MultipleInstanceErrorr   Nr   r   r    r!   r$   r$   ,   r"   r    r$   c                  T  a  ] tR t^5t]! ]R/ 4      t]! RRR7      tR V 3R llt]	R R l4       t
R R	 ltRR
 R llt]! R4      ]R R l4       4       tR R lt]	R R R ll4       t]	RR R ll4       t]	R R R ll4       t]	R R l4       t]	R R R ll4       t]	R R l4       tRtV ;t# )!Configurablez*traitlets.config.configurable.ConfigurableT)
allow_nonec                    V ^8  d   QhRRRR/# )   kwargst.AnyreturnNoner   )formats   "r!   __annotate__Configurable.__annotate__9   s     B. B. B.4 B.r    c                  <aa SP                  RR4      pVe*   SP                  RR4      f   VP                  SR&   W n        SP                  RR4      p\        SV `  ! R/ SB  \        4       oR VV3R llpV P                  V4       Ve   W0n        MV P                  V P                  4       V P                  V4       S F  p\        WSV,          4       K  	  R# )a  Create a configurable given a config config.

Parameters
----------
config : Config
    If this is empty, default values are used. If config is a
    :class:`Config` instance, it will be used to configure the
    instance.
parent : Configurable instance, optional
    The parent Configurable instance of this object.

Notes
-----
Subclasses of Configurable must call the :meth:`__init__` method of
:class:`Configurable` *before* doing anything else and using
:func:`super`::

    class MyConfigurable(Configurable):
        def __init__(self, config=None):
            super(MyConfigurable, self).__init__(config=config)
            # Then any other code you need to finish initialization.

This ensures that instances will be configured properly.
parentNconfigc                    V ^8  d   QhRRRR/# r)   changer   r,   r-   r   )r.   s   "r!   r/   +Configurable.__init__.<locals>.__annotate__a   s     	7 	75 	7T 	7r    c                d   < V P                   S9   d   SP                  V P                   4       R# R# )zjRecord traits set by both config and kwargs.

They will need to be overridden again after loading config.
N)nameadd)r6   config_override_namesr*   s   &r!   notice_config_override5Configurable.__init__.<locals>.notice_config_overridea   s(    
 {{f$%))&++6 %r    r   )popgetr3   r2   super__init__setr   _load_config	unobservesetattr)selfr*   r2   r3   r<   r9   r;   	__class__s   &l    @r!   rA   Configurable.__init__9   s    2 Hd+zz(D)1#)==x  KHd+ 	"6" !$	7 	7 	+,  !K dkk*-.)DDt- *r    c                   V ^8  d   QhRR/# )r)   r,   z	list[str]r   )r.   s   "r!   r/   r0      s     
 
i 
r    c                    \        V P                  4       Uu. uF:  p\        V\        4      '       g   K  \        W4      '       g   K.  VP                  NK<  	  up# u upi )zreturn section names as a list)reversed__mro__
issubclassr&   r   )clscs   & r!   section_namesConfigurable.section_names   sO    
 ckk*
*!\* /9#/A AJJ*
 	
 
s   AAAc                    V ^8  d   QhRRRR/# )r)   cfgr   r,   r+   r   )r.   s   "r!   r/   r0      s      6 e r    c                8   V.pV P                   '       d+   VP                  V P                   P                  V4      4       \        4       pV FJ  pV P	                  4        F3  pVP                  V4      '       g   K  VP                  WE,          4       K5  	  KL  	  V# )a  extract my config from a global Config object

will construct a Config object of only the config values that apply to me
based on my mro(), as well as those of my parent(s) if they exist.

If I am Bar and my parent is Foo, and their parent is Tim,
this will return merge following config sections, in this order::

    [Bar, Foo.Bar, Tim.Foo.Bar]

With the last item being the highest priority.
)r2   append_find_my_configr   rP   _has_sectionmerge)rF   rS   cfgs	my_configrO   snames   &&    r!   rV   Configurable._find_my_config   sz     u;;;KK33C89H	A++- >>%((OOAH-	 .  r    c               (    V ^8  d   QhRRRRRRRR/# )	r)   rS   r   rP   zlist[str] | Nonetraitsz)dict[str, TraitType[t.Any, t.Any]] | Noner,   r-   r   )r.   s   "r!   r/   r0      s2     3 33 (3 :	3
 
3r    c                $   Vf   V P                  RR7      pVf   V P                  4       pV P                  V4      pV P                  4       ;_uu_ 4        VP	                  4        EF  w  rVWS9   dx   \        V\        4      '       d   \        W4      pVP                  V4      pM-\        V\        4      '       d   VP                  W5,          4      p\        W\        V4      4       K  \        V4      '       d   K  \        V\        4      '       d   K  ^ RIHp \        V \         4      '       d(   V P"                  f   Q hV P"                  P$                  p	MR R lp	V! WS4      p
RV RV P&                  P(                   R	2p\+        V
4      ^8X  d   VR
V
^ ,           R2,          pMA\+        V
4      ^8  d2   VRP-                  RP/                  \1        V
4      4      R7      ,          pV	! V4       EK  	  RRR4       R#   + '       g   i     R# ; i)z load traits from a Config objectNTr3   )get_close_matchesc                    V ^8  d   QhRRRR/# )r)   msgr+   r,   r-   r   )r.   s   "r!   r/   /Configurable._load_config.<locals>.__annotate__   s     Q Qe Q Qr    c                <    \         P                  ! V \        ^	R7      # )	   
stacklevel)r   warnUserWarning)rc   s   &r!   ri   'Configurable._load_config.<locals>.warn   s    #+==ka#PPr    zConfig option `z` not recognized by `z`.z  Did you mean `z`?z#  Did you mean one of: `{matches}`?, )matches)r^   rP   rV   hold_trait_notificationsitems
isinstancer   getattr	get_valuer   rE   r   r   r   difflibra   LoggingConfigurablelogwarningrG   r   lenr.   joinsorted)rF   rS   rP   r^   rZ   r9   config_valueinitialra   ri   rm   rc   s   &&&&        r!   rC   Configurable._load_config   s    >[[[-F  ..0M((-	 **,,&/oo&7">!,@@ #*$"5'3'='=g'F#L.AA'3'='=fl'K D(>?(..z,PV7W7W9!$(;<<#xx333#xx//Q 0=G+D61Ft~~G^G^F__abC7|q(!1'!*R@@W*DKK$(IIfWo$>  L    IE '8 -,,,s   B"G>;G>C!G>>H	r3   c                    V ^8  d   QhRRRR/# r5   r   )r.   s   "r!   r/   r0      s     R Re R Rr    c                    V P                  RR7      pV P                  4       pV P                  VP                  W#R7       R# )zUpdate all the class traits having ``config=True`` in metadata.

For any class trait with a ``config`` metadata attribute that is
``True``, we update the trait with the value of the corresponding
config entry.
Tr`   )r^   rP   N)r^   rP   rC   new)rF   r6   r^   rP   s   &&  r!   _config_changedConfigurable._config_changed   s;     D)
 **,&**VQr    c                    V ^8  d   QhRRRR/# )r)   r3   r   r,   r-   r   )r.   s   "r!   r/   r0      s     " "F "t "r    c                    \        V P                  4      V n        V P                  V4       V P                  P                  V4       R# )z%Update config and load the new valuesN)r   r3   rC   rX   )rF   r3   s   &&r!   update_configConfigurable.update_config   s4     t{{+&!&!r    c                    V ^8  d   QhRRRR/# )r)   instHasTraits | Noner,   strr   )r.   s   "r!   r/   r0      s     % %"2 %c %r    c                   Ve   \        W4      '       g   Q h. pRP                  R V P                   4       4      pVP                  V P                   RV R24       VP                  \        V^ ,          4      R,          4       \        V P                  RR7      P                  4       4       F'  w  rEV P                  WQ4      pVP                  V4       K)  	  RP                  V4      # )	zGet the help string for this class in ReST format.

If `inst` is given, its current trait values will be used in place of
class defaults.
rl   c              3  8   "   T F  qP                   x  K  	  R # 5iN)r   .0ps   & r!   	<genexpr>.Configurable.class_get_help.<locals>.<genexpr>  s      C]]s   (z	) options-Tr`   
)
rp   rx   	__bases__rU   r   rw   ry   class_traitsro   class_get_trait_help)rN   r   
final_helpbase_classes_vhelps   &&     r!   class_get_helpConfigurable.class_get_help   s     |z$4444
yy CS]] CCS\\N!L>CD#jm,s233++4+8>>@ADA++A4Dd# B yy$$r    c               (    V ^8  d   QhRRRRRRRR/# )	r)   traitTraitType[t.Any, t.Any]r   r   helptextz
str | Noner,   r   r   )r.   s   "r!   r/   r0     s2     6  6 &6  6  	6 
 
6 r    c           
        Ve   \        W 4      '       g   Q h. pRV P                   RVP                   2p\        V\        \        34      '       dz   VP
                  P                  RR4      p\        V\        4      '       d   RpM+RVP                  P                  P                  4       ,          pVR8X  d
   V RV R	2pM%V R
V R	2pMV RVP                  P                   R2pVP                  V4       Vf   VP                  pVR8w  d6   RP                  \        V^L4      4      pVP                  \        V4      4       RVP                  P                  9   d0   VP                  \        RVP                  4       ,          4      4       Ve=   TP                  \        R\        Y!P                  ;'       g    R4      : 24      4       MV VP!                  4       pVeB   \%        V4      ^@8  d   VR,          R	,           pVP                  \        RV,          4      4       RP                  V4      #   \"         d    Rp Lei ; i)zGet the helptext string for a single trait.

:param inst:
    If given, its current trait values will be used in place of
    the class default.
:param helptext:
    If not given, uses the `help` attribute of the current trait.
Nz--.multiplicityrU   z<key-1>=<value-1>z<%s-item-1>=... z=<> r   EnumzChoices: %sz	Current: N=   NzDefault: %s)rp   r   r9   r   r   metadatar?   rG   lowerrU   r   rx   r   r   inforq   default_value_repr	Exceptionrw   )	rN   r   r   r   linesheaderr   sample_valuedvrs	   &&&&     r!   r   !Configurable.class_get_trait_help  s    |z$4444cll^1UZZL1ei.// >>--nhGL%&&2,u/G/G/M/M/OOx'"81\N#6"81\N#6xr%//":":!;1=FVzzHr>yy2!>?HLL)*U__---LL

 <=>LL)GD**:J:J,K+N OPQ..0 s8b=c(U*CVMC$789yy  s   H5 5IIc                    V ^8  d   QhRRRR/# )r)   r   r   r,   r-   r   )r.   s   "r!   r/   r0   E  s     ( ($4 ( (r    c                :    \        V P                  V4      4       R# )z4Get the help string for a single trait and print it.N)printr   )rN   r   s   &&r!   class_print_helpConfigurable.class_print_helpD  s     	c  &'r    c               $    V ^8  d   QhRRRRRR/# )r)   r   r   classeszt.Sequence[type[HasTraits]]r,   ztype[Configurable]r   )r.   s   "r!   r/   r0   J  s$      +6Q	r    c                    T pVP                   f   Q hV P                  4        FW  p\        V\        4      '       g   K  WB9   g   K#  VP	                  RR7      P                  VP                   R4      VJ g   KU  TpKY  	  V# )a  Get the class that defines a trait

For reducing redundant help output in config files.
Returns the current class if:
- the trait is defined on this class, or
- the class where it is defined would not be in the config file

Parameters
----------
trait : Trait
    The trait to look for
classes : list
    The list of other classes to consider for redundancy.
    Will return `cls` even if it is not defined on `cls`
    if the defining class is not in `classes`.
NTr`   )r9   mrorM   r&   class_own_traitsr?   )rN   r   r   defining_clsr2   s   &&&  r!   _defining_classConfigurable._defining_classI  sq    ( zz%%%ggiF6<00%++4+8<<UZZNRWW%   r    c                    V ^8  d   QhRRRR/# )r)   r   z"t.Sequence[type[HasTraits]] | Noner,   r   r   )r.   s   "r!   r/   r0   i  s     9  9 +M 9 Y\ 9 r    c           	        R R lpRpRP                  R V P                   4       4      pRV P                   RV R2pW5V.pV P                  4       P	                  R4      pV'       d   VP
                  pV'       g   \        V R	R
4      pV'       d)   VP                  V! V4      4       VP                  R
4       \        V P                  RR7      P                  4       4       EFc  w  rV	P                  4       p
V'       d   V P                  W4      pMT pWJ d   V	P                  '       d"   VP                  V! V	P                  4      4       R\        V	4      P                  9   d'   VP                  RV	P                  4       ,          4       VP                  RV
,          4       MkV	P                  '       d9   VP                  V! V	P                  P                  R^4      ^ ,          4      4       VP                  RVP                   RV 24       VP                  RV P                   RV RV
 24       VP                  R
4       EKf  	  RP                  V4      # )zGet the config section for this class.

Parameters
----------
classes : list, optional
    The list of other classes in the config file.
    Used to reduce redundant information.
c                    V ^8  d   QhRRRR/# )r)   sr   r,   r   )r.   s   "r!   r/   7Configurable.class_config_section.<locals>.__annotate__s  s     	4 	4 	4 	4r    c                j    RP                  \        V ^N4      4      p RV P                  RR4      ,           # )z"return a commented, wrapped block.z

z## r   z
#  )rx   r   replace)r   s   &r!   rO   ,Configurable.class_config_section.<locals>.cs  s-    OAr23A199T7333r    rl   c              3  j   "   T F)  p\        V\        4      '       g   K  VP                  x  K+  	  R # 5ir   )rM   r&   r   r   s   & r!   r   4Configurable.class_config_section.<locals>.<genexpr>{  s!     "d}!
STVbHc:1::}s   33z# r   z) configurationdescription__doc__r   Tr`   r   z#  Choices: %sz#  Default: %sr   z#  See also: r   z# c.z = zO#------------------------------------------------------------------------------)rx   r   r   r   r?   default_valuerq   rU   ry   ro   r   r   r   typer   split)rN   r   rO   breakerparent_classesr   r   descr9   r   default_reprdefining_classs   &&          r!   class_config_section!Configurable.class_config_sectionh  s   	4 !"ds}}"dda/?W%!%%m4%%D3	2.DLL4!LL!#"2"2$"2"?"E"E"GHKD 335L!$!4!4U!D!$$:::LL5::/T%[111LL!1EJJL!@A-<= :::LL5::#3#3D!#<Q#?!@A}^-D-D,EQtfMNLL4~QtfC~FGLL/ I0 yyr    c                   V ^8  d   QhRR/# )r)   r,   r   r   )r.   s   "r!   r/   r0     s     )  ) S ) r    c                j   . pV P                   p\        V P                  RR7      P                  4       4       EFT  w  r4VP                  P                   pVP
                  '       g   K0  VR,           VP
                  ,           pRV9   d    VRVP                  4       ,           ,          pMVRV,           ,          pVP                  V4        VP                  4       pVee   \        V4      ^@8  d   VR,          R,           pVP                  R	R
4      pVP                  \        RV,          4      4       VP                  R4       VP                  ;'       g    RpVP                  \        \        V4      4      4       VP                  R4       EKW  	  RP                  V4      #   \         d    Rp Li ; i)zgGenerate rST documentation for this class' config options.

Excludes traits defined on parent classes.
Tr`   r   r   z : Nr   r   z\nz\\nzDefault: ``%s``r   zNo descriptionr   )r   ry   r   ro   rG   r9   info_rstrU   r   r   rw   r   r   r   r   rx   )	rN   r   	classnamer   r   ttypetermliner   r   s	   &        r!   class_config_rst_doc!Configurable.class_config_rst_doc  se    LL	s//t/<BBDEHAOO,,E::: 33H EENN$444EEM)LL"..0 s8b=c(U*Ckk%1V$5$;<=R ::11!1DLLt-. LLA FD yy!  s   
F""F21F2)r3   r2   r   )NNr   )r   r   r   r   r	   r   r3   r2   rA   classmethodrP   rV   rC   r   r   r   r   r   r   r   r   r   r   r   __classcell__)rG   s   @r!   r&   r&   5   s    fb"%FBtTFB. B.P 
 
23j XR  R "  % %  6  6 p ( (  < 9  9 v )  ) r    r&   c                  ~    ] tR tRtRt]! RRR7      t]! R4      R R l4       t]	! R4      R	 R
 l4       t
R R ltRtR# )rt   i  zA parent class for Configurables that log.

Subclasses have a log trait, and the default behavior
is to get the logger from the currently running Application.
z Logger or LoggerAdapter instanceF)r   r'   ru   c                    V ^8  d   QhRRRR/# )r)   proposalr   r,   
LoggerTyper   )r.   s   "r!   r/    LoggingConfigurable.__annotate__  s     	2 	2e 	2
 	2r    c                	B   \        VP                  \        P                  \        P                  34      '       gB   \
        P                  ! V P                  P                   R VP                   R2\        ^R7       \        P                  ! \        VP                  4      # )z..log should be a Logger or LoggerAdapter, got r   rg   )rp   valueloggingLoggerLoggerAdapterr   ri   rG   r   rj   tcastr   )rF   r   s   &&r!   _validate_log!LoggingConfigurable._validate_log  sq    (..7>>7;P;P*QRRMM>>**+ , 'q*	 vvj(..11r    c                   V ^8  d   QhRR/# )r)   r,   r   r   )r.   s   "r!   r/   r     s        j  r    c                	    \        V P                  \        4      '       dJ   V P                  f   Q h\        P                  ! \
        P                  V P                  P                  4      # ^ RIHp VP                  4       # )N)ru   )
rp   r2   rt   r   r   r   r   ru   	traitlets
get_logger)rF   ru   s   & r!   _log_default LoggingConfigurable._log_default  sQ    dkk#677;;***66'..$++//::!~~r    c                   V ^8  d   QhRR/# )r)   r,   zlogging.Handler | Noner   )r.   s   "r!   r/   r     s     " ""8 "r    c                   V P                   '       g   R# \        V P                   \        P                  4      '       d   V P                   MV P                   P                  p\        VRR4      '       g   R# VP                  ^ ,          # )zReturn the default Handler

Returns None if none can be found

Deprecated, this now returns the first log handler which may or may
not be the default one.
Nhandlers)ru   rp   r   r   loggerrq   r   )rF   r   s   & r!   _get_log_handler$LoggingConfigurable._get_log_handler  s]     xxx"488W^^<<DHH$((// 	 vz400q!!r    r   N)r   r   r   r   r   r   ru   r   r   r   r   r   r   r   r    r!   rt   rt     sN     5%
HCe_	2 	2 U^   " "r    rt   CTSingletonConfigurable)boundc                  v    ] tR tRtRtRt]R R l4       t]R R l4       t]R R	 l4       t	]R
 R l4       t
RtR# )r   i  zA configurable that only allows one instance.

This class is for classes that should only have one instance of itself
or *any* subclass. To create and retrieve such a class use the
:meth:`SingletonConfigurable.instance` method.
Nc                   V ^8  d   QhRR/# )r)   r,   z4t.Generator[type[SingletonConfigurable], None, None]r   )r.   s   "r!   r/   "SingletonConfigurable.__annotate__  s      N r    c              #     "   V P                  4        F?  p\        W4      '       g   K  \        V\        4      '       g   K.  V\        8w  g   K;  Vx  KA  	  R# 5i)zVWalk the cls.mro() for parent classes that are also singletons

For use in instance()
N)r   rM   r   rN   subclasss   & r!   	_walk_mroSingletonConfigurable._walk_mro  s>      	H3))x)>?? 55 "s   "AAA
Ac                   V ^8  d   QhRR/# )r)   r,   r-   r   )r.   s   "r!   r/   r    s     * *t *r    c                    V P                  4       '       g   R# V P                  4        F(  p\        VP                  V 4      '       g   K!  RVn        K*  	  R# )z5unset _instance for this class and singleton parents.N)initializedr  rp   	_instancer  s   & r!   clear_instance$SingletonConfigurable.clear_instance  sA       H(,,c22 &*"	 (r    c               (    V ^8  d   QhRRRRRRRR/# )r)   rN   ztype[CT]argsr+   r*   r,   r   r   )r.   s   "r!   r/   r  *  s(     ) )h )u ) )" )r    c                (   V P                   f&   V ! V/ VB pV P                  4        F	  pW4n         K  	  \        V P                   V 4      '       d   V P                   # \        RV P                   R\        V P                   4      P                   24      h)a  Returns a global instance of this class.

This method create a new instance if none have previously been created
and returns a previously created instance is one already exists.

The arguments and keyword arguments passed to this method are passed
on to the :meth:`__init__` method of the class upon instantiation.

Examples
--------
Create a singleton class using instance, and retrieve it::

    >>> from traitlets.config.configurable import SingletonConfigurable
    >>> class Foo(SingletonConfigurable): pass
    >>> foo = Foo.instance()
    >>> foo == Foo.instance()
    True

Create a subclass that is retrieved using the base class instance::

    >>> class Bar(SingletonConfigurable): pass
    >>> class Bam(Bar): pass
    >>> bam = Bam.instance()
    >>> bam == Bar.instance()
    True
zAn incompatible sibling of 'z(' is already instantiated as singleton: )r  r  rp   r$   r   r   )rN   r  r*   r   r  s   &*,  r!   instanceSingletonConfigurable.instance)  s    : == ''D  MMO%)" , cmmS))== '.s||n =""&s}}"5">">!?A r    c                   V ^8  d   QhRR/# )r)   r,   boolr   )r.   s   "r!   r/   r  V  s     G GD Gr    c                F    \        V R4      ;'       d    V P                  RJ# )zHas an instance been created?r  N)hasattrr  )rN   s   &r!   r  !SingletonConfigurable.initializedU  s"     sK(FFS]]$-FFr    r   )r   r   r   r   r   r  r   r  r  r  r  r   r   r    r!   r   r     s_     I  * * ) )V G Gr    ).r   
__future__r   r   typingr   copyr   textwrapr   traitlets.traitletsr   r   r   r   r	   r
   r   r   r   r   traitlets.utilsr   traitlets.utils.bunchr   traitlets.utils.textr   r   loaderr   r   r   r   TYPE_CHECKINGUnionr   r   r   r   r   r$   r&   rt   TypeVarr   r   r   r    r!   <module>r&     s    5 #       % ' 8 L L ???)>)>quu)EEFJJ		 		- 	Y 9 Y x.", ."b YYt23SG/ SGr    