PY-84905 Introduce run.with.py.tool registry key to enable running with specific run tools.

(cherry picked from commit d62efa40233864a49bf0c4c79395b9a726b0eca9)

IJ-MR-178963

GitOrigin-RevId: 8d564387328ebf00dd6a6124c69d1fdacf492069
This commit is contained in:
Timur Malanin
2025-10-20 21:08:19 +00:00
committed by intellij-monorepo-bot
parent 5c6fd25182
commit 266c5fa121
4 changed files with 13 additions and 4 deletions
@@ -198,6 +198,7 @@
overrides="true"/>
<registryKey key="python.test.autodetect.new.run.config" defaultValue="true" description="Python test autodetect configuration new UI"/>
<registryKey key="python.run.doctest.via.pytest.configuration" defaultValue="true" description="Run doctest via pytest configuration"/>
<registryKey key="run.with.py.tool" defaultValue="true" description="Run with Python tool"/>
<registryKey key="debugger.valueTooltipAutoShow" defaultValue="false" description="Auto show tooltip on mouse over." overrides="true"/>
<configurationType implementation="com.jetbrains.python.testing.PythonTestConfigurationType"/>
@@ -95,6 +95,7 @@ import java.util.function.Function;
import static com.intellij.execution.util.EnvFilesUtilKt.configureEnvsFromFiles;
import static com.jetbrains.python.run.PythonScriptCommandLineState.getExpandedWorkingDir;
import static com.jetbrains.python.run.features.PyRunToolExtKt.useRunTool;
import static com.jetbrains.python.run.features.PyRunToolProviderKt.getEnableRunTool;
/**
* Since this state is async, any method could be called on any thread
@@ -352,7 +353,7 @@ public abstract class PythonCommandLineState extends CommandLineState {
.toList();
PyRunToolParameters runToolParameters = null;
if (sdk != null) {
if (sdk != null && getEnableRunTool()) {
PyRunToolProvider runToolProvider = PyRunToolProvider.forSdk(sdk);
if (runToolProvider != null && useRunTool(myConfig, sdk)) {
runToolParameters = runToolProvider.getRunToolParameters();
@@ -12,6 +12,7 @@ import com.jetbrains.python.run.AbstractPythonRunConfiguration
import com.jetbrains.python.run.PyCommonFragmentsBuilder
import com.jetbrains.python.run.PythonRunConfigurationExtensionsManager
import com.jetbrains.python.run.features.PyRunToolProvider
import com.jetbrains.python.run.features.enableRunTool
import com.jetbrains.python.run.features.useRunTool
import java.awt.event.ComponentAdapter
import java.awt.event.ComponentEvent
@@ -31,9 +32,9 @@ abstract class AbstractPythonConfigurationFragmentedEditor<T : AbstractPythonRun
addInterpreterOptions(fragments)
addContentSourceRoots(fragments)
runConfiguration.sdk?.let { sdk ->
createRunToolTag(sdk)?.let { fragments.add(it) }
}
runConfiguration.sdk?.takeIf { enableRunTool }
?.let { createRunToolTag(it) }
?.let { fragments.add(it) }
customizeFragments(fragments)
fragments.add(PyEditorExtensionFragment())
@@ -3,10 +3,16 @@ package com.jetbrains.python.run.features
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.projectRoots.Sdk
import com.intellij.openapi.util.registry.Registry
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.annotations.Nls
import org.jetbrains.annotations.NonNls
/**
* Feature flag for Python "Run with …" tool integration.
*/
internal val enableRunTool: Boolean get() = Registry.`is`("run.with.py.tool")
@JvmInline
@ApiStatus.Internal
value class PyRunToolId(@param:NonNls val value: String)