Hello community, here is the log from the commit of package python-python-language-server for openSUSE:Factory checked in at 2020-11-13 18:59:27 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-python-language-server (Old) and /work/SRC/openSUSE:Factory/.python-python-language-server.new.24930 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-python-language-server" Fri Nov 13 18:59:27 2020 rev:14 rq:848216 version:0.36.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-python-language-server/python-python-language-server.changes 2020-09-23 18:48:37.213775043 +0200 +++ /work/SRC/openSUSE:Factory/.python-python-language-server.new.24930/python-python-language-server.changes 2020-11-13 18:59:30.798143847 +0100 @@ -1,0 +2,18 @@ +Thu Nov 12 14:23:55 UTC 2020 - Benjamin Greiner <c...@bnavigator.de> + +- Update to 0.36.1 + * Add code in front of the diagnostic message for flake8. + * Pass document path to jedi_names when a file is not placed in a + module. +- Changelog for 0.36.0 + * Allow passing explicit environment variables to Jedi + environment + * Add document path to Jedi's sys_path + * Resolve flake8_executable allowing ~/${HOME} paths + * Pass server settings to new workspaces + * Synchronize document text updates + * Correct method and attribute detection on document/symbols call + * Specify relevant document path when retrieving some plugin + settings + +------------------------------------------------------------------- Old: ---- python-language-server-0.35.1.tar.gz New: ---- python-language-server-0.36.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-python-language-server.spec ++++++ --- /var/tmp/diff_new_pack.WhyH3R/_old 2020-11-13 18:59:31.418144528 +0100 +++ /var/tmp/diff_new_pack.WhyH3R/_new 2020-11-13 18:59:31.422144532 +0100 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %bcond_without python2 Name: python-python-language-server -Version: 0.35.1 +Version: 0.36.1 Release: 0 Summary: Python Language Server for the Language Server Protocol License: MIT @@ -42,7 +42,7 @@ BuildRequires: %{python_module yapf} BuildRequires: fdupes BuildRequires: python-rpm-macros -Requires: python-jedi >= 0.17 +Requires: python-jedi >= 0.17.2 Requires: python-pluggy Requires: python-python-jsonrpc-server >= 0.4.0 Requires: python-setuptools @@ -58,7 +58,7 @@ # SECTION test requirements BuildRequires: %{python_module flaky} BuildRequires: %{python_module future >= 0.14.0} -BuildRequires: %{python_module jedi >= 0.17} +BuildRequires: %{python_module jedi >= 0.17.2} BuildRequires: %{python_module mock} BuildRequires: %{python_module pluggy} BuildRequires: %{python_module pytest} ++++++ python-language-server-0.35.1.tar.gz -> python-language-server-0.36.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/PKG-INFO new/python-language-server-0.36.1/PKG-INFO --- old/python-language-server-0.35.1/PKG-INFO 2020-09-16 22:24:46.802510300 +0200 +++ new/python-language-server-0.36.1/PKG-INFO 2020-11-08 21:19:30.100321000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: python-language-server -Version: 0.35.1 +Version: 0.36.1 Summary: Python Language Server for the Language Server Protocol Home-page: https://github.com/palantir/python-language-server Author: Palantir Technologies, Inc. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/pyls/_utils.py new/python-language-server-0.36.1/pyls/_utils.py --- old/python-language-server-0.35.1/pyls/_utils.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/pyls/_utils.py 2020-11-08 21:19:18.000000000 +0100 @@ -82,6 +82,18 @@ return [] +def path_to_dot_name(path): + """Given a path to a module, derive its dot-separated full name.""" + directory = os.path.dirname(path) + module_name, _ = os.path.splitext(os.path.basename(path)) + full_name = [module_name] + while os.path.exists(os.path.join(directory, '__init__.py')): + this_directory = os.path.basename(directory) + directory = os.path.dirname(directory) + full_name = [this_directory] + full_name + return '.'.join(full_name) + + def match_uri_to_workspace(uri, workspaces): if uri is None: return None diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/pyls/_version.py new/python-language-server-0.36.1/pyls/_version.py --- old/python-language-server-0.35.1/pyls/_version.py 2020-09-16 22:24:46.802510300 +0200 +++ new/python-language-server-0.36.1/pyls/_version.py 2020-11-08 21:19:30.100321000 +0100 @@ -8,11 +8,11 @@ version_json = ''' { - "date": "2020-09-16T15:20:40-0500", + "date": "2020-11-07T11:05:46-0500", "dirty": false, "error": null, - "full-revisionid": "7dbd812124e5baa08aa5299370e09665e0026675", - "version": "0.35.1" + "full-revisionid": "7a98c2c5f9de193a02c2a53405fb951ff7b3ae6b", + "version": "0.36.1" } ''' # END VERSION_JSON diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/pyls/plugins/autopep8_format.py new/python-language-server-0.36.1/pyls/plugins/autopep8_format.py --- old/python-language-server-0.35.1/pyls/plugins/autopep8_format.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/pyls/plugins/autopep8_format.py 2020-11-08 21:19:18.000000000 +0100 @@ -28,7 +28,7 @@ def _format(config, document, line_range=None): - options = _autopep8_config(config) + options = _autopep8_config(config, document) if line_range: options['line_range'] = list(line_range) @@ -57,9 +57,10 @@ }] -def _autopep8_config(config): +def _autopep8_config(config, document=None): # We user pycodestyle settings to avoid redefining things - settings = config.plugin_settings('pycodestyle') + path = document.path if document is not None else None + settings = config.plugin_settings('pycodestyle', document_path=path) options = { 'exclude': settings.get('exclude'), 'hang_closing': settings.get('hangClosing'), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/pyls/plugins/flake8_lint.py new/python-language-server-0.36.1/pyls/plugins/flake8_lint.py --- old/python-language-server-0.35.1/pyls/plugins/flake8_lint.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/pyls/plugins/flake8_lint.py 2020-11-08 21:19:18.000000000 +0100 @@ -1,7 +1,7 @@ # Copyright 2019 Palantir Technologies, Inc. """Linter pluging for flake8""" import logging -from os import path +import os.path import re from subprocess import Popen, PIPE from pyls import hookimpl, lsp @@ -19,7 +19,7 @@ @hookimpl def pyls_lint(workspace, document): config = workspace._config - settings = config.plugin_settings('flake8') + settings = config.plugin_settings('flake8', document_path=document.path) log.debug("Got flake8 settings: %s", settings) opts = { @@ -34,8 +34,8 @@ # flake takes only absolute path to the config. So we should check and # convert if necessary - if opts.get('config') and not path.isabs(opts.get('config')): - opts['config'] = path.abspath(path.expanduser(path.expandvars( + if opts.get('config') and not os.path.isabs(opts.get('config')): + opts['config'] = os.path.abspath(os.path.expanduser(os.path.expandvars( opts.get('config') ))) log.debug("using flake8 with config: %s", opts['config']) @@ -56,6 +56,12 @@ args = [(i if not i.startswith('--ignore=') else FIX_IGNORES_RE.sub('', i)) for i in args if i is not None] + # if executable looks like a path resolve it + if not os.path.isfile(flake8_executable) and os.sep in flake8_executable: + flake8_executable = os.path.abspath( + os.path.expanduser(os.path.expandvars(flake8_executable)) + ) + log.debug("Calling %s with args: '%s'", flake8_executable, args) try: cmd = [flake8_executable] @@ -138,6 +144,8 @@ _, line, character, code, msg = parsed_line line = int(line) - 1 character = int(character) - 1 + # show also the code in message + msg = code + ' ' + msg diagnostics.append( { 'source': 'flake8', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/pyls/plugins/jedi_completion.py new/python-language-server-0.36.1/pyls/plugins/jedi_completion.py --- old/python-language-server-0.35.1/pyls/plugins/jedi_completion.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/pyls/plugins/jedi_completion.py 2020-11-08 21:19:18.000000000 +0100 @@ -57,7 +57,7 @@ code_position = _utils.position_to_jedi_linecolumn(document, position) code_position["fuzzy"] = settings.get("fuzzy", False) - completions = document.jedi_script().complete(**code_position) + completions = document.jedi_script(use_document_path=True).complete(**code_position) if not completions: return None diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/pyls/plugins/mccabe_lint.py new/python-language-server-0.36.1/pyls/plugins/mccabe_lint.py --- old/python-language-server-0.35.1/pyls/plugins/mccabe_lint.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/pyls/plugins/mccabe_lint.py 2020-11-08 21:19:18.000000000 +0100 @@ -12,7 +12,7 @@ @hookimpl def pyls_lint(config, document): - threshold = config.plugin_settings('mccabe').get(THRESHOLD, DEFAULT_THRESHOLD) + threshold = config.plugin_settings('mccabe', document_path=document.path).get(THRESHOLD, DEFAULT_THRESHOLD) log.debug("Running mccabe lint with threshold: %s", threshold) try: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/pyls/plugins/preload_imports.py new/python-language-server-0.36.1/pyls/plugins/preload_imports.py --- old/python-language-server-0.35.1/pyls/plugins/preload_imports.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/pyls/plugins/preload_imports.py 2020-11-08 21:19:18.000000000 +0100 @@ -30,5 +30,8 @@ try: __import__(mod_name) log.debug("Preloaded module %s", mod_name) - except ImportError: + except Exception: # pylint: disable=broad-except + # Catch any exception since not only ImportError can be raised here + # For example, old versions of NumPy can cause a ValueError. + # See spyder-ide/spyder#13985 pass diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/pyls/plugins/pycodestyle_lint.py new/python-language-server-0.36.1/pyls/plugins/pycodestyle_lint.py --- old/python-language-server-0.35.1/pyls/plugins/pycodestyle_lint.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/pyls/plugins/pycodestyle_lint.py 2020-11-08 21:19:18.000000000 +0100 @@ -21,7 +21,7 @@ @hookimpl def pyls_lint(workspace, document): config = workspace._config - settings = config.plugin_settings('pycodestyle') + settings = config.plugin_settings('pycodestyle', document_path=document.path) log.debug("Got pycodestyle settings: %s", settings) opts = { @@ -78,5 +78,13 @@ 'message': text, 'code': code, # Are style errors really ever errors? - 'severity': lsp.DiagnosticSeverity.Warning + 'severity': _get_severity(code) }) + + +def _get_severity(code): + # Are style errors ever really errors? + if code[0] == 'E' or code[0] == 'W': + return lsp.DiagnosticSeverity.Warning + # If no severity is specified, why wouldn't this be informational only? + return lsp.DiagnosticSeverity.Information diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/pyls/plugins/pydocstyle_lint.py new/python-language-server-0.36.1/pyls/plugins/pydocstyle_lint.py --- old/python-language-server-0.35.1/pyls/plugins/pydocstyle_lint.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/pyls/plugins/pydocstyle_lint.py 2020-11-08 21:19:18.000000000 +0100 @@ -26,7 +26,7 @@ @hookimpl def pyls_lint(config, document): - settings = config.plugin_settings('pydocstyle') + settings = config.plugin_settings('pydocstyle', document_path=document.path) log.debug("Got pydocstyle settings: %s", settings) # Explicitly passing a path to pydocstyle means it doesn't respect the --match flag, so do it ourselves diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/pyls/plugins/symbols.py new/python-language-server-0.36.1/pyls/plugins/symbols.py --- old/python-language-server-0.35.1/pyls/plugins/symbols.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/pyls/plugins/symbols.py 2020-11-08 21:19:18.000000000 +0100 @@ -1,5 +1,7 @@ # Copyright 2017 Palantir Technologies, Inc. import logging +import os + from pyls import hookimpl from pyls.lsp import SymbolKind @@ -8,17 +10,71 @@ @hookimpl def pyls_document_symbols(config, document): - all_scopes = config.plugin_settings('jedi_symbols').get('all_scopes', True) - definitions = document.jedi_names(all_scopes=all_scopes) - return [{ - 'name': d.name, - 'containerName': _container(d), - 'location': { - 'uri': document.uri, - 'range': _range(d), - }, - 'kind': _kind(d), - } for d in definitions if _include_def(d)] + # pylint: disable=broad-except + # pylint: disable=too-many-nested-blocks + # pylint: disable=too-many-locals + # pylint: disable=too-many-branches + symbols_settings = config.plugin_settings('jedi_symbols') + all_scopes = symbols_settings.get('all_scopes', True) + add_import_symbols = symbols_settings.get('include_import_symbols', True) + + use_document_path = False + document_dir = os.path.normpath(os.path.dirname(document.path)) + if not os.path.isfile(os.path.join(document_dir, '__init__.py')): + use_document_path = True + + definitions = document.jedi_names(use_document_path, all_scopes=all_scopes) + module_name = document.dot_path + symbols = [] + exclude = set({}) + redefinitions = {} + while definitions != []: + d = definitions.pop(0) + if not add_import_symbols: + sym_full_name = d.full_name + if sym_full_name is not None: + if (not sym_full_name.startswith(module_name) and + not sym_full_name.startswith('__main__')): + continue + + if _include_def(d) and document.path == d.module_path: + tuple_range = _tuple_range(d) + if tuple_range in exclude: + continue + + kind = redefinitions.get(tuple_range, None) + if kind is not None: + exclude |= {tuple_range} + + if d.type == 'statement': + if d.description.startswith('self'): + kind = 'field' + + symbol = { + 'name': d.name, + 'containerName': _container(d), + 'location': { + 'uri': document.uri, + 'range': _range(d), + }, + 'kind': _kind(d) if kind is None else _SYMBOL_KIND_MAP[kind], + } + symbols.append(symbol) + + if d.type == 'class': + try: + defined_names = list(d.defined_names()) + for method in defined_names: + if method.type == 'function': + redefinitions[_tuple_range(method)] = 'method' + elif method.type == 'statement': + redefinitions[_tuple_range(method)] = 'field' + else: + redefinitions[_tuple_range(method)] = method.type + definitions = list(defined_names) + definitions + except Exception: + pass + return symbols def _include_def(definition): @@ -56,6 +112,11 @@ } +def _tuple_range(definition): + definition = definition._name.tree_name.get_definition() + return (definition.start_pos, definition.end_pos) + + _SYMBOL_KIND_MAP = { 'none': SymbolKind.Variable, 'type': SymbolKind.Class, @@ -95,6 +156,7 @@ 'string': SymbolKind.String, 'unicode': SymbolKind.String, 'list': SymbolKind.Array, + 'field': SymbolKind.Field } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/pyls/python_ls.py new/python-language-server-0.36.1/pyls/python_ls.py --- old/python-language-server-0.35.1/pyls/python_ls.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/pyls/python_ls.py 2020-11-08 21:19:18.000000000 +0100 @@ -379,6 +379,7 @@ workspace_config = config.Config( added_uri, self.config._init_opts, self.config._process_id, self.config._capabilities) + workspace_config.update(self.config._settings) self.workspaces[added_uri] = Workspace( added_uri, self._endpoint, workspace_config) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/pyls/workspace.py new/python-language-server-0.36.1/pyls/workspace.py --- old/python-language-server-0.35.1/pyls/workspace.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/pyls/workspace.py 2020-11-08 21:19:18.000000000 +0100 @@ -3,6 +3,8 @@ import logging import os import re +import functools +from threading import RLock import jedi @@ -15,6 +17,15 @@ RE_END_WORD = re.compile('^[A-Za-z_0-9]*') +def lock(method): + """Define an atomic region over a method.""" + @functools.wraps(method) + def wrapper(self, *args, **kwargs): + with self._lock: + return method(self, *args, **kwargs) + return wrapper + + class Workspace(object): M_PUBLISH_DIAGNOSTICS = 'textDocument/publishDiagnostics' @@ -122,6 +133,7 @@ self.uri = uri self.version = version self.path = uris.to_fs_path(uri) + self.dot_path = _utils.path_to_dot_name(self.path) self.filename = os.path.basename(self.path) self._config = workspace._config @@ -130,6 +142,7 @@ self._source = source self._extra_sys_path = extra_sys_path or [] self._rope_project_builder = rope_project_builder + self._lock = RLock() def __str__(self): return str(self.uri) @@ -139,10 +152,12 @@ return libutils.path_to_resource(self._rope_project_builder(rope_config), self.path) @property + @lock def lines(self): return self.source.splitlines(True) @property + @lock def source(self): if self._source is None: with io.open(self.path, 'r', encoding='utf-8') as f: @@ -152,6 +167,7 @@ def update_config(self, settings): self._config.update((settings or {}).get('pyls', {})) + @lock def apply_change(self, change): """Apply a change to the document.""" text = change['text'] @@ -217,24 +233,38 @@ return m_start[0] + m_end[-1] - def jedi_names(self, all_scopes=False, definitions=True, references=False): - script = self.jedi_script() + @lock + def jedi_names(self, use_document_path, all_scopes=False, definitions=True, references=False): + script = self.jedi_script(use_document_path=use_document_path) return script.get_names(all_scopes=all_scopes, definitions=definitions, references=references) - def jedi_script(self, position=None): + @lock + def jedi_script(self, position=None, use_document_path=False): 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') - environment = self.get_enviroment(environment_path) if environment_path else None - sys_path = self.sys_path(environment_path) + extra_paths + # 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 + # Extend sys_path with document's path if requested + if use_document_path: + sys_path += [os.path.normpath(os.path.dirname(self.path))] + kwargs = { 'code': self.source, 'path': self.path, @@ -248,7 +278,7 @@ return jedi.Script(**kwargs) - def get_enviroment(self, environment_path=None): + def get_enviroment(self, environment_path=None, env_vars=None): # TODO(gatesn): #339 - make better use of jedi environments, they seem pretty powerful if environment_path is None: environment = jedi.api.environment.get_cached_default_environment() @@ -256,14 +286,17 @@ if environment_path in self._workspace._environments: environment = self._workspace._environments[environment_path] else: - environment = jedi.api.environment.create_environment(path=environment_path, safe=False) + environment = jedi.api.environment.create_environment(path=environment_path, + safe=False, + env_vars=env_vars) self._workspace._environments[environment_path] = environment return environment - def sys_path(self, environment_path=None): + def sys_path(self, environment_path=None, env_vars=None): # Copy our extra sys path + # TODO: when safe to break API, use env_vars explicitly to pass to create_environment path = list(self._extra_sys_path) - environment = self.get_enviroment(environment_path=environment_path) + environment = self.get_enviroment(environment_path=environment_path, env_vars=env_vars) path.extend(environment.get_sys_path()) return path diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/python_language_server.egg-info/PKG-INFO new/python-language-server-0.36.1/python_language_server.egg-info/PKG-INFO --- old/python-language-server-0.35.1/python_language_server.egg-info/PKG-INFO 2020-09-16 22:24:46.000000000 +0200 +++ new/python-language-server-0.36.1/python_language_server.egg-info/PKG-INFO 2020-11-08 21:19:29.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: python-language-server -Version: 0.35.1 +Version: 0.36.1 Summary: Python Language Server for the Language Server Protocol Home-page: https://github.com/palantir/python-language-server Author: Palantir Technologies, Inc. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/python_language_server.egg-info/requires.txt new/python-language-server-0.36.1/python_language_server.egg-info/requires.txt --- old/python-language-server-0.35.1/python_language_server.egg-info/requires.txt 2020-09-16 22:24:46.000000000 +0200 +++ new/python-language-server-0.36.1/python_language_server.egg-info/requires.txt 2020-11-08 21:19:29.000000000 +0100 @@ -1,4 +1,4 @@ -jedi<0.18.0,>=0.17.0 +jedi<0.18.0,>=0.17.2 python-jsonrpc-server>=0.4.0 pluggy diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/setup.py new/python-language-server-0.36.1/setup.py --- old/python-language-server-0.35.1/setup.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/setup.py 2020-11-08 21:19:18.000000000 +0100 @@ -10,7 +10,7 @@ 'configparser; python_version<"3.0"', 'future>=0.14.0; python_version<"3"', 'backports.functools_lru_cache; python_version<"3.2"', - 'jedi>=0.17.0,<0.18.0', + 'jedi>=0.17.2,<0.18.0', 'python-jsonrpc-server>=0.4.0', 'pluggy', 'ujson<=2.0.3 ; platform_system!="Windows" and python_version<"3.0"', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/test/fixtures.py new/python-language-server-0.36.1/test/fixtures.py --- old/python-language-server-0.35.1/test/fixtures.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/test/fixtures.py 2020-11-08 21:19:18.000000000 +0100 @@ -45,6 +45,15 @@ @pytest.fixture +def workspace_other_root_path(tmpdir): + """Return a workspace with a root_path other than tmpdir.""" + ws_path = str(tmpdir.mkdir('test123').mkdir('test456')) + ws = Workspace(uris.from_fs_path(ws_path), Mock()) + ws._config = Config(ws.root_uri, {}, 0, {}) + return ws + + +@pytest.fixture def config(workspace): # pylint: disable=redefined-outer-name """Return a config object.""" return Config(workspace.root_uri, {}, 0, {}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/test/plugins/test_completion.py new/python-language-server-0.36.1/test/plugins/test_completion.py --- old/python-language-server-0.35.1/test/plugins/test_completion.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/test/plugins/test_completion.py 2020-11-08 21:19:18.000000000 +0100 @@ -334,3 +334,26 @@ completions = pyls_jedi_completions(doc._config, doc, com_position) assert completions[0]['label'] == 'loghub' assert 'changelog generator' in completions[0]['documentation'].lower() + + +def test_document_path_completions(tmpdir, workspace_other_root_path): + # Create a dummy module out of the workspace's root_path and try to get + # completions for it in another file placed next to it. + module_content = ''' +def foo(): + pass +''' + + p = tmpdir.join("mymodule.py") + p.write(module_content) + + # Content of doc to test completion + doc_content = """import mymodule +mymodule.f""" + doc_path = str(tmpdir) + os.path.sep + 'myfile.py' + doc_uri = uris.from_fs_path(doc_path) + doc = Document(doc_uri, workspace_other_root_path, doc_content) + + com_position = {'line': 1, 'character': 10} + completions = pyls_jedi_completions(doc._config, doc, com_position) + assert completions[0]['label'] == 'foo()' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/test/plugins/test_flake8_lint.py new/python-language-server-0.36.1/test/plugins/test_flake8_lint.py --- old/python-language-server-0.35.1/test/plugins/test_flake8_lint.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/test/plugins/test_flake8_lint.py 2020-11-08 21:19:18.000000000 +0100 @@ -31,7 +31,7 @@ def test_flake8_unsaved(workspace): doc = Document('', workspace, DOC) diags = flake8_lint.pyls_lint(workspace, doc) - msg = 'local variable \'a\' is assigned to but never used' + msg = 'F841 local variable \'a\' is assigned to but never used' unused_var = [d for d in diags if d['message'] == msg][0] assert unused_var['source'] == 'flake8' @@ -45,7 +45,7 @@ try: name, doc = temp_document(DOC, workspace) diags = flake8_lint.pyls_lint(workspace, doc) - msg = 'local variable \'a\' is assigned to but never used' + msg = 'F841 local variable \'a\' is assigned to but never used' unused_var = [d for d in diags if d['message'] == msg][0] assert unused_var['source'] == 'flake8' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/test/plugins/test_symbols.py new/python-language-server-0.36.1/test/plugins/test_symbols.py --- old/python-language-server-0.35.1/test/plugins/test_symbols.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/test/plugins/test_symbols.py 2020-11-08 21:19:18.000000000 +0100 @@ -40,7 +40,7 @@ # Check we have some sane mappings to VSCode constants assert sym('a')['kind'] == SymbolKind.Variable assert sym('B')['kind'] == SymbolKind.Class - assert sym('__init__')['kind'] == SymbolKind.Function + assert sym('__init__')['kind'] == SymbolKind.Method assert sym('main')['kind'] == SymbolKind.Function # Not going to get too in-depth here else we're just testing Jedi @@ -54,7 +54,7 @@ # All four symbols (import sys, a, B, main) # y is not in the root scope, it shouldn't be returned - assert len(symbols) == 4 + assert len(symbols) == 5 def sym(name): return [s for s in symbols if s['name'] == name][0] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-language-server-0.35.1/test/test_workspace.py new/python-language-server-0.36.1/test/test_workspace.py --- old/python-language-server-0.35.1/test/test_workspace.py 2020-09-16 22:24:32.000000000 +0200 +++ new/python-language-server-0.36.1/test/test_workspace.py 2020-11-08 21:19:18.000000000 +0100 @@ -242,3 +242,23 @@ seetings = pyls.workspaces[str(workspace3_dir)]._config.settings() assert seetings['plugins']['pycodestyle']['maxLineLength'] == 20 + + +def test_settings_of_added_workspace(pyls, tmpdir): + test_uri = str(tmpdir.mkdir('Test123')) + pyls.root_uri = test_uri + pyls.workspace._root_uri = test_uri + + # Set some settings for the server. + server_settings = {'pyls': {'plugins': {'jedi': {'environment': '/usr/bin/python3'}}}} + pyls.m_workspace__did_change_configuration(server_settings) + + # Create a new workspace. + workspace1 = {'uri': str(tmpdir.mkdir('NewTest456'))} + event = {'added': [workspace1]} + pyls.m_workspace__did_change_workspace_folders(event) + + # Assert settings are inherited from the server config. + workspace1_object = pyls.workspaces[workspace1['uri']] + workspace1_jedi_settings = workspace1_object._config.plugin_settings('jedi') + assert workspace1_jedi_settings == server_settings['pyls']['plugins']['jedi'] _______________________________________________ openSUSE Commits mailing list -- commit@lists.opensuse.org To unsubscribe, email commit-le...@lists.opensuse.org List Netiquette: https://en.opensuse.org/openSUSE:Mailing_list_netiquette List Archives: https://lists.opensuse.org/archives/list/commit@lists.opensuse.org