Skip to content

Commit

Permalink
apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbautista committed Jan 31, 2025
1 parent 5181ed2 commit bf929d2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 28 deletions.
7 changes: 0 additions & 7 deletions spyder/plugins/ipythonconsole/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,6 @@ def on_remote_client_available(self):
def on_main_interpreter_available(self):
main_interpreter = self.get_plugin(Plugins.MainInterpreter)
main_interpreter.sig_environments_updated.connect(self._update_envs)
mi_container = main_interpreter.get_container()

pythonenv_status = self.get_widget().pythonenv_status

# connect signals
pythonenv_status.sig_open_preferences_requested.connect(
mi_container.sig_open_preferences_requested)

@on_plugin_teardown(plugin=Plugins.Preferences)
def on_preferences_teardown(self):
Expand Down
12 changes: 12 additions & 0 deletions spyder/plugins/ipythonconsole/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ def __init__(self, name=None, plugin=None, parent=None):
self.pythonenv_status.sig_interpreter_changed.connect(
self.sig_interpreter_changed
)
self.pythonenv_status.sig_open_preferences_requested.connect(
self._open_interpreter_preferences
)

# Initial value for the current working directory
self._current_working_directory = get_home_dir()
Expand Down Expand Up @@ -1160,6 +1163,15 @@ def _init_asyncio_patch(self):
asyncio.set_event_loop_policy(
WindowsSelectorEventLoopPolicy())

def _open_interpreter_preferences(self):
"""Open the Preferences dialog in the main interpreter section."""
self._main.show_preferences()
preferences = self._main.preferences
container = preferences.get_container()
dlg = container.dialog
index = dlg.get_index_by_name("main_interpreter")
dlg.set_current_index(index)

@Slot()
def _create_client_for_kernel(self):
"""Create a client connected to an existing kernel"""
Expand Down
4 changes: 0 additions & 4 deletions spyder/plugins/maininterpreter/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ class MainInterpreterContainer(PluginMainContainer):
:py:meth:`spyder.utils.envs.get_list_envs`.
"""

sig_open_preferences_requested = Signal()
"""
Signal to open the main interpreter preferences.
"""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down
17 changes: 0 additions & 17 deletions spyder/plugins/maininterpreter/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class MainInterpreter(SpyderPluginV2):
Path to the new interpreter.
"""


# ---- SpyderPluginV2 API
# -------------------------------------------------------------------------
@staticmethod
Expand All @@ -83,18 +82,12 @@ def get_icon(cls):
def on_initialize(self):
container = self.get_container()

# Connect signal to open preferences
container.sig_open_preferences_requested.connect(
self._open_interpreter_preferences
)

# Connect container signals
container.sig_environments_updated.connect(
self.sig_environments_updated
)
container.sig_interpreter_changed.connect(self.sig_interpreter_changed)


# Validate that the custom interpreter from the previous session
# still exists
if self.get_conf('custom'):
Expand Down Expand Up @@ -125,13 +118,3 @@ def set_custom_interpreter(self, interpreter):
self.set_conf("custom", True)
self.set_conf("custom_interpreter", interpreter)
self.set_conf("executable", interpreter)

# ---- Private API
def _open_interpreter_preferences(self):
"""Open the Preferences dialog in the main interpreter section."""
self._main.show_preferences()
preferences = self._main.preferences
container = preferences.get_container()
dlg = container.dialog
index = dlg.get_index_by_name("main_interpreter")
dlg.set_current_index(index)

0 comments on commit bf929d2

Please sign in to comment.