
    ^jP	                    L    d Z ddlmZ ddlZddlZddlmZmZ ddZd	dZ	d
dZ
y)z9A fancy version of Python's builtin :func:`dir` function.    )annotationsN)AnyCallablec                ,    	 t        | |       y#  Y yxY w)zfIn recent versions of Python, hasattr() only catches AttributeError.
    This catches all errors.
    TF)getattr)objattrs     K/opt/ringagent/.cad-venv/lib/python3.12/site-packages/IPython/utils/dir2.pysafe_hasattrr      s    Ts    c                   	 t        t        |             }t        | d      r!|t        t        | j                              z  }|D cg c]  }t        |t              s| }}t        |      S # t        $ r t               }Y mw xY wc c}w )av  dir2(obj) -> list of strings

    Extended version of the Python builtin dir(), which does a few extra
    checks.

    This version is guaranteed to return only a list of true strings, whereas
    dir() returns anything that objects inject into themselves, even if they
    are later not really valid for attribute access (many extension libraries
    have such bugs).
    	__class__)setdir	Exceptionr   r   
isinstancestrsorted)r   wordsws      r
   dir2r      s|    CH
 C%S'((
 41As!3Q4E4%=   5s   A. BB.BBc                    	 t        | dd      }|y	 t        | |d      }t        j                  |       rt	        |t
        j                        syt        |      r|S y# t        $ r Y yw xY w# t        $ r Y yw xY w)aE  Like getattr, but with a few extra sanity checks:

    - If obj is a class, ignore everything except class methods
    - Check if obj is a proxy that claims to have all attributes
    - Catch attribute access failing with any exception
    - Check that the attribute is a callable object

    Returns the method or None.
    (_ipython_canary_method_should_not_exist_N)r   r   inspectisclassr   types
MethodTypecallable)r   namecanaryms       r
   get_real_methodr!   8   s    H$O Ct$ sJq%2B2B$C{%    s"   A A- 	A*)A*-	A98A9)r   objectr	   r   returnbool)r   r"   r#   z	list[str])r   r"   r   r   r#   zCallable[..., Any] | None)__doc__
__future__r   r   r   typingr   r   r   r   r!        r
   <module>r*      s%    ?
 #    >r)   