8000 Don't pass unicode to pyflakes (#372) · mirror-dump/python-lsp-server@f3b71b3 · GitHub
[go: up one dir, main page]

Skip to content

Commit f3b71b3

Browse files
muffinmadgatesn
authored andcommitted
Don't pass unicode to pyflakes (python-lsp#372)
* Don't pass unicode to pyflakes * unicode for py34 tests
1 parent 0009935 commit f3b71b3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pyls/plugins/pyflakes_lint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@hookimpl
2222
def pyls_lint(document):
2323
reporter = PyflakesDiagnosticReport(document.lines)
24-
pyflakes_api.check(document.source, document.path, reporter=reporter)
24+
pyflakes_api.check(document.source.encode('utf-8'), document.path, reporter=reporter)
2525
return reporter.diagnostics
2626

2727

test/plugins/test_pyflakes_lint.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ def hello():
1919
DOC_UNDEFINED_NAME_ERR = "a = b"
2020

2121

22+
DOC_ENCODING = u"""# encoding=utf-8
23+
import sys
24+
"""
25+
26+
2227
def test_pyflakes():
2328
doc = Document(DOC_URI, DOC)
2429
diags = pyflakes_lint.pyls_lint(doc)
@@ -47,3 +52,11 @@ def test_undefined_name_pyflakes():
4752
assert diag['message'] == 'undefined name \'b\''
4853
assert diag['range']['start'] == {'line': 0, 'character': 4}
4954
assert diag['severity'] == lsp.DiagnosticSeverity.Error
55+
56+
57+
def test_unicode_encoding():
58+
doc = Document(DOC_URI, DOC_ENCODING)
59+
diags = pyflakes_lint.pyls_lint(doc)
60+
61+
assert len(diags) == 1
62+
assert diags[0]['message'] == '\'sys\' imported but unused'

0 commit comments

Comments
 (0)
0