From cdd356ff9b521de0ba720f9534be67114ec2adf2 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 13 Jan 2014 16:45:59 +0100 Subject: [PATCH] removed pr.String and pr.Number in favor of the more general pr.Literal --- jedi/evaluate/iterable.py | 8 ++++---- jedi/parser/representation.py | 12 +----------- test/test_parsing.py | 6 +++--- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/jedi/evaluate/iterable.py b/jedi/evaluate/iterable.py index 86b7cc70..5b9f8c08 100644 --- a/jedi/evaluate/iterable.py +++ b/jedi/evaluate/iterable.py @@ -92,14 +92,14 @@ class Array(use_metaclass(CachedMetaClass, pr.Base)): if len(key_expression_list) != 1: # cannot deal with complex strings continue key = key_expression_list[0] - if isinstance(key, pr.String): - str_key = key.value + if isinstance(key, pr.Literal): + key = key.value elif isinstance(key, pr.Name): - str_key = str(key) + key = str(key) else: continue - if mixed_index == str_key: + if mixed_index == key: index = i break if index is None: diff --git a/jedi/parser/representation.py b/jedi/parser/representation.py index 64a54780..5d5333dc 100644 --- a/jedi/parser/representation.py +++ b/jedi/parser/representation.py @@ -1069,9 +1069,7 @@ class Statement(Simple): is_literal = token_type in [tokenize.STRING, tokenize.NUMBER] if isinstance(tok, Name) or is_literal: - cls = Call - if is_literal: - cls = String if token_type == tokenize.STRING else Number + cls = Literal if is_literal else Call call = cls(self._sub_module, tok, start_pos, end_pos, self) if is_chain: @@ -1243,14 +1241,6 @@ class Literal(StatementElement): return "<%s: %s>" % (type(self).__name__, s) -class String(Literal): - pass - - -class Number(Literal): - pass - - class Array(StatementElement): """ Describes the different python types for an array, but also empty diff --git a/test/test_parsing.py b/test/test_parsing.py index b9f2ac55..a7092756 100644 --- a/test/test_parsing.py +++ b/test/test_parsing.py @@ -37,15 +37,15 @@ class TestCallAndName(): def test_literal_type(self): literal = self.get_call('1.0') - assert isinstance(literal, pr.Number) + assert isinstance(literal, pr.Literal) assert type(literal.value) == float literal = self.get_call('1') - assert isinstance(literal, pr.Number) + assert isinstance(literal, pr.Literal) assert type(literal.value) == int literal = self.get_call('"hello"') - assert isinstance(literal, pr.String) + assert isinstance(literal, pr.Literal) assert literal.value == 'hello'