From 6af2a0677d583ab6b964477f79ccdb6f42653588 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sat, 11 May 2013 21:36:43 +0200 Subject: [PATCH] Compute default line/column/source_path in api.Script --- jedi/api.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jedi/api.py b/jedi/api.py index cfa2c738..ef28e3d4 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -54,8 +54,12 @@ class Script(object): ``unicode`` object (default ``'utf-8'``). :type source_encoding: str """ - def __init__(self, source, line, column, source_path, + def __init__(self, source, line=None, column=None, source_path=None, source_encoding='utf-8', fast=None): + lines = source.splitlines() + line = len(lines) if line is None else line + column = len(lines[-1]) if column is None else column + api_classes._clear_caches() debug.reset_time() self.source = modules.source_to_unicode(source, source_encoding) @@ -537,9 +541,6 @@ class Interpreter(Script): If `line` and `column` are None, they are assumed be at the end of `source`. """ - lines = source.splitlines() - line = len(lines) if line is None else line - column = len(lines[-1]) if column is None else column super(Interpreter, self).__init__( source, line, column, source_path, source_encoding, fast=False)