Skip to content

Commit b54bc39

Browse files
authored
Merge pull request #25022 from CAM-Gerlach/prefs-ui-text-interpreter
PR: Clarify and polish UI text for Python interpreter pref pane
2 parents da6e808 + 432f200 commit b54bc39

File tree

1 file changed

+32
-67
lines changed

1 file changed

+32
-67
lines changed

spyder/plugins/maininterpreter/confpage.py

Lines changed: 32 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# Standard library imports
1010
import os
1111
import os.path as osp
12-
import sys
1312

1413
# Third party imports
1514
from qtpy.QtWidgets import (QButtonGroup, QGroupBox, QInputDialog, QLabel,
@@ -68,18 +67,18 @@ def setup_page(self):
6867
pyexec_bg = QButtonGroup(pyexec_group)
6968
pyexec_label = QLabel(
7069
_(
71-
"Select the default Python interpreter to create new IPython "
72-
"consoles and to provide code completion in the Editor"
70+
"Select the default Python interpreter for new IPython consoles "
71+
"and Editor code completion"
7372
)
7473
)
7574
pyexec_label.setWordWrap(True)
7675
self.def_exec_radio = self.create_radiobutton(
77-
_("Internal (i.e. the same used by Spyder)"),
76+
_("Internal (same used by Spyder)"),
7877
'default',
7978
button_group=pyexec_bg,
8079
)
8180
self.cus_exec_radio = self.create_radiobutton(
82-
_("Use the following interpreter:"),
81+
_("Selected interpreter:"),
8382
'custom',
8483
button_group=pyexec_bg,
8584
)
@@ -117,40 +116,39 @@ def setup_page(self):
117116

118117
# UMR Group
119118
umr_group = QGroupBox(_("User Module Reloader (UMR)"))
120-
umr_label = QLabel(_("UMR forces Python to reload modules which were "
121-
"imported when executing a file in a Python or "
122-
"IPython console with the <i>runfile</i> "
123-
"function."))
119+
umr_label = QLabel(
120+
_(
121+
"UMR forces Python to reload imported modules when "
122+
"running a file in an IPython console."
123+
),
124+
)
124125
umr_label.setWordWrap(True)
125126
umr_enabled_box = newcb(
126127
_("Enable UMR"),
127128
'umr/enabled',
128-
msg_if_enabled=True,
129-
msg_warning=_(
129+
msg_info=_("This change will only be applied to new consoles"),
130+
tip=_(
130131
"This option will enable the User Module Reloader (UMR) "
131-
"in Python/IPython consoles. UMR forces Python to "
132-
"reload deeply modules during import when running a "
133-
"Python file using the Spyder's builtin function "
134-
"<b>runfile</b>."
135-
"<br><br><b>1.</b> UMR may require to restart the "
136-
"console in which it will be called "
132+
"in IPython consoles. UMR forces Python to perform a "
133+
"deep reload of imported modules when running Python files "
134+
"with Spyder's <code>Run</code> command.<br><br>"
135+
"After being enabled, UMR requires a console restart "
137136
"(otherwise only newly imported modules will be "
138-
"reloaded when executing files)."
139-
"<br><br><b>2.</b> If errors occur when re-running a "
140-
"PyQt-based program, please check that the Qt objects "
141-
"are properly destroyed (e.g. you may have to use the "
142-
"attribute <b>Qt.WA_DeleteOnClose</b> on your main "
143-
"window, using the <b>setAttribute</b> method)"
137+
"reloaded when running files).<br><br>"
138+
"If errors occur when re-running a PyQt-based program, "
139+
"please check that the Qt objects are properly destroyed "
140+
"(e.g. you may have to use the attribute "
141+
"<code>Qt.WA_DeleteOnClose</code> on your main window, "
142+
"using the <code>setAttribute</code> method)."
144143
),
145144
)
146145
umr_verbose_box = newcb(
147-
_("Show reloaded modules list"),
146+
_("Print list of reloaded modules"),
148147
'umr/verbose',
149-
msg_info=_("Please note that these changes will "
150-
"be applied only to new consoles"),
148+
msg_info=_("This change will only be applied to new consoles"),
151149
)
152150
umr_namelist_btn = QPushButton(
153-
_("Set UMR excluded (not reloaded) modules"))
151+
_("Select modules to exclude from being reloaded"))
154152
umr_namelist_btn.clicked.connect(self.set_umr_namelist)
155153

156154
umr_layout = QVBoxLayout()
@@ -166,43 +164,13 @@ def setup_page(self):
166164
vlayout.addStretch(1)
167165
self.setLayout(vlayout)
168166

169-
def warn_python_compatibility(self, pyexec):
170-
if not osp.isfile(pyexec):
171-
return
172-
173-
spyder_version = sys.version_info[0]
174-
try:
175-
args = ["-c", "import sys; print(sys.version_info[0])"]
176-
proc = programs.run_program(pyexec, args, env={})
177-
console_version = int(proc.communicate()[0])
178-
except IOError:
179-
console_version = spyder_version
180-
except ValueError:
181-
return False
182-
183-
if spyder_version != console_version:
184-
QMessageBox.warning(
185-
self,
186-
_('Warning'),
187-
_("You selected a <b>Python %d</b> interpreter for the "
188-
"console but Spyder is running on <b>Python %d</b>!.<br><br>"
189-
"Although this is possible, we recommend you to install and "
190-
"run Spyder directly with your selected interpreter, to "
191-
"avoid seeing false warnings and errors due to the "
192-
"incompatible syntax between these two Python versions."
193-
) % (console_version, spyder_version),
194-
QMessageBox.Ok,
195-
)
196-
197-
return True
198-
199167
def set_umr_namelist(self):
200-
"""Set UMR excluded modules name list"""
168+
"""Set UMR excluded module names list."""
169+
example_excludes = "<code>numpy, scipy</code>"
201170
arguments, valid = QInputDialog.getText(
202171
self,
203172
_('UMR'),
204-
_("Set the list of excluded modules as this: "
205-
"<i>numpy, scipy</i>"),
173+
_("List of excluded modules (e.g. {})").format(example_excludes),
206174
QLineEdit.Normal,
207175
", ".join(self.get_option('umr/namelist')),
208176
)
@@ -222,15 +190,15 @@ def set_umr_namelist(self):
222190
QMessageBox.warning(
223191
self,
224192
_('UMR'),
225-
_("The following modules are not "
226-
"installed on your machine:\n%s") % invalid,
193+
_(
194+
"The following modules are not installed:\n{}"
195+
).format(invalid),
227196
QMessageBox.Ok,
228197
)
229198
QMessageBox.information(
230199
self,
231200
_('UMR'),
232-
_("Please note that these changes will "
233-
"be applied only to new IPython consoles"),
201+
_("Changes will only be applied to new IPython consoles"),
234202
QMessageBox.Ok,
235203
)
236204
else:
@@ -254,6 +222,3 @@ def perform_adjustments(self):
254222
self.cus_exec_combo.combobox.clear()
255223
self.cus_exec_combo.combobox.addItems(custom_list)
256224
self.pyexec_edit.setText(executable)
257-
258-
# Show warning compatibility message.
259-
self.warn_python_compatibility(executable)

0 commit comments

Comments
 (0)