summaryrefslogtreecommitdiff
path: root/astroid/util.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-10-11 23:36:13 +0300
committerClaudiu Popa <pcmanticore@gmail.com>2015-10-11 23:36:13 +0300
commitf293a83d04ae5471b8e974aa994af062ebb3116b (patch)
treef08dec1f025e206c8ad58b8ff76f2919aa38c2cd /astroid/util.py
parent01801c5776cdd02ba85b41f556c615d5cdb3ff20 (diff)
downloadastroid-git-f293a83d04ae5471b8e974aa994af062ebb3116b.tar.gz
Move proxy_alias function to util.py
Diffstat (limited to 'astroid/util.py')
-rw-r--r--astroid/util.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/astroid/util.py b/astroid/util.py
index 96ba5fbf..20c44d72 100644
--- a/astroid/util.py
+++ b/astroid/util.py
@@ -20,7 +20,9 @@
# the same license.
import sys
+import warnings
+import lazy_object_proxy
import six
@@ -45,3 +47,22 @@ class YES(object):
def __call__(self, *args, **kwargs):
return self
+
+
+def _instancecheck(cls, other):
+ wrapped = cls.__wrapped__
+ other_cls = other.__class__
+ is_instance_of = wrapped is other_cls or issubclass(other_cls, wrapped)
+ warnings.warn("%r is deprecated and slated for removal in astroid "
+ "2.0, use %r instead" % (cls.__class__.__name__,
+ wrapped.__name__),
+ PendingDeprecationWarning, stacklevel=2)
+ return is_instance_of
+
+
+def proxy_alias(alias_name, node_type):
+ """Get a Proxy from the given name to the given node type."""
+ proxy = type(alias_name, (lazy_object_proxy.Proxy,),
+ {'__class__': object.__dict__['__class__'],
+ '__instancecheck__': _instancecheck})
+ return proxy(lambda: node_type)