Skip to content

Commit 62de1c0

Browse files
authored
Merge pull request #2 from palantir/develop
Sync Fork from Upstream Repo
2 parents edba906 + 048a4fe commit 62de1c0

38 files changed

+1239
-131
lines changed

.DS_Store

-10 KB
Binary file not shown.

.circleci/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717
- image: "python:3.5-stretch"
1818
steps:
1919
- checkout
20+
# To test Jedi environments
21+
- run: python3 -m venv /tmp/pyenv
22+
- run: /tmp/pyenv/bin/python -m pip install loghub
2023
- run: pip install -e .[all] .[test]
2124
- run: py.test -v test/
2225

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,6 @@ ENV/
109109

110110
# Merge orig files
111111
*.orig
112+
113+
# Special files
114+
.DS_Store

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Development
112112

113113
To run the test suite:
114114

115-
``pip install .[test] && tox``
115+
``pip install .[test] && pytest``
116116

117117
Develop against VS Code
118118
=======================

RELEASE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
To release a new version of the PyLS you need to follow these steps:
2+
3+
* Close the current milestone on Github
4+
5+
* git pull or git fetch/merge
6+
7+
* git tag -a X.X.X -m 'Release X.X.X'
8+
9+
* git push upstream --tags
10+
11+
* Publish release in our Github Releases page

appveyor.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
environment:
2+
global:
3+
APPVEYOR_RDP_PASSWORD: "dcca4c4863E30d56c2e0dda6327370b3#"
24
matrix:
35
- PYTHON: "C:\\Python27"
46
PYTHON_VERSION: "2.7.15"
@@ -19,7 +21,10 @@ install:
1921
- "%PYTHON%/python.exe -m pip install .[all] .[test]"
2022

2123
test_script:
22-
- "%PYTHON%/Scripts/pytest.exe test/"
24+
- "%PYTHON%/Scripts/pytest.exe -v test/"
25+
26+
# on_finish:
27+
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
2328

2429
build: false # Not a C# project
2530

pyls/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# Copyright 2017 Palantir Technologies, Inc.
22
import os
3-
from future.standard_library import install_aliases
3+
import sys
44
import pluggy
55
from ._version import get_versions
66

7-
install_aliases()
7+
if sys.version_info[0] < 3:
8+
from future.standard_library import install_aliases
9+
install_aliases()
10+
811
__version__ = get_versions()['version']
912
del get_versions
1013

pyls/__main__.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# Copyright 2017 Palantir Technologies, Inc.
22
import argparse
3-
import json
43
import logging
54
import logging.config
65
import sys
7-
from .python_ls import start_io_lang_server, start_tcp_lang_server, PythonLanguageServer
6+
7+
try:
8+
import ujson as json
9+
except Exception: # pylint: disable=broad-except
10+
import json
11+
12+
from .python_ls import (PythonLanguageServer, start_io_lang_server,
13+
start_tcp_lang_server)
814

915
LOG_FORMAT = "%(asctime)s UTC - %(levelname)s - %(name)s - %(message)s"
1016

@@ -55,10 +61,12 @@ def main():
5561
_configure_logger(args.verbose, args.log_config, args.log_file)
5662

5763
if args.tcp:
58-
start_tcp_lang_server(args.host, args.port, PythonLanguageServer)
64+
start_tcp_lang_server(args.host, args.port, args.check_parent_process,
65+
PythonLanguageServer)
5966
else:
6067
stdin, stdout = _binary_stdio()
61-
start_io_lang_server(stdin, stdout, args.check_parent_process, PythonLanguageServer)
68+
start_io_lang_server(stdin, stdout, args.check_parent_process,
69+
PythonLanguageServer)
6270

6371

6472
def _binary_stdio():

pyls/_utils.py

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
# Copyright 2017 Palantir Technologies, Inc.
2+
from distutils.version import LooseVersion
23
import functools
34
import inspect
45
import logging
56
import os
67
import sys
78
import threading
89

10+
import jedi
11+
912
PY2 = sys.version_info.major == 2
13+
JEDI_VERSION = jedi.__version__
1014

1115
if PY2:
1216
import pathlib2 as pathlib
@@ -136,7 +140,8 @@ def format_docstring(contents):
136140
"""
137141
contents = contents.replace('\t', u'\u00A0' * 4)
138142
contents = contents.replace(' ', u'\u00A0' * 2)
139-
contents = contents.replace('*', '\\*')
143+
if LooseVersion(JEDI_VERSION) < LooseVersion('0.15.0'):
144+
contents = contents.replace('*', '\\*')
140145
return contents
141146

142147

@@ -147,19 +152,49 @@ def clip_column(column, lines, line_number):
147152
return min(column, max_column)
148153

149154

150-
def is_process_alive(pid):
151-
""" Check whether the process with the given pid is still alive.
155+
if os.name == 'nt':
156+
import ctypes
152157

153-
Args:
154-
pid (int): process ID
158+
kernel32 = ctypes.windll.kernel32
159+
PROCESS_QUERY_INFROMATION = 0x1000
155160

156-
Returns:
157-
bool: False if the process is not alive or don't have permission to check, True otherwise.
158-
"""
159-
try:
160-
os.kill(pid, 0)
161-
except OSError:
162-
# no such process or process is already dead
161+
def is_process_alive(pid):
162+
"""Check whether the process with the given pid is still alive.
163+
164+
Running `os.kill()` on Windows always exits the process, so it can't be used to check for an alive process.
165+
see: https://docs.python.org/3/library/os.html?highlight=os%20kill#os.kill
166+
167+
Hence ctypes is used to check for the process directly via windows API avoiding any other 3rd-party dependency.
168+
169+
Args:
170+
pid (int): process ID
171+
172+
Returns:
173+
bool: False if the process is not alive or don't have permission to check, True otherwise.
174+
"""
175+
process = kernel32.OpenProcess(PROCESS_QUERY_INFROMATION, 0, pid)
176+
if process != 0:
177+
kernel32.CloseHandle(process)
178+
return True
163179
return False
164-
else:
165-
return True
180+
181+
else:
182+
import errno
183+
184+
def is_process_alive(pid):
185+
"""Check whether the process with the given pid is still alive.
186+
187+
Args:
188+
pid (int): process ID
189+
190+
Returns:
191+
bool: False if the process is not alive or don't have permission to check, True otherwise.
192+
"""
193+
if pid < 0:
194+
return False
195+
try:
196+
os.kill(pid, 0)
197+
except OSError as e:
198+
return e.errno == errno.EPERM
199+
else:
200+
return True

pyls/config/flake8_conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
('ignore', 'plugins.pycodestyle.ignore', list),
2020
('max-line-length', 'plugins.pycodestyle.maxLineLength', int),
2121
('select', 'plugins.pycodestyle.select', list),
22+
# flake8
23+
('exclude', 'plugins.flake8.exclude', list),
24+
('filename', 'plugins.flake8.filename', list),
25+
('hang-closing', 'plugins.flake8.hangClosing', bool),
26+
('ignore', 'plugins.flake8.ignore', list),
27+
('max-line-length', 'plugins.flake8.maxLineLength', int),
28+
('select', 'plugins.flake8.select', list),
2229
]
2330

2431

0 commit comments

Comments
 (0)