aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/ipython/py2/IPython/utils/dir2.py
diff options
context:
space:
mode:
authorNikita Slyusarev <nslus@yandex-team.com>2022-02-10 16:46:53 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:53 +0300
commit469afdc4e2587bf62ecdd096b75a0baa444c4012 (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /contrib/python/ipython/py2/IPython/utils/dir2.py
parentcd77cecfc03a3eaf87816af28a33067c4f0cdb59 (diff)
downloadydb-469afdc4e2587bf62ecdd096b75a0baa444c4012.tar.gz
Restoring authorship annotation for Nikita Slyusarev <nslus@yandex-team.com>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/ipython/py2/IPython/utils/dir2.py')
-rw-r--r--contrib/python/ipython/py2/IPython/utils/dir2.py72
1 files changed, 36 insertions, 36 deletions
diff --git a/contrib/python/ipython/py2/IPython/utils/dir2.py b/contrib/python/ipython/py2/IPython/utils/dir2.py
index 352c079178..f6f164f9b1 100644
--- a/contrib/python/ipython/py2/IPython/utils/dir2.py
+++ b/contrib/python/ipython/py2/IPython/utils/dir2.py
@@ -2,10 +2,10 @@
"""A fancy version of Python's builtin :func:`dir` function.
"""
-# Copyright (c) IPython Development Team.
-# Distributed under the terms of the Modified BSD License.
+# Copyright (c) IPython Development Team.
+# Distributed under the terms of the Modified BSD License.
-import inspect
+import inspect
from .py3compat import string_types
@@ -46,36 +46,36 @@ def dir2(obj):
words = [w for w in words if isinstance(w, string_types)]
return sorted(words)
-
-
-def get_real_method(obj, name):
- """Like getattr, but with a few extra sanity checks:
-
- - If obj is a class, ignore its 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.
- """
- if inspect.isclass(obj):
- return None
-
- try:
- canary = getattr(obj, '_ipython_canary_method_should_not_exist_', None)
- except Exception:
- return None
-
- if canary is not None:
- # It claimed to have an attribute it should never have
- return None
-
- try:
- m = getattr(obj, name, None)
- except Exception:
- return None
-
- if callable(m):
- return m
-
- return None
+
+
+def get_real_method(obj, name):
+ """Like getattr, but with a few extra sanity checks:
+
+ - If obj is a class, ignore its 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.
+ """
+ if inspect.isclass(obj):
+ return None
+
+ try:
+ canary = getattr(obj, '_ipython_canary_method_should_not_exist_', None)
+ except Exception:
+ return None
+
+ if canary is not None:
+ # It claimed to have an attribute it should never have
+ return None
+
+ try:
+ m = getattr(obj, name, None)
+ except Exception:
+ return None
+
+ if callable(m):
+ return m
+
+ return None