Repository: spyder-ide/spyder

Issue:
TypeError after clicking "Find in files" action
## Description

### What steps will reproduce the problem?

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

Tried to open "Find in files". The textbox to search in files was already filled with the last line of code I ran in the console for some reason.

### Traceback
```python-traceback
Traceback (most recent call last):
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/spyder/plugins/findinfiles/widgets/search_thread.py", line 101, in run
  File "/Applications/Spyder.app/Contents/Resources/lib/python3.9/spyder/plugins/findinfiles/widgets/search_thread.py", line 119, in find_files_in_path
  File "os.pyc", line 342, in walk
TypeError: expected str, bytes or os.PathLike object, not NoneType
```

## Versions

* Spyder version: 5.5.0 b4c4e1a16 (standalone)
* Python version: 3.9.14 64-bit
* Qt version: 5.15.11
* PyQt5 version: 5.15.10
* Operating System: macOS-13.5.2-x86_64-i386-64bit

### Dependencies

```
# Mandatory:
atomicwrites >=1.2.0             :  1.4.1 (OK)
chardet >=2.0.0                  :  5.2.0 (OK)
cloudpickle >=0.5.0              :  3.0.0 (OK)
cookiecutter >=1.6.0             :  2.4.0 (OK)
diff_match_patch >=20181111      :  20230430 (OK)
intervaltree >=3.0.2             :  3.1.0 (OK)
IPython >=8.13.0,<9.0.0,!=8.17.1 :  8.17.2 (OK)
jedi >=0.17.2,<0.20.0            :  0.19.1 (OK)
jellyfish >=0.7                  :  1.0.1 (OK)
jsonschema >=3.2.0               :  4.19.2 (OK)
keyring >=17.0.0                 :  24.2.0 (OK)
nbconvert >=4.0                  :  7.11.0 (OK)
numpydoc >=0.6.0                 :  1.6.0 (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.6 (OK)
pygments >=2.0                   :  2.16.1 (OK)
pylint >=2.5.0,<3.1              :  3.0.2 (OK)
pylint_venv >=3.0.2              :  None (OK)
pyls_spyder >=0.4.0              :  0.4.0 (OK)
pylsp >=1.9.0,<1.10.0            :  1.9.0 (OK)
pylsp_black >=1.2.0,<3.0.0       :  1.3.0 (OK)
qdarkstyle >=3.2.0,<3.3.0        :  3.2 (OK)
qstylizer >=0.2.2                :  0.2.2 (OK)
qtawesome >=1.2.1                :  1.2.3 (OK)
qtconsole >=5.5.0,<5.6.0         :  5.5.0 (OK)
qtpy >=2.1.0                     :  2.4.1 (OK)
rtree >=0.9.7                    :  1.1.0 (OK)
setuptools >=49.6.0              :  68.2.2 (OK)
sphinx >=0.6.6                   :  5.1.1 (OK)
spyder_kernels >=2.5.0,<2.6.0    :  2.5.0 (OK)
textdistance >=4.2.0             :  4.6.0 (OK)
three_merge >=0.1.1              :  0.1.1 (OK)
watchdog >=0.10.3                :  3.0.0 (OK)
zmq >=22.1.0                     :  25.1.1 (OK)

# Optional:
cython >=0.21                    :  3.0.5 (OK)
matplotlib >=3.0.0               :  3.8.1 (OK)
numpy >=1.7                      :  1.26.1 (OK)
pandas >=1.1.1                   :  2.1.2 (OK)
scipy >=0.17.0                   :  1.11.3 (OK)
sympy >=0.7.3                    :  1.12 (OK)
```



Discussion:
> Tried to open "Find in files". The textbox to search in files was already filled with the last line of code I ran in the console for some reason.

### Solution
OK so first try to set Spyder to factory defaults.
Then RE-install if not work
run cmd.exe as admin and type 
`sfc /scannow`
reboot spyder 
if not work try:
`DISM /Online /Cleanup-Image /RestoreHealth` --> might wanna try to do DISM /Online /Cleanup-Image /CheckHealth first.

If none work tell me

Thx
Kiamehr Esk
Hey @popovs, thanks for reporting. I don't understand very well how this error can be generated. If possible, could you post a screenshot of the current options you have in the Find pane that lead to this error?

If that's not possible, don't worry. We'll find a way to prevent it in Spyder 6, to be released during the first quarter of next year.

Resolving patch:
diff --git a/spyder/plugins/findinfiles/plugin.py b/spyder/plugins/findinfiles/plugin.py
--- a/spyder/plugins/findinfiles/plugin.py
+++ b/spyder/plugins/findinfiles/plugin.py
@@ -59,7 +59,7 @@ def get_icon(cls):
     def on_initialize(self):
         self.create_action(
             FindInFilesActions.FindInFiles,
-            text=_("Find in files"),
+            text=_("Search text in the Find pane"),
             tip=_("Search text in multiple files"),
             triggered=self.find,
             register_shortcut=True,
diff --git a/spyder/plugins/findinfiles/widgets/combobox.py b/spyder/plugins/findinfiles/widgets/combobox.py
--- a/spyder/plugins/findinfiles/widgets/combobox.py
+++ b/spyder/plugins/findinfiles/widgets/combobox.py
@@ -20,12 +20,16 @@
 
 # ---- Constants
 # ----------------------------------------------------------------------------
-CWD = 0
-PROJECT = 1
-FILE_PATH = 2
-SELECT_OTHER = 4
-CLEAR_LIST = 5
-EXTERNAL_PATHS = 7
+class SearchInComboBoxItems:
+    Cwd = 0
+    Project = 1
+    File = 2
+    FirstSeparator = 3
+    SelectAnotherDirectory = 4
+    ClearList = 5
+    SecondSeparator = 6
+    ExternalPaths = 7
+
 MAX_PATH_HISTORY = 15
 
 
@@ -43,46 +47,35 @@ class SearchInComboBox(SpyderComboBox):
     def __init__(self, external_path_history=[], parent=None, id_=None):
         super().__init__(parent)
         self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
-        self.setToolTip(_('Search directory'))
         self.setEditable(False)
 
         self.path = ''
-        self.project_path = None
-        self.file_path = None
-        self.external_path = None
+        self.project_path = ''
+        self.file_path = ''
+        self.external_path = ''
 
         if id_ is not None:
             self.ID = id_
 
         self.addItem(_("Current working directory"))
-        ttip = ("Search in all files and directories present on the current"
-                " Spyder path")
-        self.setItemData(0, ttip, Qt.ToolTipRole)
 
         self.addItem(_("Project"))
-        ttip = _("Search in all files and directories present on the"
-                 " current project path (if opened)")
-        self.setItemData(1, ttip, Qt.ToolTipRole)
-        self.model().item(1, 0).setEnabled(False)
-
-        self.addItem(_("File").replace('&', ''))
-        ttip = _("Search in current opened file")
-        self.setItemData(2, ttip, Qt.ToolTipRole)
+        self.model().item(SearchInComboBoxItems.Project, 0).setEnabled(False)
 
-        self.insertSeparator(3)
+        self.addItem(_("Current file").replace('&', ''))
 
-        self.addItem(_("Select other directory"))
-        ttip = _("Search in other folder present on the file system")
-        self.setItemData(4, ttip, Qt.ToolTipRole)
+        self.insertSeparator(SearchInComboBoxItems.FirstSeparator)
 
-        self.addItem(_("Clear this list"))
-        ttip = _("Clear the list of other directories")
-        self.setItemData(5, ttip, Qt.ToolTipRole)
+        self.addItem(_("Select another directory"))
+        self.addItem(_("Clear the list of other directories"))
 
-        self.insertSeparator(6)
+        self.insertSeparator(SearchInComboBoxItems.SecondSeparator)
 
-        for path in external_path_history:
-            self.add_external_path(path)
+        if external_path_history:
+            for path in external_path_history:
+                self.add_external_path(path)
+        else:
+            self.set_state_other_dirs_items(False)
 
         self.currentIndexChanged.connect(self.path_selection_changed)
         self.view().installEventFilter(self)
@@ -96,21 +89,29 @@ def add_external_path(self, path):
         """
         if not osp.exists(path):
             return
+        self.set_state_other_dirs_items(True)
         self.removeItem(self.findText(path))
         self.addItem(path)
         self.setItemData(self.count() - 1, path, Qt.ToolTipRole)
-        while self.count() > MAX_PATH_HISTORY + EXTERNAL_PATHS:
-            self.removeItem(EXTERNAL_PATHS)
+
+        while (
+            self.count() >
+            (MAX_PATH_HISTORY + SearchInComboBoxItems.ExternalPaths)
+        ):
+            self.removeItem(SearchInComboBoxItems.ExternalPaths)
 
     def get_external_paths(self):
         """Returns a list of the external paths listed in the combobox."""
-        return [str(self.itemText(i))
-                for i in range(EXTERNAL_PATHS, self.count())]
+        return [
+            str(self.itemText(i))
+            for i in range(SearchInComboBoxItems.ExternalPaths, self.count())
+        ]
 
     def clear_external_paths(self):
         """Remove all the external paths listed in the combobox."""
-        while self.count() > EXTERNAL_PATHS:
-            self.removeItem(EXTERNAL_PATHS)
+        while self.count() > SearchInComboBoxItems.ExternalPaths:
+            self.removeItem(SearchInComboBoxItems.ExternalPaths)
+        self.set_state_other_dirs_items(False)
 
     def get_current_searchpath(self):
         """
@@ -118,11 +119,11 @@ def get_current_searchpath(self):
         in the combobox.
         """
         idx = self.currentIndex()
-        if idx == CWD:
+        if idx == SearchInComboBoxItems.Cwd:
             return self.path
-        elif idx == PROJECT:
+        elif idx == SearchInComboBoxItems.Project:
             return self.project_path
-        elif idx == FILE_PATH:
+        elif idx == SearchInComboBoxItems.File:
             return self.file_path
         else:
             return self.external_path
@@ -131,15 +132,17 @@ def set_current_searchpath_index(self, index):
         """Set the current index of this combo box."""
         if index is not None:
             index = min(index, self.count() - 1)
-            index = CWD if index in [CLEAR_LIST, SELECT_OTHER] else index
+            if index in [SearchInComboBoxItems.ClearList,
+                         SearchInComboBoxItems.SelectAnotherDirectory]:
+                index = SearchInComboBoxItems.Cwd
         else:
-            index = CWD
+            index = SearchInComboBoxItems.Cwd
 
         self.setCurrentIndex(index)
 
     def is_file_search(self):
         """Returns whether the current search path is a file."""
-        if self.currentIndex() == FILE_PATH:
+        if self.currentIndex() == SearchInComboBoxItems.File:
             return True
         else:
             return False
@@ -148,22 +151,22 @@ def is_file_search(self):
     def path_selection_changed(self):
         """Handles when the current index of the combobox changes."""
         idx = self.currentIndex()
-        if idx == SELECT_OTHER:
+        if idx == SearchInComboBoxItems.SelectAnotherDirectory:
             external_path = self.select_directory()
             if len(external_path) > 0:
                 self.add_external_path(external_path)
                 self.setCurrentIndex(self.count() - 1)
             else:
-                self.setCurrentIndex(CWD)
-        elif idx == CLEAR_LIST:
+                self.setCurrentIndex(SearchInComboBoxItems.Cwd)
+        elif idx == SearchInComboBoxItems.ClearList:
             reply = QMessageBox.question(
                     self, _("Clear other directories"),
                     _("Do you want to clear the list of other directories?"),
                     QMessageBox.Yes | QMessageBox.No)
             if reply == QMessageBox.Yes:
                 self.clear_external_paths()
-            self.setCurrentIndex(CWD)
-        elif idx >= EXTERNAL_PATHS:
+            self.setCurrentIndex(SearchInComboBoxItems.Cwd)
+        elif idx >= SearchInComboBoxItems.ExternalPaths:
             self.external_path = str(self.itemText(idx))
 
     @Slot()
@@ -187,27 +190,55 @@ def set_project_path(self, path):
         if the value of path is None.
         """
         if path is None:
-            self.project_path = None
-            self.model().item(PROJECT, 0).setEnabled(False)
-            if self.currentIndex() == PROJECT:
-                self.setCurrentIndex(CWD)
+            self.project_path = ''
+            self.model().item(
+                SearchInComboBoxItems.Project, 0
+            ).setEnabled(False)
+            if self.currentIndex() == SearchInComboBoxItems.Project:
+                self.setCurrentIndex(SearchInComboBoxItems.Cwd)
         else:
             path = osp.abspath(path)
             self.project_path = path
-            self.model().item(PROJECT, 0).setEnabled(True)
+            self.model().item(
+                SearchInComboBoxItems.Project, 0
+            ).setEnabled(True)
+
+    def set_state_other_dirs_items(self, enabled):
+        """
+        Set the enabled/visible state of items that change when other
+        directories are added/removed to/from the combobox.
+        """
+        # The second separator needs to be visible only when the user has added
+        # other directories.
+        self.view().setRowHidden(
+            SearchInComboBoxItems.SecondSeparator, not enabled
+        )
+
+        # The ClearList item needs to be disabled if the user has not added
+        # other directories
+        self.model().item(
+            SearchInComboBoxItems.ClearList, 0
+        ).setEnabled(enabled)
 
     def eventFilter(self, widget, event):
         """Used to handle key events on the QListView of the combobox."""
         if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Delete:
             index = self.view().currentIndex().row()
-            if index >= EXTERNAL_PATHS:
+            if index >= SearchInComboBoxItems.ExternalPaths:
                 # Remove item and update the view.
                 self.removeItem(index)
                 self.showPopup()
+
                 # Set the view selection so that it doesn't bounce around.
                 new_index = min(self.count() - 1, index)
-                new_index = 0 if new_index < EXTERNAL_PATHS else new_index
+                if new_index < SearchInComboBoxItems.ExternalPaths:
+                    new_index = SearchInComboBoxItems.Cwd
+                    self.set_state_other_dirs_items(False)
+                    self.hidePopup()
+
                 self.view().setCurrentIndex(self.model().index(new_index, 0))
                 self.setCurrentIndex(new_index)
+
             return True
+
         return super().eventFilter(widget, event)
diff --git a/spyder/plugins/findinfiles/widgets/main_widget.py b/spyder/plugins/findinfiles/widgets/main_widget.py
--- a/spyder/plugins/findinfiles/widgets/main_widget.py
+++ b/spyder/plugins/findinfiles/widgets/main_widget.py
@@ -140,6 +140,7 @@ def __init__(self, name=None, plugin=None, parent=None):
         self._search_in_label_width = None
         self._exclude_label_width = None
         self._is_shown = False
+        self._is_first_time = False
 
         search_text = self.get_conf('search_text', '')
         path_history = self.get_conf('path_history', [])
@@ -348,22 +349,18 @@ def setup(self):
             self.set_max_results_action,
             menu=menu,
         )
-        self.set_pane_empty()
 
-    def set_pane_empty(self):
-        if self.result_browser.data:
-            self.stacked_widget.setCurrentWidget(self.result_browser)
-        else:
-            self.stacked_widget.setCurrentWidget(self.pane_empty)
+        # Set pane_empty widget at the beginning
+        self.stacked_widget.setCurrentWidget(self.pane_empty)
 
     def update_actions(self):
         self.find_action.setIcon(self.create_icon(
-            'stop' if self.running else 'find'))
+            'stop' if self.running else 'find')
+        )
 
         if self.extras_toolbar and self.more_options_action:
             self.extras_toolbar.setVisible(
                 self.more_options_action.isChecked())
-        self.set_pane_empty()
 
     @on_conf_change(option='more_options')
     def on_more_options_update(self, value):
@@ -645,6 +642,12 @@ def find(self):
         If there is no search running, this will start the search. If there is
         a search running, this will stop it.
         """
+        # Show result_browser the first time a user performs a search and leave
+        # it shown afterwards.
+        if not self._is_first_time:
+            self.stacked_widget.setCurrentWidget(self.result_browser)
+            self._is_first_time = True
+
         if self.running:
             self.stop()
         else:


Test patch:
diff --git a/spyder/plugins/findinfiles/tests/test_plugin.py b/spyder/plugins/findinfiles/tests/test_plugin.py
--- a/spyder/plugins/findinfiles/tests/test_plugin.py
+++ b/spyder/plugins/findinfiles/tests/test_plugin.py
@@ -17,7 +17,7 @@
 # Local imports
 from spyder.config.manager import CONF
 from spyder.plugins.findinfiles.plugin import FindInFiles
-from spyder.plugins.findinfiles.widgets.combobox import SELECT_OTHER
+from spyder.plugins.findinfiles.widgets.combobox import SearchInComboBoxItems
 
 
 LOCATION = osp.realpath(osp.join(os.getcwd(), osp.dirname(__file__)))
@@ -59,7 +59,9 @@ def test_closing_plugin(findinfiles, qtbot, mocker, tmpdir):
             'spyder.plugins.findinfiles.widgets.combobox.getexistingdirectory',
             return_value=external_path
         )
-        path_selection_combo.setCurrentIndex(SELECT_OTHER)
+        path_selection_combo.setCurrentIndex(
+            SearchInComboBoxItems.SelectAnotherDirectory
+        )
 
     assert path_selection_combo.get_external_paths() == expected_results
 
diff --git a/spyder/plugins/findinfiles/widgets/tests/test_widgets.py b/spyder/plugins/findinfiles/widgets/tests/test_widgets.py
--- a/spyder/plugins/findinfiles/widgets/tests/test_widgets.py
+++ b/spyder/plugins/findinfiles/widgets/tests/test_widgets.py
@@ -24,8 +24,9 @@
 from spyder.config.manager import CONF
 from spyder.plugins.findinfiles.widgets.main_widget import FindInFilesWidget
 from spyder.plugins.findinfiles.widgets.combobox import (
-    CWD, CLEAR_LIST, EXTERNAL_PATHS, FILE_PATH, PROJECT, SearchInComboBox,
-    SELECT_OTHER)
+    SearchInComboBox,
+    SearchInComboBoxItems
+)
 from spyder.plugins.findinfiles.widgets.search_thread import SearchThread
 from spyder.utils.palette import QStylePalette, SpyderPalette
 from spyder.utils.stylesheet import APP_STYLESHEET
@@ -366,10 +367,15 @@ def test_add_external_paths(searchin_combobox, mocker):
             osp.dirname(osp.dirname(osp.dirname(LOCATION))),
             osp.dirname(LOCATION)
             ]
-    assert searchin_combobox.count() == len(expected_results)+EXTERNAL_PATHS
+    assert (
+        searchin_combobox.count()
+        == len(expected_results) + SearchInComboBoxItems.ExternalPaths
+    )
     assert searchin_combobox.get_external_paths() == expected_results
     for i, expected_result in enumerate(expected_results):
-        assert expected_result == searchin_combobox.itemText(i+EXTERNAL_PATHS)
+        assert expected_result == searchin_combobox.itemText(
+            i + SearchInComboBoxItems.ExternalPaths
+        )
 
     # Add a new external path to the combobox. The new path is added at the
     # end of the combobox.
@@ -378,10 +384,15 @@ def test_add_external_paths(searchin_combobox, mocker):
         'spyder.plugins.findinfiles.widgets.combobox.getexistingdirectory',
         return_value=new_path
     )
-    searchin_combobox.setCurrentIndex(SELECT_OTHER)
+    searchin_combobox.setCurrentIndex(
+        SearchInComboBoxItems.SelectAnotherDirectory
+    )
 
     expected_results.append(new_path)
-    assert searchin_combobox.count() == len(expected_results)+EXTERNAL_PATHS
+    assert (
+        searchin_combobox.count()
+        == len(expected_results) + SearchInComboBoxItems.ExternalPaths
+    )
     assert searchin_combobox.get_external_paths() == expected_results
     assert searchin_combobox.currentIndex() == searchin_combobox.count()-1
 
@@ -392,11 +403,16 @@ def test_add_external_paths(searchin_combobox, mocker):
         'spyder.plugins.findinfiles.widgets.combobox.getexistingdirectory',
         return_value=new_path
     )
-    searchin_combobox.setCurrentIndex(SELECT_OTHER)
+    searchin_combobox.setCurrentIndex(
+        SearchInComboBoxItems.SelectAnotherDirectory
+    )
 
     expected_results.pop(0)
     expected_results.append(new_path)
-    assert searchin_combobox.count() == len(expected_results)+EXTERNAL_PATHS
+    assert (
+        searchin_combobox.count()
+        == len(expected_results) + SearchInComboBoxItems.ExternalPaths
+    )
     assert searchin_combobox.get_external_paths() == expected_results
     assert searchin_combobox.currentIndex() == searchin_combobox.count()-1
 
@@ -406,11 +422,16 @@ def test_add_external_paths(searchin_combobox, mocker):
         'spyder.plugins.findinfiles.widgets.combobox.getexistingdirectory',
         return_value=''
     )
-    searchin_combobox.setCurrentIndex(SELECT_OTHER)
+    searchin_combobox.setCurrentIndex(
+        SearchInComboBoxItems.SelectAnotherDirectory
+    )
 
-    assert searchin_combobox.count() == len(expected_results)+EXTERNAL_PATHS
+    assert (
+        searchin_combobox.count()
+        == len(expected_results) + SearchInComboBoxItems.ExternalPaths
+    )
     assert searchin_combobox.get_external_paths() == expected_results
-    assert searchin_combobox.currentIndex() == CWD
+    assert searchin_combobox.currentIndex() == SearchInComboBoxItems.Cwd
 
 
 def test_clear_this_list(searchin_combobox, mocker):
@@ -422,7 +443,7 @@ def test_clear_this_list(searchin_combobox, mocker):
 
     # Cancel the Clear the list action and assert the result.
     mocker.patch.object(QMessageBox, 'question', return_value=QMessageBox.No)
-    searchin_combobox.setCurrentIndex(CLEAR_LIST)
+    searchin_combobox.setCurrentIndex(SearchInComboBoxItems.ClearList)
 
     expected_results = [
             LOCATION,
@@ -430,18 +451,21 @@ def test_clear_this_list(searchin_combobox, mocker):
             osp.dirname(osp.dirname(osp.dirname(LOCATION))),
             osp.dirname(LOCATION)
             ]
-    assert searchin_combobox.count() == len(expected_results)+EXTERNAL_PATHS
+    assert (
+        searchin_combobox.count()
+        == len(expected_results) + SearchInComboBoxItems.ExternalPaths
+    )
     assert searchin_combobox.get_external_paths() == expected_results
-    assert searchin_combobox.currentIndex() == CWD
+    assert searchin_combobox.currentIndex() == SearchInComboBoxItems.Cwd
 
     # Clear the list of external paths and assert that the list of
     # external paths is empty.
     mocker.patch.object(QMessageBox, 'question', return_value=QMessageBox.Yes)
-    searchin_combobox.setCurrentIndex(CLEAR_LIST)
+    searchin_combobox.setCurrentIndex(SearchInComboBoxItems.ClearList)
 
-    assert searchin_combobox.count() == EXTERNAL_PATHS
+    assert searchin_combobox.count() == SearchInComboBoxItems.ExternalPaths
     assert searchin_combobox.get_external_paths() == []
-    assert searchin_combobox.currentIndex() == CWD
+    assert searchin_combobox.currentIndex() == SearchInComboBoxItems.Cwd
 
 
 def test_delete_path(searchin_combobox, qtbot, mocker):
@@ -452,48 +476,75 @@ def test_delete_path(searchin_combobox, qtbot, mocker):
     searchin_combobox.show()
 
     expected_results = [
-            LOCATION,
-            osp.dirname(osp.dirname(LOCATION)),
-            osp.dirname(osp.dirname(osp.dirname(LOCATION))),
-            osp.dirname(LOCATION)
-            ]
+        LOCATION,
+        osp.dirname(osp.dirname(LOCATION)),
+        osp.dirname(osp.dirname(osp.dirname(LOCATION))),
+        osp.dirname(LOCATION)
+    ]
 
     searchin_combobox.showPopup()
-    assert searchin_combobox.currentIndex() == CWD
-    assert searchin_combobox.view().currentIndex().row() == CWD
+    assert searchin_combobox.currentIndex() == SearchInComboBoxItems.Cwd
+    assert (
+        searchin_combobox.view().currentIndex().row()
+        == SearchInComboBoxItems.Cwd
+    )
 
     # Assert that the delete action does nothing when the selected item in
     # the combobox view is not an external path.
-    for i in range(EXTERNAL_PATHS):
+    for i in range(SearchInComboBoxItems.ExternalPaths):
         searchin_combobox.view().setCurrentIndex(
             searchin_combobox.model().index(i, 0))
         qtbot.keyPress(searchin_combobox.view(), Qt.Key_Delete)
 
-    assert searchin_combobox.count() == len(expected_results)+EXTERNAL_PATHS
+    assert (
+        searchin_combobox.count()
+        == len(expected_results) + SearchInComboBoxItems.ExternalPaths
+    )
     assert searchin_combobox.get_external_paths() == expected_results
-    assert searchin_combobox.currentIndex() == CWD
+    assert searchin_combobox.currentIndex() == SearchInComboBoxItems.Cwd
 
     # Delete the first external path in the list.
     searchin_combobox.view().setCurrentIndex(
-            searchin_combobox.model().index(EXTERNAL_PATHS, 0))
+        searchin_combobox.model().index(SearchInComboBoxItems.ExternalPaths, 0)
+    )
     qtbot.keyPress(searchin_combobox.view(), Qt.Key_Delete)
 
     expected_results.pop(0)
-    assert searchin_combobox.count() == len(expected_results)+EXTERNAL_PATHS
+    assert (
+        searchin_combobox.count()
+        == len(expected_results) + SearchInComboBoxItems.ExternalPaths
+    )
     assert searchin_combobox.get_external_paths() == expected_results
-    assert searchin_combobox.currentIndex() == EXTERNAL_PATHS
-    assert searchin_combobox.view().currentIndex().row() == EXTERNAL_PATHS
+    assert (
+        searchin_combobox.currentIndex() == SearchInComboBoxItems.ExternalPaths
+    )
+    assert (
+        searchin_combobox.view().currentIndex().row()
+        == SearchInComboBoxItems.ExternalPaths
+    )
 
     # Delete the second external path in the remaining list.
     searchin_combobox.view().setCurrentIndex(
-            searchin_combobox.model().index(EXTERNAL_PATHS+1, 0))
+        searchin_combobox.model().index(
+            SearchInComboBoxItems.ExternalPaths + 1, 0
+        )
+    )
     qtbot.keyPress(searchin_combobox.view(), Qt.Key_Delete)
 
     expected_results.pop(1)
-    assert searchin_combobox.count() == len(expected_results)+EXTERNAL_PATHS
+    assert (
+        searchin_combobox.count()
+        == len(expected_results) + SearchInComboBoxItems.ExternalPaths
+    )
     assert searchin_combobox.get_external_paths() == expected_results
-    assert searchin_combobox.currentIndex() == EXTERNAL_PATHS+1
-    assert searchin_combobox.view().currentIndex().row() == EXTERNAL_PATHS+1
+    assert (
+        searchin_combobox.currentIndex()
+        == SearchInComboBoxItems.ExternalPaths + 1
+    )
+    assert (
+        searchin_combobox.view().currentIndex().row()
+        == SearchInComboBoxItems.ExternalPaths + 1
+    )
 
     # Delete the last external path in the list.
     searchin_combobox.view().setCurrentIndex(
@@ -501,7 +552,10 @@ def test_delete_path(searchin_combobox, qtbot, mocker):
     qtbot.keyPress(searchin_combobox.view(), Qt.Key_Delete)
 
     expected_results.pop()
-    assert searchin_combobox.count() == len(expected_results)+EXTERNAL_PATHS
+    assert (
+        searchin_combobox.count()
+        == len(expected_results) + SearchInComboBoxItems.ExternalPaths
+    )
     assert searchin_combobox.get_external_paths() == expected_results
     assert searchin_combobox.currentIndex() == searchin_combobox.count()-1
     assert (searchin_combobox.view().currentIndex().row() ==
@@ -509,13 +563,17 @@ def test_delete_path(searchin_combobox, qtbot, mocker):
 
     # Delete the last remaining external path in the list.
     searchin_combobox.view().setCurrentIndex(
-            searchin_combobox.model().index(EXTERNAL_PATHS, 0))
+        searchin_combobox.model().index(SearchInComboBoxItems.ExternalPaths, 0)
+    )
     qtbot.keyPress(searchin_combobox.view(), Qt.Key_Delete)
 
-    assert searchin_combobox.count() == EXTERNAL_PATHS
+    assert searchin_combobox.count() == SearchInComboBoxItems.ExternalPaths
     assert searchin_combobox.get_external_paths() == []
-    assert searchin_combobox.currentIndex() == CWD
-    assert searchin_combobox.view().currentIndex().row() == CWD
+    assert searchin_combobox.currentIndex() == SearchInComboBoxItems.Cwd
+    assert (
+        searchin_combobox.view().currentIndex().row()
+        == SearchInComboBoxItems.Cwd
+    )
 
 
 def test_set_project_path(findinfiles, qtbot):
@@ -526,25 +584,40 @@ def test_set_project_path(findinfiles, qtbot):
     path_selection_combo = findinfiles.path_selection_combo
     findinfiles.show()
 
-    assert path_selection_combo.model().item(PROJECT, 0).isEnabled() is False
-    assert findinfiles.project_path is None
-    assert path_selection_combo.project_path is None
+    assert (
+        path_selection_combo.model().item(
+            SearchInComboBoxItems.Project, 0
+        ).isEnabled()
+        is False
+    )
+    assert findinfiles.project_path == ""
+    assert path_selection_combo.project_path == ""
 
     # Set the project path to an existing directory. For the purpose of this
     # test, it doesn't need to be a valid Spyder project path.
     project_path = NONASCII_DIR
     findinfiles.set_project_path(project_path)
-    assert path_selection_combo.model().item(PROJECT, 0).isEnabled() is True
+    assert (
+        path_selection_combo.model().item(
+            SearchInComboBoxItems.Project, 0
+        ).isEnabled()
+        is True
+    )
     assert findinfiles.project_path == project_path
     assert path_selection_combo.project_path == project_path
 
     # Disable the project path search in the widget.
-    path_selection_combo.setCurrentIndex(PROJECT)
+    path_selection_combo.setCurrentIndex(SearchInComboBoxItems.Project)
     findinfiles.disable_project_search()
-    assert path_selection_combo.model().item(PROJECT, 0).isEnabled() is False
-    assert findinfiles.project_path is None
-    assert path_selection_combo.project_path is None
-    assert path_selection_combo.currentIndex() == CWD
+    assert (
+        path_selection_combo.model().item(
+            SearchInComboBoxItems.Project, 0
+        ).isEnabled()
+        is False
+    )
+    assert findinfiles.project_path == ""
+    assert path_selection_combo.project_path == ""
+    assert path_selection_combo.currentIndex() == SearchInComboBoxItems.Cwd
 
 
 @pytest.mark.parametrize('findinfiles',
@@ -593,20 +666,22 @@ def test_current_search_path(findinfiles, qtbot):
     # Assert that the good path is returned for each option selected.
 
     # Test for the current working directory :
-    path_selection_combo.setCurrentIndex(CWD)
+    path_selection_combo.setCurrentIndex(SearchInComboBoxItems.Cwd)
     assert path_selection_combo.get_current_searchpath() == directory
     assert path_selection_combo.is_file_search() is False
     # Test for the project path :
-    path_selection_combo.setCurrentIndex(PROJECT)
+    path_selection_combo.setCurrentIndex(SearchInComboBoxItems.Project)
     assert path_selection_combo.get_current_searchpath() == project_path
     assert path_selection_combo.is_file_search() is False
     # Test for the file path :
-    path_selection_combo.setCurrentIndex(FILE_PATH)
+    path_selection_combo.setCurrentIndex(SearchInComboBoxItems.File)
     assert path_selection_combo.get_current_searchpath() == file_path
     assert path_selection_combo.is_file_search() is True
     # Test for the external file path :
     for i, path in enumerate(external_paths):
-        path_selection_combo.setCurrentIndex(EXTERNAL_PATHS+i)
+        path_selection_combo.setCurrentIndex(
+            SearchInComboBoxItems.ExternalPaths + i
+        )
         assert path_selection_combo.get_current_searchpath() == path
         assert path_selection_combo.is_file_search() is False
 
@@ -627,7 +702,10 @@ def test_max_history(searchin_combobox):
             osp.dirname(osp.dirname(osp.dirname(LOCATION))),
             osp.dirname(LOCATION)
     ]
-    assert searchin_combobox.count() == len(expected_results) + EXTERNAL_PATHS
+    assert (
+        searchin_combobox.count()
+        == len(expected_results) + SearchInComboBoxItems.ExternalPaths
+    )
     assert searchin_combobox.get_external_paths() == expected_results
 
 
@@ -659,7 +737,7 @@ def test_find_in_single_file(findinfiles, qtbot):
     """
     findinfiles.set_search_text("spam")
     findinfiles.set_file_path(osp.join(LOCATION, "data", 'spam.txt'))
-    findinfiles.path_selection_combo.setCurrentIndex(FILE_PATH)
+    findinfiles.path_selection_combo.setCurrentIndex(SearchInComboBoxItems.File)
 
     with qtbot.waitSignal(findinfiles.sig_finished):
         findinfiles.find()