<commit_before>"""
Jedi is an autocompletion library for Python. It offers additonal
services such as goto / get_definition / pydoc support /
get_in_function_call / related names.

To give you a simple exmple how you can use the jedi library,
here is an exmple for the autocompletion feature:

>>> import jedi
>>> source = '''import json; json.l'''
>>> script = jedi.Script(source, 1, 19, '')
>>> script
<jedi.api.Script at 0x7f6d40f3db90>
>>> completions = script.complete()
>>> completions
[<Completion: load>, <Completion: loads>]
>>> completions[0].complete
'oad'
>>> completions[0].word
'load'

As you see Jedi is pretty simple and allows you to concentrate
writing a good text editor, while still having very good IDE features
for Python.
"""
from __future__ import with_statement
__all__ = ['Script', 'NotFoundError', 'set_debug_function']

import re

import parsing
import dynamic
import imports
import evaluate
import modules
import debug
import settings
import keywords
import helpers
import common
import builtin
import api_classes
import cache

from _compatibility import next, unicode


class NotFoundError(Exception):
    """ A custom error to avoid catching the wrong exceptions """
    pass


class Script(object):
    """
    A Script is the base for a completion, goto or whatever call.

    :param source: The source code of the current file
    :type source: string
    :param line: The line to complete in.
    :type line: int
    :param col: The column to complete in.
    :type col: int
    :param source_path: The path in the os, the current module is in.
    :type source_path: string or None
    :param source_encoding: encoding for decoding `source`, if it
                            is not a `unicode` object.
    :type source_encoding: string
    """
    def __init__(self, source, line, column, source_path,
                                 source_encoding='utf-8'):
        debug.reset_time()
        source = modules.source_to_unicode(source, source_encoding)
        self.pos = line, column
        self.module = modules.ModuleWithCursor(source_path, source=source,
                                                            position=self.pos)
        self.source_path = source_path
        debug.speed('init')<commit_msg>delete caches also at the beginning of an interaction<commit_after>"""
Jedi is an autocompletion library for Python. It offers additonal
services such as goto / get_definition / pydoc support /
get_in_function_call / related names.

To give you a simple exmple how you can use the jedi library,
here is an exmple for the autocompletion feature:

>>> import jedi
>>> source = '''import json; json.l'''
>>> script = jedi.Script(source, 1, 19, '')
>>> script
<jedi.api.Script at 0x7f6d40f3db90>
>>> completions = script.complete()
>>> completions
[<Completion: load>, <Completion: loads>]
>>> completions[0].complete
'oad'
>>> completions[0].word
'load'

As you see Jedi is pretty simple and allows you to concentrate
writing a good text editor, while still having very good IDE features
for Python.
"""
from __future__ import with_statement
__all__ = ['Script', 'NotFoundError', 'set_debug_function']

import re

import parsing
import dynamic
import imports
import evaluate
import modules
import debug
import settings
import keywords
import helpers
import common
import builtin
import api_classes
import cache

from _compatibility import next, unicode


class NotFoundError(Exception):
    """ A custom error to avoid catching the wrong exceptions """
    pass


class Script(object):
    """
    A Script is the base for a completion, goto or whatever call.

    :param source: The source code of the current file
    :type source: string
    :param line: The line to complete in.
    :type line: int
    :param col: The column to complete in.
    :type col: int
    :param source_path: The path in the os, the current module is in.
    :type source_path: string or None
    :param source_encoding: encoding for decoding `source`, if it
                            is not a `unicode` object.
    :type source_encoding: string
    """
    def __init__(self, source, line, column, source_path,
                                 source_encoding='utf-8'):
        api_classes._clear_caches()
        debug.reset_time()
        source = modules.source_to_unicode(source, source_encoding)
        self.pos = line, column
        self.module = modules.ModuleWithCursor(source_path, source=source,
                                                            position=self.pos)
        self.source_path = source_path
        debug.speed('init')
{'fraction_non_alphanumeric': 0.08344226579520697, 'fraction_numerical': 0.006100217864923747, 'mean_word_length': 3.1547511312217194, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5057570', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1222, 'n_words': 500}