}BFjP NdZddlmZddlZddlZddlmZmZdd Zdd Z ddZ dS)z9A fancy version of Python's builtin :func:`dir` function.) annotationsN)AnyCallableobjobjectattrstrreturnboolc8 t||dS#YdSxYw)zfIn recent versions of Python, hasattr() only catches AttributeError. This catches all errors. TF)getattr)rrs @C:\PYTHON\_runtimes\venv\Lib\site-packages\IPython/utils/dir2.py safe_hasattrrs,Ttuus list[str]c tt|}n#t$rt}YnwxYwt|dr$|tt|jz}d|D}t |S)avdir2(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__c<g|]}t|t|S) isinstancer ).0ws r zdir2..4s' 4 4 41As!3!3 4Q 4 4 4)setdir Exceptionrrsorted)rwordss rdir2rsCHH  C%%) S''((( 5 4 4 4 4E %==s ::nameCallable[..., Any] | Nonec  t|dd}n#t$rYdSwxYw|dS t||d}n#t$rYdSwxYwtj|rt |t jsdSt|r|SdS)aELike 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 rinspectisclassrtypes MethodTypecallable)rr canaryms rget_real_methodr+8sH$OO ttt Ct $ $ ttsJq%2B$C$Ct{{ 4s ""< A  A )rrrr r r )rrr r)rrr r r r!) __doc__ __future__rr$r&typingrrrrr+rrrr/s?? #""""" >r