Repository: spyder-ide/spyder

Issue:
Setting ignore rules for Pycodestyle is not working
While working on PR #9186 I noticed that when you set something to ignore in the "Code style" tab of "Completion and linting", that's not getting send to server.

@dalthviz, I think the problem is here

https://github.com/spyder-ide/spyder/blob/5a39ace4a24d95b0b4ecaf0fada0317988d37dc3/spyder/plugins/editor/lsp/manager.py#L245

because:

1. In case 'pycodestyle/select' is an empty string, then this code generates `['']` to pass to the server and it should be `[]` (i.e. an empty list, not a list with an empty string).
2. I think Pycodestyle doesn't accept that both `select` and `ignore` are passed at the same time (but please verify that).

Also, please remove the `xfail` of this test after fixing this issue:

https://github.com/spyder-ide/spyder/blob/d3ca22ab0fbe99ed4d64efcb3ee78b13e893452e/spyder/plugins/editor/widgets/tests/test_warnings.py#L27-L32


Discussion:

Resolving patch:
diff --git a/spyder/plugins/editor/lsp/manager.py b/spyder/plugins/editor/lsp/manager.py
--- a/spyder/plugins/editor/lsp/manager.py
+++ b/spyder/plugins/editor/lsp/manager.py
@@ -248,10 +248,11 @@ def generate_python_config(self):
 
         pycodestyle = {
             'enabled': self.get_option('pycodestyle'),
-            'exclude': [exclude.strip() for exclude in cs_exclude],
-            'filename': [filename.strip() for filename in cs_filename],
-            'select': [select.strip() for select in cs_select],
-            'ignore': [ignore.strip() for ignore in cs_ignore],
+            'exclude': [exclude.strip() for exclude in cs_exclude if exclude],
+            'filename': [filename.strip()
+                         for filename in cs_filename if filename],
+            'select': [select.strip() for select in cs_select if select],
+            'ignore': [ignore.strip() for ignore in cs_ignore if ignore],
             'hangClosing': False,
             'maxLineLength': cs_max_line_length
         }
@@ -278,10 +279,12 @@ def generate_python_config(self):
         pydocstyle = {
             'enabled': self.get_option('pydocstyle'),
             'convention': convention,
-            'addIgnore': [ignore.strip() for ignore in ds_add_ignore],
-            'addSelect': [select.strip() for select in ds_add_select],
-            'ignore': [ignore.strip() for ignore in ds_ignore],
-            'select': [select.strip() for select in ds_select],
+            'addIgnore': [ignore.strip()
+                          for ignore in ds_add_ignore if ignore],
+            'addSelect': [select.strip()
+                          for select in ds_add_select if select],
+            'ignore': [ignore.strip() for ignore in ds_ignore if ignore],
+            'select': [select.strip() for select in ds_select if select],
             'match': self.get_option('pydocstyle/match'),
             'matchDir': self.get_option('pydocstyle/match_dir')
         }


Test patch:
diff --git a/spyder/plugins/editor/widgets/tests/test_warnings.py b/spyder/plugins/editor/widgets/tests/test_warnings.py
--- a/spyder/plugins/editor/widgets/tests/test_warnings.py
+++ b/spyder/plugins/editor/widgets/tests/test_warnings.py
@@ -26,7 +26,6 @@
 
 @pytest.mark.slow
 @pytest.mark.second
-@pytest.mark.xfail
 def test_ignore_warnings(qtbot, lsp_codeeditor):
     """Test that the editor is ignoring some warnings."""
     editor, manager = lsp_codeeditor