Repository: palantir/python-language-server

Issue:
pycodestyle config not being read, seeing runtime errors since 0.12.0
Since upgrading to 0.12.1 (from 0.11.1) I noticed that I was getting D100 and D103 docstring warnings in my code, even though I ignored them via `$HOME/.config/pycodestyle`.  I tried adding a `setup.cfg` to the project directory but I still got the warnings.

When running `pyls` (as `pyls --tcp --port 9001 -v`) in TCP mode I saw the following output after loading a Python file. Could the issue I'm seeing be related to the pydocstyle error? 


```
[...]
2017-12-25 11:09:59,221 UTC - INFO - pyls.config.config - Loaded pyls plugin pycodestyle from <module 'pyls.plugins.pycodestyle_lint' from '/home/terr/.local/lib/python3.5/site-packages/pyls/plugins/pycodestyle_lint.py'>
[...]
2017-12-25 11:04:15,188 UTC - INFO - pyls.config.config - Loaded pyls plugin mccabe from <module 'pyls.plugins.mccabe_lint' from '/home/terr/.local/lib/python3.5/site-packages/pyls/plugins/mccabe_lint.py'>
2017-12-25 11:04:15,188 UTC - INFO - pyls.config.config - Loaded pyls plugin jedi_signature_help from <module 'pyls.plugins.signature' from '/home/terr/.local/lib/python3.5/site-packages/pyls/plugins/signature.py'>
Usage: pydocstyle [options] [<file|dir>...]
pyls: error: no such option: --tcp
```

I'm assuming the "no such option: --tcp" error doesn't occur in IO mode. I've got the most recent version of `pydocstyle` installed, 2.1.1. 

I also tried 0.12.0, where I got the same output and results (warnings about D100/D103). Version 0.11.1 still works fine, both in IO and TCP mode.

Discussion:
gatesn: @lgeiger hopefully last iteration on this stuff!
lgeiger: Thanks for taking a look and maintaining this language server!

Unfortunately it looks like this doesn't fully fix the problem. I rebased #211 onto this branch and  the bug is still partially present. I hope I'm missing something obvious here 😄 
gatesn: Will merge this as it seems to resolve #210, then will look again at your rebased branch. Thanks for testing.

Patch:
diff --git a/pyls/language_server.py b/pyls/language_server.py
index b898ae1..f310182 100644
--- a/pyls/language_server.py
+++ b/pyls/language_server.py
@@ -65,7 +65,7 @@ class LanguageServer(dispatcher.JSONRPCMethodDispatcher, JSONRPCServer):
         pass
 
     def m_initialize(self, **kwargs):
-        log.debug("Language server intialized with %s", kwargs)
+        log.debug("Language server initialized with %s", kwargs)
         if 'rootUri' in kwargs:
             self.root_uri = kwargs['rootUri']
         elif 'rootPath' in kwargs:
diff --git a/pyls/plugins/pycodestyle_lint.py b/pyls/plugins/pycodestyle_lint.py
index d157a38..2940166 100644
--- a/pyls/plugins/pycodestyle_lint.py
+++ b/pyls/plugins/pycodestyle_lint.py
@@ -12,12 +12,12 @@ def pyls_lint(config, document):
     log.debug("Got pycodestyle settings: %s", settings)
 
     opts = {
-        'exclude': settings.get('exclude'),
-        'filename': settings.get('filename'),
+        'exclude': ','.join(settings.get('exclude') or []),
+        'filename': ','.join(settings.get('filename') or []),
         'hang_closing': settings.get('hangClosing'),
-        'ignore': settings.get('ignore'),
+        'ignore': ','.join(settings.get('ignore') or []),
         'max_line_length': settings.get('maxLineLength'),
-        'select': settings.get('select'),
+        'select': ','.join(settings.get('select') or []),
     }
 
     styleguide = pycodestyle.StyleGuide({k: v for k, v in opts.items() if v is not None})
@@ -27,6 +27,7 @@ def pyls_lint(config, document):
     )
     c.check_all()
     diagnostics = c.report.diagnostics
+
     return diagnostics
 
 


Test patch:
diff --git a/test/plugins/test_pycodestyle_lint.py b/test/plugins/test_pycodestyle_lint.py
index a93b513..028997f 100644
--- a/test/plugins/test_pycodestyle_lint.py
+++ b/test/plugins/test_pycodestyle_lint.py
@@ -86,4 +86,9 @@ def test_pycodestyle_config(workspace):
     # And make sure we only get one warning
     diags = pycodestyle_lint.pyls_lint(config, doc)
     assert not [d for d in diags if d['code'] == 'W191']
-    assert [d for d in diags if d['code'] == 'W391']
+
+    # Ignore both warnings
+    config.update({'plugins': {'pycodestyle': {'ignore': ['W191', 'W391']}}})
+    # And make sure we get neither
+    assert not [d for d in diags if d['code'] == 'W191']
+    assert not [d for d in diags if d['code'] == 'W391']