How to use the jedi.settings function in jedi

To help you get started, we’ve selected a few jedi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github konstellation-io / science-toolkit / vscode / extensions / ms-python.python-2020.2.63072 / pythonFiles / completion.py View on Github external
jediPath = sys.argv[2]
        jediPreview = True
        cachePrefix = "custom_v"
        if len(sys.argv) > 3:
            modulesToLoad = sys.argv[3]
    else:
        # release
        jediPath = os.path.join(os.path.dirname(__file__), "lib", "python")
        if len(sys.argv) > 1:
            modulesToLoad = sys.argv[1]

    sys.path.insert(0, jediPath)
    import jedi

    if jediPreview:
        jedi.settings.cache_directory = os.path.join(
            jedi.settings.cache_directory,
            cachePrefix + jedi.__version__.replace(".", ""),
        )
    # remove jedi from path after we import it so it will not be completed
    sys.path.pop(0)
    if len(modulesToLoad) > 0:
        jedi.preload_module(*modulesToLoad.split(","))
    JediCompletion().watch()
github DonJayamanne / pythonVSCode / pythonFiles / release / jedi / evaluate / iterable.py View on Github external
def get_execution_parent(element):
        """ Used to get an Instance/FunctionExecution parent """
        if isinstance(element, Array):
            node = element.atom
        else:
            # Is an Instance with an
            # Arguments([AlreadyEvaluated([ArrayInstance])]) inside
            # Yeah... I know... It's complicated ;-)
            node = list(element.var_args.argument_node[0])[0].var_args.trailer
        if isinstance(node, er.InstanceElement):
            return node
        return node.get_parent_until(er.FunctionExecution)

    temp_param_add, settings.dynamic_params_for_other_modules = \
        settings.dynamic_params_for_other_modules, False

    search_names = ['append', 'extend', 'insert'] if is_list else ['add', 'update']
    comp_arr_parent = get_execution_parent(compare_array)

    added_types = []
    for add_name in search_names:
        try:
            possible_names = module.used_names[add_name]
        except KeyError:
            continue
        else:
            for name in possible_names:
                # Check if the original scope is an execution. If it is, one
                # can search for the same statement, that is in the module
                # dict. Executions are somewhat special in jedi, since they
                # literally copy the contents of a function.
github srusskih / SublimeJEDI / dependencies / jedi / api / completion.py View on Github external
def filter_names(inference_state, completion_names, stack, like_name, fuzzy, cached_name):
    comp_dct = set()
    if settings.case_insensitive_completion:
        like_name = like_name.lower()
    for name in completion_names:
        string = name.string_name
        if settings.case_insensitive_completion:
            string = string.lower()
        if helpers.match(string, like_name, fuzzy=fuzzy):
            new = classes.Completion(
                inference_state,
                name,
                stack,
                len(like_name),
                is_fuzzy=fuzzy,
                cached_name=cached_name,
            )
            k = (new.name, new.complete)  # key
            if k not in comp_dct:
                comp_dct.add(k)
                tree_name = name.tree_name
                if tree_name is not None:
                    definition = tree_name.get_definition()
github inclement / Pyonic-interpreter / pyonic / jediinterface.py View on Github external
from jedi import Script, settings
settings.case_insensitive_completion = False

from os.path import abspath, join
settings.cache_directory = join(abspath('.'), '.cache', 'jedi')

from kivy.event import EventDispatcher
from kivy.properties import ListProperty, ObjectProperty
from kivy.clock import mainthread

from functools import partial

from time import time

import threading

import traceback
github srusskih / SublimeJEDI / dependencies / jedi / inference / __init__.py View on Github external
def parse_and_get_code(self, code=None, path=None, encoding='utf-8',
                           use_latest_grammar=False, file_io=None, **kwargs):
        if code is None:
            if file_io is None:
                file_io = FileIO(path)
            code = file_io.read()
        # We cannot just use parso, because it doesn't use errors='replace'.
        code = parso.python_bytes_to_unicode(code, encoding=encoding, errors='replace')

        if len(code) > settings._cropped_file_size:
            code = code[:settings._cropped_file_size]

        grammar = self.latest_grammar if use_latest_grammar else self.grammar
        return grammar.parse(code=code, path=path, file_io=file_io, **kwargs), code
github DamnWidget / anaconda / anaconda_lib / jedi / cache.py View on Github external
if path is None and name is None:
        return None

    tim = os.path.getmtime(path) if path else None
    n = name if path is None else path
    try:
        parser_cache_item = parser_cache[n]
        if not path or tim <= parser_cache_item.change_time:
            return parser_cache_item.parser
        else:
            # In case there is already a module cached and this module
            # has to be reparsed, we also need to invalidate the import
            # caches.
            invalidate_star_import_cache(parser_cache_item.parser.module)
    except KeyError:
        if settings.use_filesystem_cache:
            return ModulePickling.load_module(n, tim)
github bazitur / brackets-python-tools / jedi / evaluate / dynamic.py View on Github external
@debug.increase_indent
def search_params(evaluator, execution_context, funcdef):
    """
    A dynamic search for param values. If you try to complete a type:

    >>> def func(foo):
    ...     foo
    >>> func(1)
    >>> func("")

    It is not known what the type ``foo`` without analysing the whole code. You
    have to look for all calls to ``func`` to find out what ``foo`` possibly
    is.
    """
    if not settings.dynamic_params:
        return set()

    evaluator.dynamic_params_depth += 1
    try:
        debug.dbg('Dynamic param search in %s.', funcdef.name.value, color='MAGENTA')
        module_context = execution_context.get_root_context()
        function_executions = _search_function_executions(
            evaluator,
            module_context,
            funcdef
        )
        if function_executions:
            zipped_params = zip(*list(
                function_execution.get_params()
                for function_execution in function_executions
            ))
github davidhalter / jedi / sith.py View on Github external
def main(arguments):
    debugger = 'pdb' if arguments['--pdb'] else \
               'ipdb' if arguments['--ipdb'] else \
               'pudb' if arguments['--pudb'] else None
    record = arguments['--record']

    jedi.settings.use_filesystem_cache = arguments['--fs-cache']
    if arguments['--debug']:
        jedi.set_debug_function()

    if arguments['redo'] or arguments['show']:
        t = TestCase.from_cache(record)
        if arguments['show']:
            t.show_errors()
        else:
            t.run(debugger)
    elif arguments['run']:
            TestCase(
                arguments[''], arguments['
github ColdGrub1384 / Pyto / site-packages / jedi / api / __init__.py View on Github external
# Compiled modules typically don't allow keyword arguments.
                if not isinstance(module, compiled.CompiledObject):
                    for p in call_sig.params:
                        # Allow access on _definition here, because it's a
                        # public API and we don't want to make the internal
                        # Name object public.
                        if p._definition.stars == 0:  # no *args/**kwargs
                            completion_names.append(p._name)

        needs_dot = not dot and path

        comps = []
        comp_dct = {}
        for c in set(completion_names):
            n = str(c)
            if settings.case_insensitive_completion \
                    and n.lower().startswith(like.lower()) \
                    or n.startswith(like):
                if isinstance(c.parent, (pr.Function, pr.Class)):
                    # TODO I think this is a hack. It should be an
                    #   er.Function/er.Class before that.
                    c = er.wrap(self._evaluator, c.parent).name
                new = classes.Completion(self._evaluator, c, needs_dot, len(like))
                k = (new.name, new.complete)  # key
                if k in comp_dct and settings.no_completion_duplicates:
                    comp_dct[k]._same_name_completions.append(new)
                else:
                    comp_dct[k] = new
                    comps.append(new)

        debug.speed('completions end')
github davidhalter / jedi / jedi / inference / dynamic_params.py View on Github external
def dynamic_param_lookup(function_value, param_index):
    """
    A dynamic search for param values. If you try to complete a type:

    >>> def func(foo):
    ...     foo
    >>> func(1)
    >>> func("")

    It is not known what the type ``foo`` without analysing the whole code. You
    have to look for all calls to ``func`` to find out what ``foo`` possibly
    is.
    """
    funcdef = function_value.tree_node

    if not settings.dynamic_params:
        return NO_VALUES

    path = function_value.get_root_context().py__file__()
    if path is not None and is_stdlib_path(path):
        # We don't want to search for usages in the stdlib. Usually people
        # don't work with it (except if you are a core maintainer, sorry).
        # This makes everything slower. Just disable it and run the tests,
        # you will see the slowdown, especially in 3.6.
        return NO_VALUES

    if funcdef.type == 'lambdef':
        string_name = _get_lambda_name(funcdef)
        if string_name is None:
            return NO_VALUES
    else:
        string_name = funcdef.name.value