Repository: spyder-ide/spyder

Issue:
Error when enabling `Underline errors and warnings` linting option
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

I just edited the linting settings and clicked apply.

### Traceback
```python-traceback
Traceback (most recent call last):
  File "C:\Program Files\Spyder\pkgs\spyder\plugins\editor\plugin.py", line 419, in _rpc_call
    meth(*args, **kwargs)
  File "C:\Program Files\Spyder\pkgs\spyder\plugins\editor\plugin.py", line 1307, in update_source_menu
    state = self.get_option(opt, section=section)
  File "C:\Program Files\Spyder\pkgs\spyder\api\plugins\old_api.py", line 111, in get_option
    return super(BasePlugin, self)._get_option(option, default,
  File "C:\Program Files\Spyder\pkgs\spyder\plugins\base.py", line 71, in _get_option
    return CONF.get(section, option, default)
  File "C:\Program Files\Spyder\pkgs\spyder\config\manager.py", line 460, in get
    raise cp.NoOptionError(option, section)
configparser.NoOptionError: No option ('editor', 'underline_errors') in section: 'editor'
```

## Versions

* Spyder version: 5.3.0 
* Python version: 3.8.10
* Qt version: 5.15.2
* PyQt5 version: 5.15.6
* Operating System: Windows 10

### Dependencies

```
# Mandatory:
atomicwrites >=1.2.0                 :  1.4.0 (OK)
chardet >=2.0.0                      :  4.0.0 (OK)
cloudpickle >=0.5.0                  :  2.0.0 (OK)
cookiecutter >=1.6.0                 :  1.7.3 (OK)
diff_match_patch >=20181111          :  20200713 (OK)
intervaltree                         :  None (OK)
IPython >=7.31.1;<8.0.0              :  7.32.0 (OK)
jedi >=0.17.2;<0.19.0                :  0.18.1 (OK)
jellyfish >=0.7                      :  0.9.0 (OK)
jsonschema >=3.2.0                   :  4.4.0 (OK)
keyring >=17.0.0                     :  23.5.0 (OK)
nbconvert >=4.0                      :  6.4.5 (OK)
numpydoc >=0.6.0                     :  1.2.1 (OK)
paramiko >=2.4.0                     :  2.10.3 (OK)
parso >=0.7.0;<0.9.0                 :  0.8.3 (OK)
pexpect >=4.4.0                      :  4.8.0 (OK)
pickleshare >=0.4                    :  0.7.5 (OK)
psutil >=5.3                         :  5.9.0 (OK)
pygments >=2.0                       :  2.11.2 (OK)
pylint >=2.5.0                       :  2.13.3 (OK)
pyls_spyder >=0.4.0                  :  0.4.0 (OK)
pylsp >=1.4.1;<1.5.0                 :  1.4.1 (OK)
pylsp_black >=1.2.0                  :  1.2.0 (OK)
qdarkstyle >=3.0.2;<3.1.0            :  3.0.3 (OK)
qstylizer >=0.1.10                   :  0.2.1 (OK)
qtawesome >=1.0.2                    :  1.1.1 (OK)
qtconsole >=5.3.0;<5.4.0             :  5.3.0 (OK)
qtpy >=2.0.1                         :  2.0.1 (OK)
rtree >=0.9.7                        :  0.9.7 (OK)
setuptools >=49.6.0                  :  61.2.0 (OK)
sphinx >=0.6.6                       :  4.5.0 (OK)
spyder_kernels >=2.3.0;<2.4.0        :  2.3.0 (OK)
textdistance >=4.2.0                 :  4.2.2 (OK)
three_merge >=0.1.1                  :  0.1.1 (OK)
watchdog                             :  2.1.7 (OK)
zmq >=17                             :  22.3.0 (OK)

# Optional:
cython >=0.21                        :  0.29.28 (OK)
matplotlib >=3.0.0                   :  3.5.1 (OK)
numpy >=1.7                          :  1.22.3 (OK)
pandas >=1.1.1                       :  1.4.1 (OK)
scipy >=0.17.0                       :  1.8.0 (OK)
sympy >=0.7.3                        :  1.10.1 (OK)

# Spyder plugins:
spyder_terminal.terminalplugin 1.2.2 :  1.2.2 (OK)
```



Discussion:
Hi @freiburgermsu,

Which particular settings did you changed? Let me know so I can try to reproduce it in my end.

Thanks for reporting!
Hello @steff456 ,

I applied changes to selecting the "underline errors and warnings" linting option. The error arose when I clicked "apply" in the preferences. I think that the change was actually applied, so I do not know what was erroneous.
Hi @freiburgermsu,

I could reproduce this issue in my end, we will work in a fix for this to be part of our next release. 
Thanks @steff456 for the confirmation. I will take care of this.

Resolving patch:
diff --git a/spyder/plugins/editor/plugin.py b/spyder/plugins/editor/plugin.py
--- a/spyder/plugins/editor/plugin.py
+++ b/spyder/plugins/editor/plugin.py
@@ -1299,11 +1299,13 @@ def update_source_menu(self, options, **kwargs):
         named_options = dict(zip(option_names, options))
         for name, action in self.checkable_actions.items():
             if name in named_options:
-                section = 'completions'
                 if name == 'underline_errors':
                     section = 'editor'
+                    opt = 'underline_errors'
+                else:
+                    section = 'completions'
+                    opt = named_options[name]
 
-                opt = named_options[name]
                 state = self.get_option(opt, section=section)
 
                 # Avoid triggering the action when this action changes state


Test patch: