summaryrefslogtreecommitdiff
path: root/astroid
diff options
context:
space:
mode:
authorMarc Mueller <30130371+cdce8p@users.noreply.github.com>2021-06-13 20:34:25 +0200
committerGitHub <noreply@github.com>2021-06-13 20:34:25 +0200
commit032fb3acc21fd939f4d77ffcb622bcc2f4a1ba73 (patch)
treeb3e8ad8a2150eead3398553da0136bcc66ca3357 /astroid
parent688b9c750d3346faf96a737f5904d25fcca48c97 (diff)
downloadastroid-git-032fb3acc21fd939f4d77ffcb622bcc2f4a1ba73.tar.gz
Deprecate Ellipsis node (#1025)
Diffstat (limited to 'astroid')
-rw-r--r--astroid/as_string.py4
-rw-r--r--astroid/node_classes.py19
-rw-r--r--astroid/rebuilder.py13
3 files changed, 12 insertions, 24 deletions
diff --git a/astroid/as_string.py b/astroid/as_string.py
index b26e4f97..3a71b0f1 100644
--- a/astroid/as_string.py
+++ b/astroid/as_string.py
@@ -284,10 +284,6 @@ class AsStringVisitor:
excs = "except"
return f"{excs}:\n{self._stmt_list(node.body)}"
- def visit_ellipsis(self, node):
- """return an astroid.Ellipsis node as string"""
- return "..."
-
def visit_empty(self, node):
"""return an Empty node as string"""
return ""
diff --git a/astroid/node_classes.py b/astroid/node_classes.py
index c8272266..68333d92 100644
--- a/astroid/node_classes.py
+++ b/astroid/node_classes.py
@@ -37,7 +37,6 @@ import abc
import builtins as builtins_mod
import itertools
import pprint
-import sys
import typing
from functools import lru_cache
from functools import singledispatch as _singledispatch
@@ -54,7 +53,6 @@ except ImportError:
BUILTINS = builtins_mod.__name__
MANAGER = manager.AstroidManager()
-PY38 = sys.version_info[:2] >= (3, 8)
def _is_const(value):
@@ -2967,20 +2965,10 @@ class Ellipsis(mixins.NoChildrenMixin, NodeNG): # pylint: disable=redefined-bui
An :class:`Ellipsis` is the ``...`` syntax.
- >>> node = astroid.extract_node('...')
- >>> node
- <Ellipsis l.1 at 0x7f23b2e35160>
+ Deprecated since v2.6.0 - Use :class:`Const` instead.
+ Will be removed with the release v2.7.0
"""
- def bool_value(self, context=None):
- """Determine the boolean value of this node.
-
- :returns: The boolean value of this node.
- For an :class:`Ellipsis` this is always ``True``.
- :rtype: bool
- """
- return True
-
class EmptyNode(mixins.NoChildrenMixin, NodeNG):
"""Holds an arbitrary object in the :attr:`LocalsDictNodeNG.locals`."""
@@ -5045,9 +5033,8 @@ CONST_CLS = {
set: Set,
type(None): Const,
type(NotImplemented): Const,
+ type(...): Const,
}
-if PY38:
- CONST_CLS[type(...)] = Const
def _update_const_classes():
diff --git a/astroid/rebuilder.py b/astroid/rebuilder.py
index 422854b5..70297f20 100644
--- a/astroid/rebuilder.py
+++ b/astroid/rebuilder.py
@@ -249,7 +249,7 @@ class TreeRebuilder:
# Not used in Python 3.8+
@overload
- def visit(self, node: "ast.Ellipsis", parent: NodeNG) -> nodes.Ellipsis:
+ def visit(self, node: "ast.Ellipsis", parent: NodeNG) -> nodes.Const:
...
@overload
@@ -883,9 +883,14 @@ class TreeRebuilder:
return newnode
# Not used in Python 3.8+.
- def visit_ellipsis(self, node: "ast.Ellipsis", parent: NodeNG) -> nodes.Ellipsis:
- """visit an Ellipsis node by returning a fresh instance of it"""
- return nodes.Ellipsis(node.lineno, node.col_offset, parent)
+ def visit_ellipsis(self, node: "ast.Ellipsis", parent: NodeNG) -> nodes.Const:
+ """visit an Ellipsis node by returning a fresh instance of Const"""
+ return nodes.Const(
+ value=Ellipsis,
+ lineno=node.lineno,
+ col_offset=node.col_offset,
+ parent=parent,
+ )
def visit_emptynode(self, node: "ast.AST", parent: NodeNG) -> nodes.EmptyNode:
"""visit an EmptyNode node by returning a fresh instance of it"""