Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

python-language-server

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

python-language-server - pypi Package Compare versions

Comparing version
0.34.0
to
0.34.1
+1
-1
PKG-INFO
Metadata-Version: 2.1
Name: python-language-server
Version: 0.34.0
Version: 0.34.1
Summary: Python Language Server for the Language Server Protocol

@@ -5,0 +5,0 @@ Home-page: https://github.com/palantir/python-language-server

@@ -11,7 +11,7 @@

{
"date": "2020-06-30T17:30:36-0500",
"date": "2020-07-02T11:29:43-0500",
"dirty": false,
"error": null,
"full-revisionid": "5fa7ae9154c79ba1f5347e1452bd770a958869b3",
"version": "0.34.0"
"full-revisionid": "78dee3d03fd6027804588fd204df06b2ac57d7d3",
"version": "0.34.1"
}

@@ -18,0 +18,0 @@ ''' # END VERSION_JSON

# Copyright 2018 Palantir Technologies, Inc.
import logging
from autopep8 import fix_code
import pycodestyle
from autopep8 import fix_code, continued_indentation as autopep8_c_i
from pyls import hookimpl

@@ -34,4 +35,12 @@

# Temporarily re-monkey-patch the continued_indentation checker - #771
del pycodestyle._checks['logical_line'][pycodestyle.continued_indentation]
pycodestyle.register_check(autopep8_c_i)
new_source = fix_code(document.source, options=options)
# Switch it back
del pycodestyle._checks['logical_line'][autopep8_c_i]
pycodestyle.register_check(pycodestyle.continued_indentation)
if new_source == document.source:

@@ -38,0 +47,0 @@ return []

@@ -46,8 +46,8 @@ # Copyright 2019 Palantir Technologies, Inc.

args = build_args(opts, document.path)
output = run_flake8(flake8_executable, args)
args = build_args(opts)
output = run_flake8(flake8_executable, args, document)
return parse_stdout(document, output)
def run_flake8(flake8_executable, args):
def run_flake8(flake8_executable, args, document):
"""Run flake8 with the provided arguments, logs errors

@@ -64,3 +64,3 @@ from stderr if any.

cmd.extend(args)
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
except IOError:

@@ -70,4 +70,4 @@ log.debug("Can't execute %s. Trying with 'python -m flake8'", flake8_executable)

cmd.extend(args)
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
(stdout, stderr) = p.communicate()
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
(stdout, stderr) = p.communicate(document.source.encode())
if stderr:

@@ -78,3 +78,3 @@ log.error("Error while running flake8 '%s'", stderr.decode())

def build_args(options, doc_path):
def build_args(options):
"""Build arguments for calling flake8.

@@ -84,5 +84,4 @@

options: dictionary of argument names and their values.
doc_path: path of the document to lint.
"""
args = [doc_path]
args = ['-'] # use stdin
for arg_name, arg_val in options.items():

@@ -89,0 +88,0 @@ if arg_val is None:

Metadata-Version: 2.1
Name: python-language-server
Version: 0.34.0
Version: 0.34.1
Summary: Python Language Server for the Language Server Protocol

@@ -5,0 +5,0 @@ Home-page: https://github.com/palantir/python-language-server

@@ -18,3 +18,22 @@ # Copyright 2017 Palantir Technologies, Inc.

INDENTED_DOC = """def foo():
print('asdf',
file=None
)
bar = { 'foo': foo
}
"""
CORRECT_INDENTED_DOC = """def foo():
print('asdf',
file=None
)
bar = {'foo': foo
}
"""
def test_format(config, workspace):

@@ -46,1 +65,9 @@ doc = Document(DOC_URI, workspace, DOC)

assert not pyls_format_document(config, doc)
def test_hanging_indentation(config, workspace):
doc = Document(DOC_URI, workspace, INDENTED_DOC)
res = pyls_format_document(config, doc)
assert len(res) == 1
assert res[0]['newText'] == CORRECT_INDENTED_DOC

@@ -31,11 +31,15 @@ # Copyright 2019 Palantir Technologies, Inc.

def test_flake8_no_checked_file(workspace):
# A bad uri or a non-saved file may cause the flake8 linter to do nothing.
# In this situtation, the linter will return an empty list.
def test_flake8_unsaved(workspace):
doc = Document('', workspace, DOC)
diags = flake8_lint.pyls_lint(workspace, doc)
assert 'Error' in diags[0]['message']
msg = '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'
assert unused_var['code'] == 'F841'
assert unused_var['range']['start'] == {'line': 5, 'character': 1}
assert unused_var['range']['end'] == {'line': 5, 'character': 11}
assert unused_var['severity'] == lsp.DiagnosticSeverity.Warning
def test_flake8_lint(workspace):

@@ -42,0 +46,0 @@ try: