wL i*dZddlZddlZdZdZdZy)z9A fancy version of Python's builtin :func:`dir` function.Nc, t||y#YyxYw)zfIn recent versions of Python, hasattr() only catches AttributeError. This catches all errors. TF)getattr)objattrs X/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/IPython/utils/dir2.py safe_hasattrr sTs c tt|}t|dr!|tt|jz}|Dcgc]}t |t s|}}t|S#t$r t}YmwxYwcc}w)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__)setdir Exceptionrr isinstancestrsorted)rwordsws rdir2rs|CH  C% S'((  41As!3Q 4E 4 %=  5sA.BB.BBc t|dd}|y t||d}tj|rt |t j syt|r|Sy#t$rYywxYw#t$rYywxYw)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)rr inspectisclassrtypes MethodTypecallable)rnamecanaryms rget_real_methodr5sH$O Ct $sJq%2B2B$C{ %  s" A A- A*)A*- A98A9)__doc__rrrrrrr"s?  >r!