Skip to content

Commit 98ca1d9

Browse files
committed
feat: update plugin and server configuration management
1 parent 1dffb2f commit 98ca1d9

File tree

14 files changed

+419
-2109
lines changed

14 files changed

+419
-2109
lines changed

pylsp/_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import sys
1212
import threading
1313
import time
14+
from glob import glob
1415
from typing import Any, Iterable, List, Optional
1516

1617
import docstring_to_markdown
@@ -96,7 +97,9 @@ def find_parents(root, path, names):
9697
# Split the relative by directory, generate all the parent directories, then check each of them.
9798
# This avoids running a loop that has different base-cases for unix/windows
9899
# e.g. /a/b and /a/b/c/d/e.py -> ['/a/b', 'c', 'd']
99-
dirs = [root] + os.path.relpath(os.path.dirname(path), root).split(os.path.sep)
100+
if os.path.isfile(path):
101+
path = os.path.dirname(path)
102+
dirs = [root] + os.path.relpath(path, root).split(os.path.sep)
100103

101104
# Search each of /a/b/c, /a/b, /a
102105
while dirs:

pylsp/config/config.py

Lines changed: 0 additions & 203 deletions
This file was deleted.

pylsp/config/flake8_conf.py

Lines changed: 0 additions & 64 deletions
This file was deleted.

pylsp/config/plugin.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2017-2020 Palantir Technologies, Inc.
2+
# Copyright 2021- Python Language Server Contributors.
3+
4+
from __future__ import annotations
5+
6+
import logging
7+
from collections.abc import Mapping, Sequence
8+
9+
import pluggy
10+
from pluggy import HookImpl
11+
12+
log = logging.getLogger(__name__)
13+
14+
15+
class PluginManager(pluggy.PluginManager):
16+
def __init__(self, project_name: str):
17+
super().__init__(project_name)
18+
19+
def _hookexec(
20+
self,
21+
hook_name: str,
22+
methods: Sequence[HookImpl],
23+
kwargs: Mapping[str, object],
24+
firstresult: bool,
25+
):
26+
try:
27+
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
28+
except Exception as e:
29+
log.warning(f"Failed to load hook {hook_name}: {e}", exc_info=True)
30+
return []
31+

pylsp/config/pycodestyle_conf.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)