# Buggy code
def jedi_script(self, position=None):
    extra_paths = []
    environment_path = None

    if self._config:
        jedi_settings = self._config.plugin_settings("jedi", document_path=self.path)
        environment_path = jedi_settings.get("environment")
        extra_paths = jedi_settings.get("extra_paths") or []

    environment = self.get_enviroment(environment_path) if environment_path else None
    sys_path = self.sys_path(environment_path) + extra_paths
    project_path = self._workspace.root_path

    kwargs = {
        "code": self.source,
        "path": self.path,
        "environment": environment,
        "project": jedi.Project(path=project_path, sys_path=sys_path),
    }

    if position:
        # Deprecated by Jedi to use in Script() constructor
        kwargs += _utils.position_to_jedi_linecolumn(self, position)

    return jedi.Script(**kwargs)


# Traceback (TypeError)
File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\codeeditor.py", line 1440, in handle_go_to_definition
def_range = position['range']
TypeError: list indices must be integers or slices, not str

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\ProgramData\Anaconda3\lib\logging\__init__.py", line 992, in emit
msg = self.format(record)
File "c:\ProgramData\Anaconda3\lib\logging\__init__.py", line 838, in format
return fmt.format(record)
File "c:\ProgramData\Anaconda3\lib\logging\__init__.py", line 575, in format
record.message = record.getMessage()
File "c:\ProgramData\Anaconda3\lib\logging\__init__.py", line 338, in getMessage
msg = msg % self.args
ValueError: incomplete format
Call stack:
File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\app\start.py", line 223, in <module>
main()
File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\app\start.py", line 219, in main
mainwindow.main()
File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3651, in main
mainwindow = run_spyder(app, options, args)
File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3567, in run_spyder
app.exec_()
File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\completion\languageserver\client.py", line 497, in on_msg_received
self.req_reply[req_id](None, {'params': []})
File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\completion\languageserver\plugin.py", line 549, in receive_response
self.COMPLETION_CLIENT_NAME, req_id, response)
File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\completion\plugin.py", line 123, in receive_response
self.howto_send_to_codeeditor(req_id)
File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\completion\plugin.py", line 171, in howto_send_to_codeeditor
self.skip_and_send_to_codeeditor(req_id)
File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\completion\plugin.py", line 205, in skip_and_send_to_codeeditor
self.gather_and_send_to_codeeditor(request_responses)
File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\completion\plugin.py", line 273, in gather_and_send_to_codeeditor
response_instance.handle_response(req_type, responses)
File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\codeeditor.py", line 1019, in handle_response
handler(params)
File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\codeeditor.py", line 1457, in handle_go_to_definition
"Error when processing go to definition")
File "c:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\codeeditor.py", line 1050, in log_lsp_handle_errors
logger.error('%', 1, stack_info=True)
Message: '%'
Arguments: (1,)

# Fixed code
def jedi_script(self, position=None):
    extra_paths = []
    environment_path = None
    env_vars = None

    if self._config:
        jedi_settings = self._config.plugin_settings("jedi", document_path=self.path)
        environment_path = jedi_settings.get("environment")
        extra_paths = jedi_settings.get("extra_paths") or []
        env_vars = jedi_settings.get("env_vars")

    # Drop PYTHONPATH from env_vars before creating the environment because that makes
    # Jedi throw an error.
    if env_vars is None:
        env_vars = os.environ.copy()
    env_vars.pop("PYTHONPATH", None)

    environment = (
        self.get_enviroment(environment_path, env_vars=env_vars)
        if environment_path
        else None
    )
    sys_path = self.sys_path(environment_path, env_vars=env_vars) + extra_paths
    project_path = self._workspace.root_path

    kwargs = {
        "code": self.source,
        "path": self.path,
        "environment": environment,
        "project": jedi.Project(path=project_path, sys_path=sys_path),
    }

    if position:
        # Deprecated by Jedi to use in Script() constructor
        kwargs += _utils.position_to_jedi_linecolumn(self, position)

    return jedi.Script(**kwargs)