Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Generalize Run plugin to support generic inputs and executors #17467

Merged
merged 102 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
d89e4b4
Start Run plugin generalization
andfoy Mar 10, 2022
c103a55
Finish typing stubs and Run API interfaces
andfoy Mar 10, 2022
cb61372
Add register and deregister methods for InputProviders, Executors and…
andfoy Mar 16, 2022
a1b920c
Merge remote-tracking branch 'upstream/master' into split_run_editor
andfoy Mar 17, 2022
dbb2bf6
Fix docstrings and some interface naming
andfoy Mar 27, 2022
738e0fa
Move context and extension to run configuration metadata
andfoy Mar 29, 2022
e26c41f
Start working on the new Run dialog
andfoy Mar 30, 2022
5a00314
Define abstract models for both model configurations as well as execu…
andfoy Apr 20, 2022
6e57446
Merge branch 'master' into split_run_editor
andfoy Apr 20, 2022
e4a986e
Register files from the editor
andfoy Apr 21, 2022
56dda5f
Fix issues with the run configuration combobox
andfoy May 9, 2022
2cd4f3f
Merge branch 'master' into split_run_editor
andfoy May 9, 2022
958fbf6
Deregister run configurations from the Editor
andfoy May 9, 2022
17800e9
Merge branch 'split_run_editor' of https://github.com/andfoy/spyder i…
andfoy May 9, 2022
8e89657
Make sure combobox follows the focused run configuration
andfoy May 10, 2022
ceffc24
Ensure executors combo box is updated correctly
andfoy May 16, 2022
ddd57c7
Load stored parameters from configuration
andfoy May 18, 2022
53a909f
Add combobox and checkbox to create new run configurations
andfoy May 23, 2022
1f3b28f
Decouple run parameters from files
andfoy May 24, 2022
7165efa
Per-executor configuration parameters are now being saved and loaded
andfoy May 26, 2022
6b4a065
Run is now working with files
andfoy May 27, 2022
0c1e651
Move external console options to a separate executor
andfoy May 30, 2022
7274b74
Add support for bash files
andfoy May 31, 2022
42996dc
Save last used parameters per file
andfoy Jun 1, 2022
4f1a388
Fix parameter initialization in dialog
andfoy Jun 1, 2022
48ac435
Add selection action
andfoy Jun 3, 2022
4e4077d
Add support for cells and script selection
andfoy Jun 4, 2022
a1ed3c7
Add support for cells and advance
andfoy Jun 7, 2022
53b8ca2
Merge branch 'master' into split_run_editor
andfoy Jun 7, 2022
cad2038
Try to override shortcuts
andfoy Jun 7, 2022
79a485b
Add run to/from line actions
andfoy Jun 7, 2022
978a59e
Add open configuration dialog action
andfoy Jun 8, 2022
35ab62f
Add re-run last file action
andfoy Jun 8, 2022
1c0d828
Add re-run cell option
andfoy Jun 9, 2022
23c7520
Migrate Profiler to use the new Run API
andfoy Jun 10, 2022
bfec106
Get around Python scope limitations
andfoy Jun 10, 2022
28a6e92
Move Pylint to use the new Run infraestructure
andfoy Jun 13, 2022
bb91bb0
Add teardown routines for Run methods and dependencies
andfoy Jun 13, 2022
b9f395b
Start re-working the Run configuration page
andfoy Jun 14, 2022
bba8245
Add configuration page edition dialog
andfoy Jun 15, 2022
22e2932
Configuration page is now working as expected
andfoy Jun 17, 2022
9069f26
Remove unwanted import
andfoy Jun 20, 2022
4761fca
Ensure powershell and cmd work as expected
andfoy Jun 20, 2022
c8401f3
Start fixing fast tests
andfoy Jun 20, 2022
748342d
Merge remote-tracking branch 'upstream/master' into split_run_editor
andfoy Jun 20, 2022
99da57b
Rename action to make it visible in macOS
steff456 Jun 20, 2022
3b5716b
Merge branch 'master' into split_run_editor
andfoy Jun 21, 2022
717d9c2
Fix mainwindow tests
andfoy Jun 21, 2022
8550e23
Merge with master
andfoy Jun 21, 2022
cbf6d4f
Add temporary run api to debug files
andfoy Jun 21, 2022
f3f413a
Fix cell copy options
andfoy Jun 21, 2022
edc8532
Fix a few more tests
andfoy Jun 21, 2022
01ac4df
Fix remaining tests
andfoy Jun 22, 2022
836626a
Merge branch 'master' into split_run_editor
andfoy Jun 23, 2022
b1e958f
Merge remote-tracking branch 'upstream/master' into split_run_editor
andfoy Jun 23, 2022
4a1339d
Fix test_connection_to_external_kernel
andfoy Jun 24, 2022
9b5dd10
Add external console test
andfoy Jun 27, 2022
17612ce
Fix shell test in Windows
andfoy Jun 27, 2022
4f5c406
Apply review comments
steff456 Jun 28, 2022
8a05705
Inherit RunExecutor from QObject in order to ensure MRO resolution
andfoy Jun 28, 2022
8fd758e
Add API versioning how-to
andfoy Jun 28, 2022
90951bc
Fix pep8 issues
steff456 Jun 29, 2022
f6a13f7
Merge branch 'master' into split_run_editor
andfoy Jun 29, 2022
54bdaff
Add comments to fix test on windows CI
steff456 Jun 30, 2022
41a08d9
Merge branch 'split_run_editor' of github.com:andfoy/spyder into spli…
steff456 Jun 30, 2022
a65c8a8
Fix failing test in frames
steff456 Jun 30, 2022
25ab1f3
Refactor run dialog to use async Qt API
andfoy Jul 1, 2022
0986382
Extend test to run an input in transient mode
andfoy Jul 2, 2022
a72dde9
Extend test to consider subordinate contexts
andfoy Jul 5, 2022
77b5422
Use Run button instead of shortcut on test_varexp_rename
andfoy Jul 5, 2022
5c68b36
Merge branch 'master' into split_run_editor
andfoy Jul 5, 2022
85eb1a4
Test teardown deregistration for Run
andfoy Jul 5, 2022
e059967
Try to prevent duplicate shortcuts
andfoy Jul 7, 2022
d223b4c
Group some run tests
andfoy Jul 11, 2022
cd7d70c
Skip test_runcell_edge_cases
andfoy Jul 11, 2022
4df2264
Skip test_runcell_pdb on Windows
andfoy Jul 11, 2022
c5b14e9
Fix typo
steff456 Jul 12, 2022
89e2d4d
Skip test_runcell_cache on Windows
andfoy Jul 12, 2022
fee8db9
Merge branch 'split_run_editor' of https://github.com/andfoy/spyder i…
andfoy Jul 12, 2022
10542d3
Skip test_runcell_after_restart on Windows
andfoy Jul 12, 2022
ffbf1e3
Move test_varexp_remove to call the Run button directly
andfoy Jul 12, 2022
d84f28a
Increase timeout on test_print_multiprocessing
andfoy Jul 13, 2022
48965d3
Fix issues with whitespaces when running shell files
andfoy Jul 13, 2022
45d5053
Retrieve run configurations for super contexts via get_run_configurat…
andfoy Jul 13, 2022
b64f181
Force editor to set focus appropiately in test_print_multiprocessing
andfoy Jul 13, 2022
3204b63
Add wait for test_print_faulthandler
andfoy Jul 13, 2022
7020323
Fix Run configuration page table issues
andfoy Jul 13, 2022
500887c
Display only the executors that have a configuration dialog
andfoy Jul 13, 2022
ebf2b63
Add wait time to refresh run file in test_debug_unsaved_function
andfoy Jul 14, 2022
646f321
Merge after releasing 5.3.3
ccordoba12 Feb 3, 2023
0e80241
Merge after releasing 5.4.0
ccordoba12 Feb 4, 2023
8ede54f
Merge after releasing 5.4.1
ccordoba12 Feb 5, 2023
1c156b7
Fix line endings of batch scripts
ccordoba12 Feb 5, 2023
0e07d4a
Merge branch 'master' into split_run_editor
ccordoba12 Feb 5, 2023
58525e3
Testing: Refactor code used to generate run parameters
ccordoba12 Feb 5, 2023
4d42430
Main Window: Remove attributes related to the Run menu and toolbar
ccordoba12 Feb 5, 2023
fd12df1
Testing: Fix most failing tests and skip others
ccordoba12 Feb 5, 2023
8215c66
Debugger: Fix debugging selections
ccordoba12 Feb 7, 2023
5304a54
Ignore revision that updated the new run architecture with master
ccordoba12 Feb 9, 2023
b4782dc
Merge branch 'master' into split_run_editor
ccordoba12 Feb 11, 2023
4068d25
Add some missing docstrings, fix style issues and other minor things
ccordoba12 Feb 11, 2023
5cf60eb
Testing: Skip test_shell_execution on Mac because it's failing
ccordoba12 Feb 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move Pylint to use the new Run infraestructure
Co-authored-by: Stephannie Jimenez Gacha <steff456@hotmail.com>
  • Loading branch information
andfoy and steff456 committed Jun 13, 2022
commit 28a6e929c9b757ba551e450599d2128bb3ef83ae
2 changes: 1 addition & 1 deletion spyder/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@
'console/clear shell': "Ctrl+L",
'console/clear line': "Shift+Escape",
# ---- In Pylint ----
'pylint/run analysis': "F8",
'pylint/run file in pylint': "F8",
ccordoba12 marked this conversation as resolved.
Show resolved Hide resolved
# ---- In Profiler ----
'profiler/run file in profiler': "F10",
# ---- In widgets/ipythonconsole/shell.py ----
Expand Down
97 changes: 70 additions & 27 deletions spyder/plugins/pylint/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# Standard library imports
import os.path as osp
steff456 marked this conversation as resolved.
Show resolved Hide resolved
from typing import List

# Third party imports
from qtpy.QtCore import Qt, Signal, Slot
steff456 marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -25,6 +26,10 @@
from spyder.plugins.pylint.confpage import PylintConfigPage
from spyder.plugins.pylint.main_widget import (PylintWidget,
PylintWidgetActions)
steff456 marked this conversation as resolved.
Show resolved Hide resolved
from spyder.plugins.run.api import (
RunContext, RunConfiguration, PossibleRunResult, run_execute,
ExtendedRunExecutionParameters, RunExecutor)
from spyder.plugins.editor.api.run import FileRun


# Localization
Expand All @@ -35,13 +40,13 @@ class PylintActions:
AnalyzeCurrentFile = 'run analysis'


class Pylint(SpyderDockablePlugin):
class Pylint(SpyderDockablePlugin, RunExecutor):

NAME = "pylint"
WIDGET_CLASS = PylintWidget
CONF_SECTION = NAME
CONF_WIDGET_CLASS = PylintConfigPage
REQUIRES = [Plugins.Preferences, Plugins.Editor]
REQUIRES = [Plugins.Preferences, Plugins.Editor, Plugins.Run]
OPTIONAL = [Plugins.MainMenu, Plugins.Projects]
CONF_FILE = False
DISABLE_ACTIONS_WHEN_HIDDEN = False
Expand All @@ -62,6 +67,10 @@ class Pylint(SpyderDockablePlugin):
Word to select on given row.
"""

def __init__(self, parent, configuration):
super().__init__(parent, configuration)
RunExecutor.__init__(self)

@staticmethod
def get_name():
return _("Code Analysis")
Expand All @@ -83,16 +92,20 @@ def on_initialize(self):
lambda: self.start_code_analysis())

# Add action to application menus
pylint_act = self.create_action(
PylintActions.AnalyzeCurrentFile,
text=_("Run code analysis"),
tip=_("Run code analysis"),
icon=self.create_icon("pylint"),
triggered=lambda: self.start_code_analysis(),
context=Qt.ApplicationShortcut,
register_shortcut=True
)
pylint_act.setEnabled(is_module_installed("pylint"))
self.run_action = None

self.executor_configuration = [
{
'input_extension': 'py',
'context': {
'name': 'File'
},
'output_formats': [],
'configuration_widget': None,
'requires_cwd': False,
'priority': 4
}
]

@on_plugin_available(plugin=Plugins.Editor)
def on_editor_available(self):
Expand All @@ -103,11 +116,6 @@ def on_editor_available(self):
widget.sig_edit_goto_requested.connect(editor.load)
editor.sig_editor_focus_changed.connect(self._set_filename)

pylint_act = self.get_action(PylintActions.AnalyzeCurrentFile)

# TODO: use new API when editor has migrated
editor.pythonfile_dependent_actions += [pylint_act]

@on_plugin_available(plugin=Plugins.Preferences)
def on_preferences_available(self):
preferences = self.get_plugin(Plugins.Preferences)
Expand All @@ -127,9 +135,31 @@ def on_projects_available(self):
def on_main_menu_available(self):
mainmenu = self.get_plugin(Plugins.MainMenu)

pylint_act = self.get_action(PylintActions.AnalyzeCurrentFile)
mainmenu.add_item_to_application_menu(
pylint_act, menu_id=ApplicationMenus.Source)
if self.run_action is not None:
mainmenu.add_item_to_application_menu(
self.run_action, menu_id=ApplicationMenus.Source)

@on_plugin_available(plugin=Plugins.Run)
def on_run_available(self):
run = self.get_plugin(Plugins.Run)
run.register_executor_configuration(self, self.executor_configuration)

if is_module_installed("pylint"):
ccordoba12 marked this conversation as resolved.
Show resolved Hide resolved
self.run_action = run.create_run_in_executor_button(
RunContext.File,
self.NAME,
text=_("Run code analysis"),
tip=_("Run code analysis"),
icon=self.create_icon("pylint"),
shortcut_context='pylint',
register_shortcut=True,
add_to_menu=True
)

mainmenu = self.get_plugin(Plugins.MainMenu)
if mainmenu:
mainmenu.add_item_to_application_menu(
self.run_action, menu_id=ApplicationMenus.Source)

@on_plugin_teardown(plugin=Plugins.Editor)
def on_editor_teardown(self):
Expand All @@ -140,12 +170,6 @@ def on_editor_teardown(self):
widget.sig_edit_goto_requested.disconnect(editor.load)
editor.sig_editor_focus_changed.disconnect(self._set_filename)

pylint_act = self.get_action(PylintActions.AnalyzeCurrentFile)

# TODO: use new API when editor has migrated
pylint_act.setVisible(False)
editor.pythonfile_dependent_actions.remove(pylint_act)

@on_plugin_teardown(plugin=Plugins.Preferences)
def on_preferences_teardown(self):
preferences = self.get_plugin(Plugins.Preferences)
Expand All @@ -162,10 +186,16 @@ def on_projects_teardown(self):
def on_main_menu_teardown(self):
mainmenu = self.get_plugin(Plugins.MainMenu)
mainmenu.remove_item_from_application_menu(
PylintActions.AnalyzeCurrentFile,
self.run_action.name,
menu_id=ApplicationMenus.Source
)

@on_plugin_teardown(plugin=Plugins.Run)
def on_run_teardown(self):
run = self.get_plugin(Plugins.Run)
run.deregister_executor_configuration(
self, self.executor_configuration)

# --- Private API
# ------------------------------------------------------------------------
@Slot()
Expand Down Expand Up @@ -209,6 +239,19 @@ def get_filename(self):
"""
return self.get_widget().get_filename()

@run_execute(context=RunContext.File)
def run_file(
self, input: RunConfiguration,
conf: ExtendedRunExecutionParameters) -> List[PossibleRunResult]:
ccordoba12 marked this conversation as resolved.
Show resolved Hide resolved
self.switch_to_plugin()

exec_params = conf['params']
cwd_opts = exec_params['working_dir']

run_input: FileRun = input['run_input']
filename = run_input['path']
self.start_code_analysis(filename)

def start_code_analysis(self, filename=None):
"""
Perform code analysis for given `filename`.
Expand Down
23 changes: 13 additions & 10 deletions spyder/plugins/run/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ def __init__(self, parent=None):
common_layout.addWidget(self.clo_edit, 3, 1)

# --- Working directory ---
wdir_group = QGroupBox(_("Working directory settings"))
wdir_group.setDisabled(True)
self.wdir_group = QGroupBox(_("Working directory settings"))
self.wdir_group.setDisabled(True)

self.run_custom_config_radio.toggled.connect(wdir_group.setEnabled)
self.run_custom_config_radio.toggled.connect(self.wdir_group.setEnabled)

wdir_layout = QVBoxLayout(wdir_group)
wdir_layout = QVBoxLayout(self.wdir_group)

self.file_dir_radio = QRadioButton(FILE_DIR)
wdir_layout.addWidget(self.file_dir_radio)
Expand Down Expand Up @@ -302,7 +302,7 @@ def __init__(self, parent=None):
layout.addWidget(self.run_custom_config_radio)
layout.addWidget(interpreter_group)
layout.addWidget(common_group)
layout.addWidget(wdir_group)
layout.addWidget(self.wdir_group)
layout.addWidget(self.firstrun_cb)
layout.addStretch(100)

Expand Down Expand Up @@ -584,13 +584,13 @@ def setup(self):
executor_group.setLayout(executor_layout)

# --- Working directory ---
wdir_group = QGroupBox(_("Working directory settings"))
# wdir_group.setDisabled(True)
executor_layout.addWidget(wdir_group)
self.wdir_group = QGroupBox(_("Working directory settings"))
# self.wdir_group.setDisabled(True)
steff456 marked this conversation as resolved.
Show resolved Hide resolved
executor_layout.addWidget(self.wdir_group)

# self.run_custom_config_radio.toggled.connect(wdir_group.setEnabled)
# self.run_custom_config_radio.toggled.connect(self.wdir_group.setEnabled)
steff456 marked this conversation as resolved.
Show resolved Hide resolved

wdir_layout = QVBoxLayout(wdir_group)
wdir_layout = QVBoxLayout(self.wdir_group)

self.file_dir_radio = QRadioButton(FILE_DIR)
wdir_layout.addWidget(self.file_dir_radio)
Expand Down Expand Up @@ -727,6 +727,9 @@ def display_executor_configuration(self, index: int):

exec_tuple = self.executors_model.get_selected_run_executor(index)
executor_name, executor_info = exec_tuple
enable_cwd = executor_info['requires_cwd']
self.wdir_group.setEnabled(enable_cwd)

ConfigWidget = (executor_info['configuration_widget'] or
RunExecutorConfigurationGroup)

Expand Down