Repository: spyder-ide/spyder

Issue:
Cannot save if remove_trailing_spaces is enabled
<!--- **PLEASE READ:** When submitting here, please ensure you've completed the following checklist and checked the boxes to confirm. Issue reports without it may be closed. Thanks! --->

### Issue Report Checklist

* [x] Searched the [issues page](https://github.com/spyder-ide/spyder/issues?q=is%3Aissue) for similar reports
* [x] Read the relevant sections of the [Spyder Troubleshooting Guide](https://github.com/spyder-ide/spyder/wiki/Troubleshooting-Guide-and-FAQ) and followed its advice
* [ ] Reproduced the issue after updating with ``conda update spyder`` (or ``pip``, if not using Anaconda)
* [ ] Could not reproduce inside ``jupyter qtconsole`` (if console-related)
* [ ] Tried basic troubleshooting (if a bug/error)
    * [x] Restarted Spyder
    * [ ] Reset preferences with ``spyder --reset``
    * [ ] Reinstalled the latest version of [Anaconda](https://www.anaconda.com/download/)
    * [ ] Tried the other applicable steps from the Troubleshooting Guide
* [x] Completed the **Problem Description**, **Steps to Reproduce** and **Version** sections below


## Problem Description

After PR #13295, if "Automatically remove trailing spaces when saving files" is enabled, an exception is raised and the file is never saved.

This happens because `remove_trailing_spaces` is defined [here](https://github.com/spyder-ide/spyder/blob/master/spyder/plugins/editor/widgets/codeeditor.py#L2072) as a method and [here](https://github.com/spyder-ide/spyder/blob/master/spyder/plugins/editor/widgets/base.py#L58) as an attribute assigned in `__init__`, there the method defined in CodeEditor is replaced by False. 

### What steps reproduce the problem?

1. Enable "Automatically remove trailing spaces when saving files" in Editor preferences
2. Open a file in the editor
3. Save it

### Paste Traceback/Error Below (if applicable)
<!--- Copy from error dialog or View > Panes > Internal Console --->

```python-traceback

Traceback (most recent call last):
  File "/home/Public/spyder/spyder/plugins/editor/widgets/editor.py", line 2075, in save
    self.remove_trailing_spaces(index)
  File "/home/Public/spyder/spyder/plugins/editor/widgets/editor.py", line 2880, in remove_trailing_spaces
    finfo.editor.remove_trailing_spaces()
TypeError: 'bool' object is not callable


```

## Versions
<!--- You can get this information from Help > About Spyder...
or (if Spyder won't launch) the "conda list" command
from the Anaconda Prompt/Terminal/command line. --->

* Spyder version: 4.2.0dev0 1c3583e
* Python version: 3.6.9



Discussion:
I can confirm behavior with bootstrap on Python 3.7.9 (#14009 )
@andfoy , as @trollodel astutely observed, `remove_trailing_spaces` is defined as a method in `CodeEditor` and an attribute initially set to false in the superclass `TextEditBaseWidget`. It was likely not an issue until your recent edit because the attribute was spelled differently (`remove_trailling_spaces`) in `TextEditBaseWidget`.

Resolving patch:
diff --git a/spyder/plugins/editor/widgets/codeeditor.py b/spyder/plugins/editor/widgets/codeeditor.py
--- a/spyder/plugins/editor/widgets/codeeditor.py
+++ b/spyder/plugins/editor/widgets/codeeditor.py
@@ -2055,7 +2055,7 @@ def rehighlight(self):
         else:
             self.unhighlight_current_line()
 
-    def remove_trailing_spaces(self):
+    def trim_trailing_spaces(self):
         """Remove trailing spaces"""
         cursor = self.textCursor()
         cursor.beginEditBlock()
diff --git a/spyder/plugins/editor/widgets/editor.py b/spyder/plugins/editor/widgets/editor.py
--- a/spyder/plugins/editor/widgets/editor.py
+++ b/spyder/plugins/editor/widgets/editor.py
@@ -2837,7 +2837,7 @@ def remove_trailing_spaces(self, index=None):
         if index is None:
             index = self.get_stack_index()
         finfo = self.data[index]
-        finfo.editor.remove_trailing_spaces()
+        finfo.editor.trim_trailing_spaces()
 
     def trim_trailing_newlines(self, index=None):
         if index is None:


Test patch: