Repository: spyder-ide/spyder

Issue:
Toggling docstring style linting in preferences doesn't work in macOS
## Problem Description
Unchecking "enable docstring style linting" in settings doesn't seem to have any effect

### What steps reproduce the problem?

1. Open spyder with docstring style linting enabled
2. Uncheck enable docstring style linting radio box
3. Click Apply and/or OK

### What is the expected output? What do you see instead?

I expect the warning icons for docstrings to disappear. Instead they remain and opening the preference again shows the radio box still clicked. Can disable by closing spyder and manually changing `pydocstyle = True` to `False` in spyder.ini file.

## Versions

* Spyder version: 4.0.0b2
* Python version: 3.7.0 64-bit
* Qt version: 5.9.6
* PyQt version: 5.9.2
* Operating System name/version: Darwin 18.6.0

### Dependencies

```
pygments >=2.0     :  2.4.0 (OK)
qdarkstyle >=2.6.4 :  2.6.8 (OK)
sphinx >=0.6.6     :  2.0.1 (OK)
psutil >=0.3       :  5.6.2 (OK)
pyls >=0.19.0;<0.25:  0.24.0 (OK)
nbconvert >=4.0    :  5.5.0 (OK)
pandas >=0.13.1    :  0.24.2 (OK)
numpy >=1.7        :  1.16.4 (OK)
sympy >=0.7.3      :  1.4 (OK)
cython >=0.21      :  0.29.8 (OK)
qtconsole >=4.2.0  :  4.5.1 (OK)
IPython >=4.0      :  7.5.0 (OK)
matplotlib >=2.0.0 :  3.1.0 (OK)
pylint >=0.25      :  2.3.1 (OK)
```


Discussion:
It doesn't work immediately, but it does after a little while (2 or 3 secs). Could you confirm?
Nope, behaviour is completely consistent. Checking or unchecking the radio box in the docstring style tab of completion and linting settings does nothing. Behaviour doesn't change, and spyder.ini doesn't change.

Selecting "Show docstring style warnings" in the source menu toggles the behaviour and changes spyder.ini. As I said before, manually changing spyder.ini and restarting also works.

If I toggle the behaviour using the file or the menu, the state of the radio box in settings will change, but clicking the box in settings won't change anything.
Sorry I should be saying "preferences" window, not settings. but I think you know what I mean.
Do you have an external configuration file for `pydocstyle`?
nope. I've never used it till I turned it on in beta 2
Ok, thanks a lot for your patience. Final question: does this happen on Linux too or only on macOS?
I will test when I get back into the office next week.
Great, thanks!
Works fine on my Linux machine.
I'm testing using this command to check settings:
```
grep pydocstyle ~/.config/spyder-py3-dev/spyder.ini
```
On Linux, the initial output is 
```
pydocstyle = False
pydocstyle/convention = numpy
pydocstyle/select = 
pydocstyle/ignore = 
pydocstyle/match = (?!test_).*\.py
pydocstyle/match_dir = [^\.].*
```
If I open the preferences window, click the radio box and hit apply, I now get
```
pydocstyle = True
pydocstyle/convention = numpy
pydocstyle/select = 
pydocstyle/ignore = 
pydocstyle/match = (?!test_).*\.py
pydocstyle/match_dir = [^\.].*
```
Uncheck and hit apply and it goes back to False.

On my mac, The `pydocstyle = True/False` value would change if I chose "show docstring style warnings" from the source menu, but not when clicking the box in preferences. So it's not a permissions error in the config file or anything like that.

I do note that on Linux, the spyder.ini is found at `~/.config/spyder-py3-dev/spyder.ini` while on mac it's at `~/.spyder-py3-dev/spyder.ini` so there is at least some difference in the handling of preferences between the versions.

 
Ok, thanks for the confirmation. I was asking about it because on Linux things are working fine for me.

@juanis2112, are you able to reproduce this problem on macOS?
I've managed to reproduce on two different macs now.
@ccordoba12 yes, I reproduced the problem in macOS.
Want to give it a go at fixing it @juanis2112 ?
I have no idea what could be causing this problem, but @steff456 has more experience with the PyLS and she also works in macOS.
@steff456, please notice that Docstring linting is working from the Source menu. It's only when it's activated in Preferences that it fails.

Resolving patch:
diff --git a/spyder/preferences/configdialog.py b/spyder/preferences/configdialog.py
--- a/spyder/preferences/configdialog.py
+++ b/spyder/preferences/configdialog.py
@@ -310,12 +310,8 @@ def load_from_conf(self):
         for checkbox, (option, default) in list(self.checkboxes.items()):
             checkbox.setChecked(self.get_option(option, default))
             # QAbstractButton works differently for PySide and PyQt
-            if not API == 'pyside':
-                checkbox.clicked.connect(lambda _foo, opt=option:
-                                         self.has_been_modified(opt))
-            else:
-                checkbox.clicked.connect(lambda opt=option:
-                                         self.has_been_modified(opt))
+            checkbox.clicked.connect(lambda opt=option:
+                                     self.has_been_modified(opt))
         for radiobutton, (option, default) in list(self.radiobuttons.items()):
             radiobutton.setChecked(self.get_option(option, default))
             radiobutton.toggled.connect(lambda _foo, opt=option:
diff --git a/spyder/preferences/languageserver.py b/spyder/preferences/languageserver.py
--- a/spyder/preferences/languageserver.py
+++ b/spyder/preferences/languageserver.py
@@ -33,7 +33,6 @@
 from spyder.utils.programs import find_program
 from spyder.widgets.helperwidgets import ItemDelegate
 
-
 LSP_LANGUAGE_NAME = {x.lower(): x for x in LSP_LANGUAGES}
 LSP_URL = "https://microsoft.github.io/language-server-protocol"
 


Test patch: