File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 1
1
# Copyright 2017 Palantir Technologies, Inc.
2
+ import contextlib
2
3
import logging
4
+ import sys
5
+
3
6
import pydocstyle
4
7
from pyls import hookimpl , lsp
5
8
@@ -19,8 +22,10 @@ def pyls_settings():
19
22
@hookimpl
20
23
def pyls_lint (document ):
21
24
conf = pydocstyle .config .ConfigurationParser ()
22
- conf .parse ()
23
- conf ._arguments = [document .path ]
25
+
26
+ with _patch_sys_argv ([document .path ]):
27
+ # TODO(gatesn): We can add more pydocstyle args here from our pyls config
28
+ conf .parse ()
24
29
25
30
# Will only yield a single filename, the document path
26
31
diags = []
@@ -65,3 +70,16 @@ def _parse_diagnostic(document, error):
65
70
}
66
71
}
67
72
}
73
+
74
+
75
+ @contextlib .contextmanager
76
+ def _patch_sys_argv (arguments ):
77
+ old_args = sys .argv
78
+
79
+ # Preserve argv[0] since it's the executable
80
+ sys .argv = old_args [0 :1 ] + arguments
81
+
82
+ try :
83
+ yield
84
+ finally :
85
+ sys .argv = old_args
Original file line number Diff line number Diff line change 38
38
'json-rpc' ,
39
39
'mccabe' ,
40
40
'pycodestyle' ,
41
- 'pydocstyle' ,
41
+ 'pydocstyle>=2.0.0 ' ,
42
42
'pyflakes' ,
43
43
'rope>=0.10.5' ,
44
44
'yapf' ,
You can’t perform that action at this time.
0 commit comments