Skip to content

Commit 3e508b1

Browse files
authored
Revert "Rename _utils module to utils" (#481)
1 parent 1c4ad71 commit 3e508b1

20 files changed

+71
-71
lines changed
File renamed without changes.

pylsp/config/config.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pluggy
1111
from pluggy._hooks import HookImpl
1212

13-
from pylsp import utils, hookspecs, uris, PYLSP
13+
from pylsp import _utils, hookspecs, uris, PYLSP
1414

1515
# See compatibility note on `group` keyword:
1616
# https://docs.python.org/3/library/importlib.metadata.html#entry-points
@@ -94,11 +94,11 @@ def __init__(self, root_uri, init_opts, process_id, capabilities):
9494
log.info("Loaded pylsp plugin %s from %s", name, plugin)
9595

9696
for plugin_conf in self._pm.hook.pylsp_settings(config=self):
97-
self._plugin_settings = utils.merge_dicts(
97+
self._plugin_settings = _utils.merge_dicts(
9898
self._plugin_settings, plugin_conf
9999
)
100100

101-
self._plugin_settings = utils.merge_dicts(
101+
self._plugin_settings = _utils.merge_dicts(
102102
self._plugin_settings, self._init_opts.get("pylsp", {})
103103
)
104104

@@ -144,10 +144,10 @@ def settings(self, document_path=None):
144144
sources = self._settings.get("configurationSources", DEFAULT_CONFIG_SOURCES)
145145

146146
# Plugin configuration
147-
settings = utils.merge_dicts(settings, self._plugin_settings)
147+
settings = _utils.merge_dicts(settings, self._plugin_settings)
148148

149149
# LSP configuration
150-
settings = utils.merge_dicts(settings, self._settings)
150+
settings = _utils.merge_dicts(settings, self._settings)
151151

152152
# User configuration
153153
for source_name in reversed(sources):
@@ -158,7 +158,7 @@ def settings(self, document_path=None):
158158
log.debug(
159159
"Got user config from %s: %s", source.__class__.__name__, source_conf
160160
)
161-
settings = utils.merge_dicts(settings, source_conf)
161+
settings = _utils.merge_dicts(settings, source_conf)
162162

163163
# Project configuration
164164
for source_name in reversed(sources):
@@ -169,15 +169,15 @@ def settings(self, document_path=None):
169169
log.debug(
170170
"Got project config from %s: %s", source.__class__.__name__, source_conf
171171
)
172-
settings = utils.merge_dicts(settings, source_conf)
172+
settings = _utils.merge_dicts(settings, source_conf)
173173

174174
log.debug("With configuration: %s", settings)
175175

176176
return settings
177177

178178
def find_parents(self, path, names):
179179
root_path = uris.to_fs_path(self._root_uri)
180-
return utils.find_parents(root_path, path, names)
180+
return _utils.find_parents(root_path, path, names)
181181

182182
def plugin_settings(self, plugin, document_path=None):
183183
return (

pylsp/config/flake8_conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import logging
55
import os
6-
from pylsp.utils import find_parents
6+
from pylsp._utils import find_parents
77
from .source import ConfigSource
88

99
log = logging.getLogger(__name__)

pylsp/config/pycodestyle_conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright 2021- Python Language Server Contributors.
33

44
import pycodestyle
5-
from pylsp.utils import find_parents
5+
from pylsp._utils import find_parents
66
from .source import ConfigSource
77

88

pylsp/plugins/autopep8_format.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from autopep8 import fix_code, continued_indentation as autopep8_c_i
88

99
from pylsp import hookimpl
10-
from pylsp.utils import get_eol_chars
10+
from pylsp._utils import get_eol_chars
1111

1212
log = logging.getLogger(__name__)
1313

pylsp/plugins/definition.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import jedi
88

9-
from pylsp import hookimpl, uris, utils
9+
from pylsp import hookimpl, uris, _utils
1010

1111
if TYPE_CHECKING:
1212
from jedi.api import Script
@@ -44,7 +44,7 @@ def pylsp_definitions(
4444
config: Config, document: Document, position: Dict[str, int]
4545
) -> List[Dict[str, Any]]:
4646
settings = config.plugin_settings("jedi_definition")
47-
code_position = utils.position_to_jedi_linecolumn(document, position)
47+
code_position = _utils.position_to_jedi_linecolumn(document, position)
4848
script = document.jedi_script(use_document_path=True)
4949
auto_import_modules = jedi.settings.auto_import_modules
5050

pylsp/plugins/highlight.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# Copyright 2021- Python Language Server Contributors.
33

44
import logging
5-
from pylsp import hookimpl, lsp, utils
5+
from pylsp import hookimpl, lsp, _utils
66

77
log = logging.getLogger(__name__)
88

99

1010
@hookimpl
1111
def pylsp_document_highlight(document, position):
12-
code_position = utils.position_to_jedi_linecolumn(document, position)
12+
code_position = _utils.position_to_jedi_linecolumn(document, position)
1313
usages = document.jedi_script().get_references(**code_position)
1414

1515
def is_valid(definition):

pylsp/plugins/hover.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
import logging
55

6-
from pylsp import hookimpl, utils
6+
from pylsp import hookimpl, _utils
77

88
log = logging.getLogger(__name__)
99

1010

1111
@hookimpl
1212
def pylsp_hover(config, document, position):
13-
code_position = utils.position_to_jedi_linecolumn(document, position)
13+
code_position = _utils.position_to_jedi_linecolumn(document, position)
1414
definitions = document.jedi_script(use_document_path=True).infer(**code_position)
1515
word = document.word_at_position(position)
1616

@@ -28,7 +28,7 @@ def pylsp_hover(config, document, position):
2828

2929
hover_capabilities = config.capabilities.get("textDocument", {}).get("hover", {})
3030
supported_markup_kinds = hover_capabilities.get("contentFormat", ["markdown"])
31-
preferred_markup_kind = utils.choose_markup_kind(supported_markup_kinds)
31+
preferred_markup_kind = _utils.choose_markup_kind(supported_markup_kinds)
3232

3333
# Find first exact matching signature
3434
signature = next(
@@ -41,7 +41,7 @@ def pylsp_hover(config, document, position):
4141
)
4242

4343
return {
44-
"contents": utils.format_docstring(
44+
"contents": _utils.format_docstring(
4545
# raw docstring returns only doc, without signature
4646
definition.docstring(raw=True),
4747
preferred_markup_kind,

pylsp/plugins/jedi_completion.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import parso
88

9-
from pylsp import utils, hookimpl, lsp
9+
from pylsp import _utils, hookimpl, lsp
1010
from pylsp.plugins._resolvers import LABEL_RESOLVER, SNIPPET_RESOLVER
1111

1212
log = logging.getLogger(__name__)
@@ -41,7 +41,7 @@ def pylsp_completions(config, document, position):
4141
# pylint: disable=too-many-locals
4242
settings = config.plugin_settings("jedi_completion", document_path=document.path)
4343
resolve_eagerly = settings.get("eager", False)
44-
code_position = utils.position_to_jedi_linecolumn(document, position)
44+
code_position = _utils.position_to_jedi_linecolumn(document, position)
4545

4646
code_position["fuzzy"] = settings.get("fuzzy", False)
4747
completions = document.jedi_script(use_document_path=True).complete(**code_position)
@@ -55,7 +55,7 @@ def pylsp_completions(config, document, position):
5555
item_capabilities = completion_capabilities.get("completionItem", {})
5656
snippet_support = item_capabilities.get("snippetSupport")
5757
supported_markup_kinds = item_capabilities.get("documentationFormat", ["markdown"])
58-
preferred_markup_kind = utils.choose_markup_kind(supported_markup_kinds)
58+
preferred_markup_kind = _utils.choose_markup_kind(supported_markup_kinds)
5959

6060
should_include_params = settings.get("include_params")
6161
should_include_class_objects = settings.get("include_class_objects", False)
@@ -146,7 +146,7 @@ def pylsp_completion_item_resolve(config, completion_item, document):
146146
)
147147
item_capabilities = completion_capabilities.get("completionItem", {})
148148
supported_markup_kinds = item_capabilities.get("documentationFormat", ["markdown"])
149-
preferred_markup_kind = utils.choose_markup_kind(supported_markup_kinds)
149+
preferred_markup_kind = _utils.choose_markup_kind(supported_markup_kinds)
150150

151151
if shared_data:
152152
completion, data = shared_data
@@ -209,7 +209,7 @@ def _resolve_completion(completion, d, markup_kind: str):
209209
# pylint: disable=broad-except
210210
completion["detail"] = _detail(d)
211211
try:
212-
docs = utils.format_docstring(
212+
docs = _utils.format_docstring(
213213
d.docstring(raw=True),
214214
signatures=[signature.to_string() for signature in d.get_signatures()],
215215
markup_kind=markup_kind,

pylsp/plugins/jedi_rename.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import logging
55

6-
from pylsp import hookimpl, uris, utils
6+
from pylsp import hookimpl, uris, _utils
77

88
log = logging.getLogger(__name__)
99

@@ -15,7 +15,7 @@ def pylsp_rename(
1515
log.debug(
1616
"Executing rename of %s to %s", document.word_at_position(position), new_name
1717
)
18-
kwargs = utils.position_to_jedi_linecolumn(document, position)
18+
kwargs = _utils.position_to_jedi_linecolumn(document, position)
1919
kwargs["new_name"] = new_name
2020
try:
2121
refactoring = document.jedi_script().rename(**kwargs)
@@ -54,6 +54,6 @@ def pylsp_rename(
5454

5555
def _num_lines(file_contents):
5656
"Count the number of lines in the given string."
57-
if utils.get_eol_chars(file_contents):
57+
if _utils.get_eol_chars(file_contents):
5858
return len(file_contents.splitlines())
5959
return 0

pylsp/plugins/pycodestyle_lint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pycodestyle
77

88
from pylsp import hookimpl, lsp
9-
from pylsp.utils import get_eol_chars
9+
from pylsp._utils import get_eol_chars
1010

1111
try:
1212
from autopep8 import continued_indentation as autopep8_c_i

pylsp/plugins/references.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# Copyright 2021- Python Language Server Contributors.
33

44
import logging
5-
from pylsp import hookimpl, uris, utils
5+
from pylsp import hookimpl, uris, _utils
66

77
log = logging.getLogger(__name__)
88

99

1010
@hookimpl
1111
def pylsp_references(document, position, exclude_declaration):
12-
code_position = utils.position_to_jedi_linecolumn(document, position)
12+
code_position = _utils.position_to_jedi_linecolumn(document, position)
1313
usages = document.jedi_script().get_references(**code_position)
1414

1515
if exclude_declaration:

pylsp/plugins/rope_completion.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import logging
55
from rope.contrib.codeassist import code_assist, sorted_proposals
66

7-
from pylsp import utils, hookimpl, lsp
7+
from pylsp import _utils, hookimpl, lsp
88

99

1010
log = logging.getLogger(__name__)
@@ -19,7 +19,7 @@ def pylsp_settings():
1919
def _resolve_completion(completion, data, markup_kind):
2020
# pylint: disable=broad-except
2121
try:
22-
doc = utils.format_docstring(data.get_doc(), markup_kind=markup_kind)
22+
doc = _utils.format_docstring(data.get_doc(), markup_kind=markup_kind)
2323
except Exception as e:
2424
log.debug("Failed to resolve Rope completion: %s", e)
2525
doc = ""
@@ -57,7 +57,7 @@ def pylsp_completions(config, workspace, document, position):
5757
)
5858
item_capabilities = completion_capabilities.get("completionItem", {})
5959
supported_markup_kinds = item_capabilities.get("documentationFormat", ["markdown"])
60-
preferred_markup_kind = utils.choose_markup_kind(supported_markup_kinds)
60+
preferred_markup_kind = _utils.choose_markup_kind(supported_markup_kinds)
6161

6262
try:
6363
definitions = code_assist(
@@ -104,7 +104,7 @@ def pylsp_completion_item_resolve(config, completion_item, document):
104104
)
105105
item_capabilities = completion_capabilities.get("completionItem", {})
106106
supported_markup_kinds = item_capabilities.get("documentationFormat", ["markdown"])
107-
preferred_markup_kind = utils.choose_markup_kind(supported_markup_kinds)
107+
preferred_markup_kind = _utils.choose_markup_kind(supported_markup_kinds)
108108

109109
if shared_data:
110110
completion, data = shared_data

pylsp/plugins/rope_rename.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from rope.base import libutils
77
from rope.refactor.rename import Rename
88

9-
from pylsp import hookimpl, uris, utils
9+
from pylsp import hookimpl, uris, _utils
1010

1111
log = logging.getLogger(__name__)
1212

@@ -61,6 +61,6 @@ def _num_lines(resource):
6161
"Count the number of lines in a `File` resource."
6262
text = resource.read()
6363

64-
if utils.get_eol_chars(text):
64+
if _utils.get_eol_chars(text):
6565
return len(text.splitlines())
6666
return 0

pylsp/plugins/signature.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import logging
55
import re
6-
from pylsp import hookimpl, utils
6+
from pylsp import hookimpl, _utils
77

88
log = logging.getLogger(__name__)
99

@@ -16,7 +16,7 @@
1616

1717
@hookimpl
1818
def pylsp_signature_help(config, document, position):
19-
code_position = utils.position_to_jedi_linecolumn(document, position)
19+
code_position = _utils.position_to_jedi_linecolumn(document, position)
2020
signatures = document.jedi_script().get_signatures(**code_position)
2121

2222
if not signatures:
@@ -31,7 +31,7 @@ def pylsp_signature_help(config, document, position):
3131
supported_markup_kinds = signature_information_support.get(
3232
"documentationFormat", ["markdown"]
3333
)
34-
preferred_markup_kind = utils.choose_markup_kind(supported_markup_kinds)
34+
preferred_markup_kind = _utils.choose_markup_kind(supported_markup_kinds)
3535

3636
s = signatures[0]
3737

@@ -42,7 +42,7 @@ def pylsp_signature_help(config, document, position):
4242
function_sig = " ".join([line.strip() for line in function_sig_lines])
4343
sig = {
4444
"label": function_sig,
45-
"documentation": utils.format_docstring(
45+
"documentation": _utils.format_docstring(
4646
s.docstring(raw=True), markup_kind=preferred_markup_kind
4747
),
4848
}
@@ -52,7 +52,7 @@ def pylsp_signature_help(config, document, position):
5252
sig["parameters"] = [
5353
{
5454
"label": p.name,
55-
"documentation": utils.format_docstring(
55+
"documentation": _utils.format_docstring(
5656
_param_docs(docstring, p.name), markup_kind=preferred_markup_kind
5757
),
5858
}

pylsp/plugins/yapf_format.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import whatthepatch
1111

1212
from pylsp import hookimpl
13-
from pylsp.utils import get_eol_chars
13+
from pylsp._utils import get_eol_chars
1414

1515
log = logging.getLogger(__name__)
1616

pylsp/python_lsp.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from pylsp_jsonrpc.endpoint import Endpoint
1515
from pylsp_jsonrpc.streams import JsonRpcStreamReader, JsonRpcStreamWriter
1616

17-
from . import lsp, utils, uris
17+
from . import lsp, _utils, uris
1818
from .config import config
1919
from .workspace import Workspace, Document, Notebook, Cell
2020
from ._version import __version__
@@ -250,7 +250,7 @@ def m_exit(self, **_kwargs):
250250
self._jsonrpc_stream_writer.close()
251251

252252
def _match_uri_to_workspace(self, uri):
253-
workspace_uri = utils.match_uri_to_workspace(uri, self.workspaces)
253+
workspace_uri = _utils.match_uri_to_workspace(uri, self.workspaces)
254254
return self.workspaces.get(workspace_uri, self.workspace)
255255

256256
def _hook(self, hook_name, doc_uri=None, **kwargs):
@@ -360,7 +360,7 @@ def m_initialize(
360360

361361
def watch_parent_process(pid):
362362
# exit when the given pid is not alive
363-
if not utils.is_process_alive(pid):
363+
if not _utils.is_process_alive(pid):
364364
log.info("parent process %s is not alive, exiting!", pid)
365365
self.m_exit()
366366
else:
@@ -439,7 +439,7 @@ def highlight(self, doc_uri, position):
439439
def hover(self, doc_uri, position):
440440
return self._hook("pylsp_hover", doc_uri, position=position) or {"contents": ""}
441441

442-
@utils.debounce(LINT_DEBOUNCE_S, keyed_by="doc_uri")
442+
@_utils.debounce(LINT_DEBOUNCE_S, keyed_by="doc_uri")
443443
def lint(self, doc_uri, is_saved):
444444
# Since we're debounced, the document may no longer be open
445445
workspace = self._match_uri_to_workspace(doc_uri)

0 commit comments

Comments
 (0)