summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2016-01-03 09:43:04 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2016-01-03 09:43:04 +0200
commit478e05b9b20c726d3ed7c46dc25155aef45aacd2 (patch)
tree58ccd985bd3bef2170599dbbee4e48be15138efb
parentc92e421ef92854cbb8bfa89a7018a74fa07ad0d5 (diff)
downloadastroid-git-478e05b9b20c726d3ed7c46dc25155aef45aacd2.tar.gz
Remove the old aliases for ass_type / file_bytes / file and nodes.
-rw-r--r--astroid/brain/brain_builtin_inference.py4
-rw-r--r--astroid/nodes.py4
-rw-r--r--astroid/tests/unittest_nodes.py142
-rw-r--r--astroid/tree/base.py12
-rw-r--r--astroid/tree/node_classes.py15
-rw-r--r--astroid/tree/scoped_nodes.py46
6 files changed, 2 insertions, 221 deletions
diff --git a/astroid/brain/brain_builtin_inference.py b/astroid/brain/brain_builtin_inference.py
index 4b5236cc..0d1e890d 100644
--- a/astroid/brain/brain_builtin_inference.py
+++ b/astroid/brain/brain_builtin_inference.py
@@ -554,8 +554,8 @@ def infer_type_dunder_new(caller, context=None):
# All the bases needs to be Classes
raise UseInferenceDefault
- cls = nodes.Class(name=name.value, lineno=caller.lineno,
- col_offset=caller.col_offset, parent=caller)
+ cls = nodes.ClassDef(name=name.value, lineno=caller.lineno,
+ col_offset=caller.col_offset, parent=caller)
# Verify the attributes.
attrs = next(caller.args[3].infer(context=context))
diff --git a/astroid/nodes.py b/astroid/nodes.py
index 4317352e..e2fb1e0c 100644
--- a/astroid/nodes.py
+++ b/astroid/nodes.py
@@ -45,8 +45,6 @@ from astroid.tree.node_classes import (
List, Name, NameConstant, Nonlocal, Pass, Print, Raise, Return, Set, Slice,
Starred, Subscript, TryExcept, TryFinally, Tuple, UnaryOp, While, With,
Yield, YieldFrom, AsyncFor, Await, AsyncWith,
- # Backwards-compatibility aliases
- Backquote, Discard, AssName, AssAttr, Getattr, CallFunc, From,
# Node not present in the builtin ast module.
DictUnpack,
# Special nodes for building from live objects.
@@ -56,8 +54,6 @@ from astroid.tree.scoped_nodes import (
Module, GeneratorExp, Lambda, DictComp,
ListComp, SetComp, FunctionDef, ClassDef,
AsyncFunctionDef,
- # Backwards-compatibility aliases
- Class, Function, GenExpr,
)
diff --git a/astroid/tests/unittest_nodes.py b/astroid/tests/unittest_nodes.py
index 4a3d4405..a8a86682 100644
--- a/astroid/tests/unittest_nodes.py
+++ b/astroid/tests/unittest_nodes.py
@@ -595,148 +595,6 @@ class BoundMethodNodeTest(unittest.TestCase):
self.assertIsInstance(inferred, objects.BoundMethod)
-class AliasesTest(unittest.TestCase):
-
- def setUp(self):
- self.transformer = transforms.TransformVisitor()
-
- def parse_transform(self, code):
- module = parse(code, apply_transforms=False)
- return self.transformer.visit(module)
-
- def test_aliases(self):
- def test_from(node):
- node.names = node.names + [('absolute_import', None)]
- return node
-
- def test_class(node):
- node.name = 'Bar'
- return node
-
- def test_function(node):
- node.name = 'another_test'
- return node
-
- def test_callfunc(node):
- if node.func.name == 'Foo':
- node.func.name = 'Bar'
- return node
-
- def test_assname(node):
- if node.name == 'foo':
- return nodes.AssignName('bar', node.lineno, node.col_offset,
- node.parent)
- def test_assattr(node):
- if node.attrname == 'a':
- node.attrname = 'b'
- return node
-
- def test_getattr(node):
- if node.attrname == 'a':
- node.attrname = 'b'
- return node
-
- def test_genexpr(node):
- if node.elt.value == 1:
- node.elt = nodes.Const(2, node.lineno, node.col_offset,
- node.parent)
- return node
-
- self.transformer.register_transform(nodes.From, test_from)
- self.transformer.register_transform(nodes.Class, test_class)
- self.transformer.register_transform(nodes.Function, test_function)
- self.transformer.register_transform(nodes.CallFunc, test_callfunc)
- self.transformer.register_transform(nodes.AssName, test_assname)
- self.transformer.register_transform(nodes.AssAttr, test_assattr)
- self.transformer.register_transform(nodes.Getattr, test_getattr)
- self.transformer.register_transform(nodes.GenExpr, test_genexpr)
-
- string = '''
- from __future__ import print_function
-
- class Foo: pass
-
- def test(a): return a
-
- foo = Foo()
- foo.a = test(42)
- foo.a
- (1 for _ in range(0, 42))
- '''
-
- module = self.parse_transform(string)
-
- self.assertEqual(len(module.body[0].names), 2)
- self.assertIsInstance(module.body[0], nodes.ImportFrom)
- self.assertEqual(module.body[1].name, 'Bar')
- self.assertIsInstance(module.body[1], nodes.ClassDef)
- self.assertEqual(module.body[2].name, 'another_test')
- self.assertIsInstance(module.body[2], nodes.FunctionDef)
- self.assertEqual(module.body[3].targets[0].name, 'bar')
- self.assertIsInstance(module.body[3].targets[0], nodes.AssignName)
- self.assertEqual(module.body[3].value.func.name, 'Bar')
- self.assertIsInstance(module.body[3].value, nodes.Call)
- self.assertEqual(module.body[4].targets[0].attrname, 'b')
- self.assertIsInstance(module.body[4].targets[0], nodes.AssignAttr)
- self.assertIsInstance(module.body[5], nodes.Expr)
- self.assertEqual(module.body[5].value.attrname, 'b')
- self.assertIsInstance(module.body[5].value, nodes.Attribute)
- self.assertEqual(module.body[6].value.elt.value, 2)
- self.assertIsInstance(module.body[6].value, nodes.GeneratorExp)
-
- @unittest.skipIf(six.PY3, "Python 3 doesn't have Repr nodes.")
- def test_repr(self):
- def test_backquote(node):
- node.value.name = 'bar'
- return node
-
- self.transformer.register_transform(nodes.Backquote, test_backquote)
-
- module = self.parse_transform('`foo`')
-
- self.assertEqual(module.body[0].value.value.name, 'bar')
- self.assertIsInstance(module.body[0].value, nodes.Repr)
-
-
-class DeprecationWarningsTest(unittest.TestCase):
- def test_asstype_warnings(self):
- string = '''
- class C: pass
- c = C()
- with warnings.catch_warnings(record=True) as w:
- pass
- '''
- module = parse(string)
- filter_stmts_mixin = module.body[0]
- assign_type_mixin = module.body[1].targets[0]
- parent_assign_type_mixin = module.body[2]
-
- with warnings.catch_warnings(record=True) as w:
- with test_utils.enable_warning(PendingDeprecationWarning):
- filter_stmts_mixin.ass_type()
- self.assertIsInstance(w[0].message, PendingDeprecationWarning)
- with warnings.catch_warnings(record=True) as w:
- with test_utils.enable_warning(PendingDeprecationWarning):
- assign_type_mixin.ass_type()
- self.assertIsInstance(w[0].message, PendingDeprecationWarning)
- with warnings.catch_warnings(record=True) as w:
- with test_utils.enable_warning(PendingDeprecationWarning):
- parent_assign_type_mixin.ass_type()
- self.assertIsInstance(w[0].message, PendingDeprecationWarning)
-
- def test_isinstance_warnings(self):
- msg_format = ("%r is deprecated and slated for removal in astroid "
- "2.0, use %r instead")
- for cls in (nodes.Discard, nodes.Backquote, nodes.AssName,
- nodes.AssAttr, nodes.Getattr, nodes.CallFunc, nodes.From):
- with warnings.catch_warnings(record=True) as w:
- with test_utils.enable_warning(PendingDeprecationWarning):
- isinstance(42, cls)
- self.assertIsInstance(w[0].message, PendingDeprecationWarning)
- actual_msg = msg_format % (cls.__class__.__name__, cls.__wrapped__.__name__)
- self.assertEqual(str(w[0].message), actual_msg)
-
-
@test_utils.require_version('3.5')
class Python35AsyncTest(unittest.TestCase):
diff --git a/astroid/tree/base.py b/astroid/tree/base.py
index 061f9a11..8b2a95e8 100644
--- a/astroid/tree/base.py
+++ b/astroid/tree/base.py
@@ -524,20 +524,12 @@ class FilterStmtsMixin(object):
def assign_type(self):
return self
- def ass_type(self):
- util.rename_warning((type(self).__name__, type(self).__name__))
- return self.assign_type()
-
class AssignTypeMixin(object):
def assign_type(self):
return self
- def ass_type(self):
- util.rename_warning((type(self).__name__, type(self).__name__))
- return self.assign_type()
-
def _get_filtered_stmts(self, lookup_node, node, _stmts, mystmt):
"""method used in filter_stmts"""
if self is mystmt:
@@ -554,10 +546,6 @@ class ParentAssignTypeMixin(AssignTypeMixin):
def assign_type(self):
return self.parent.assign_type()
- def ass_type(self):
- util.rename_warning((type(self).__name__, type(self).__name__))
- return self.assign_type()
-
class LookupMixIn(object):
"""Mixin looking up a name in the right scope
diff --git a/astroid/tree/node_classes.py b/astroid/tree/node_classes.py
index 4d87c174..07237384 100644
--- a/astroid/tree/node_classes.py
+++ b/astroid/tree/node_classes.py
@@ -499,10 +499,6 @@ class Comprehension(AssignedStmtsMixin, base.NodeNG):
def assign_type(self):
return self
- def ass_type(self):
- util.rename_warning((type(self).__name__, type(self).__name__))
- return self.assign_type()
-
def _get_filtered_stmts(self, lookup_node, node, stmts, mystmt):
"""method used in filter_stmts"""
if self is mystmt:
@@ -1308,17 +1304,6 @@ class DictUnpack(base.NodeNG):
"""Represents the unpacking of dicts into dicts using PEP 448."""
-# Backward-compatibility aliases
-
-Backquote = util.proxy_alias('Backquote', Repr)
-Discard = util.proxy_alias('Discard', Expr)
-AssName = util.proxy_alias('AssName', AssignName)
-AssAttr = util.proxy_alias('AssAttr', AssignAttr)
-Getattr = util.proxy_alias('Getattr', Attribute)
-CallFunc = util.proxy_alias('CallFunc', Call)
-From = util.proxy_alias('From', ImportFrom)
-
-
# Register additional inference dispatched functions. We do
# this here, since we need to pass this module as an argument
# to these functions, in order to avoid circular dependencies
diff --git a/astroid/tree/scoped_nodes.py b/astroid/tree/scoped_nodes.py
index 92be900a..86e09e92 100644
--- a/astroid/tree/scoped_nodes.py
+++ b/astroid/tree/scoped_nodes.py
@@ -205,46 +205,6 @@ class Module(QualifiedNameMixin, lookup.LocalsDictNode):
def postinit(self, body=None):
self.body = body
- # Legacy API aliases
- @property
- def file(self):
- util.rename_warning(('file', 'source_file'))
- return self.source_file
- @file.setter
- def file(self, source_file):
- util.rename_warning(('file', 'source_file'))
- self.source_file = source_file
- @file.deleter
- def file(self):
- util.rename_warning(('file', 'source_file'))
- del self.source_file
-
- @property
- def path(self):
- util.rename_warning(('path', 'source_file'))
- return self.source_file
- @path.setter
- def path(self, source_file):
- util.rename_warning(('path', 'source_file'))
- self.source_file = source_file
- @path.deleter
- def path(self):
- util.rename_warning(('path', 'source_file'))
- del self.source_file
-
- @property
- def files_bytes(self):
- util.rename_warning(('files_bytes', 'source_code'))
- return self.source_code
- @files_bytes.setter
- def files_bytes(self, source_code):
- util.rename_warning(('files_bytes', 'source_code'))
- self.source_code = source_code
- @files_bytes.deleter
- def files_bytes(self):
- util.rename_warning(('files_bytes', 'source_code'))
- del self.source_code
-
@property
def globals(self):
return MappingProxyType(lookup.get_locals(self))
@@ -2013,9 +1973,3 @@ class ClassDef(QualifiedNameMixin, base.FilterStmtsMixin,
def bool_value(self):
return True
-
-
-# Backwards-compatibility aliases
-Class = util.proxy_alias('Class', ClassDef)
-Function = util.proxy_alias('Function', FunctionDef)
-GenExpr = util.proxy_alias('GenExpr', GeneratorExp)