diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-03 17:44:45 +0300 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-03 17:44:45 +0300 |
commit | 3c1ba7ebc6a8bf13ae0be85fe4964ef51c48822a (patch) | |
tree | 2786815c15142df4e26445bbd6299448d26801c7 /astroid/objects.py | |
parent | b9e462e49d38e5e4a188f5fb24b61a71aeab8320 (diff) | |
download | astroid-git-3c1ba7ebc6a8bf13ae0be85fe4964ef51c48822a.tar.gz |
Move objects.Slice back into nodes.Slice
We did this because objects.Slice had more capabilities than
nodes.Slice, such as inferring the slice attributes (start, stop,
step) and it was used mostly for inferring the slice() builtin.
Diffstat (limited to 'astroid/objects.py')
-rw-r--r-- | astroid/objects.py | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/astroid/objects.py b/astroid/objects.py index b11e3bc9..f80cf549 100644 --- a/astroid/objects.py +++ b/astroid/objects.py @@ -23,24 +23,6 @@ original AST tree. For instance, inferring the following frozenset use, leads to an inferred FrozenSet: Call(func=Name('frozenset'), args=Tuple(...)) - - -This distinction might help for understanding better where to use -an AST node and where to use an inference object: - - * if the AST node can be used on its own, e.g. List, Tuple, etc, - then the AST can be used. - They have a syntactic display and can be written on its own, - e.g. "[]" is a valid list. That's why the inference of their - respective builtins (list, tuple, set etc) returns an AST node - when inferring. - - * if the AST node is part of syntax and can't be used - on its own. This is the case for slices for instance, e.g "[2:3:4]". - In this case, trying to write "2:3:4" on its own will fail. - The respective builtin (slice) returns a custom object when inferring - and not an AST node per se. - """ import six @@ -72,32 +54,6 @@ class FrozenSet(node_classes._BaseContainer): return builtins.getattr('frozenset')[0] -class Slice(node_classes.Slice): - """Custom object for representing slices internally.""" - - @decorators.cachedproperty - def _proxied(self): - builtins = MANAGER.astroid_cache[BUILTINS] - return builtins.getattr('slice')[0] - - def pytype(self): - return '%s.slice' % BUILTINS - - def igetattr(self, attrname, context=None): - if attrname == 'start': - yield self.lower - elif attrname == 'stop': - yield self.upper - elif attrname == 'step': - yield self.step - else: - for value in self.getattr(attrname, context=context): - yield value - - def getattr(self, attrname, context=None): - return self._proxied.getattr(attrname, context) - - class Super(bases.NodeNG): """Proxy class over a super call. |