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

settings: Remove settings related to upstream python REPL #5931

Merged
merged 6 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
22 changes: 0 additions & 22 deletions extensions/positron-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -773,28 +773,6 @@
"preview"
]
},
"python.REPL.enableREPLSmartSend": {
"default": true,
"description": "%python.EnableREPLSmartSend.description%",
"scope": "resource",
"type": "boolean"
},
"python.REPL.sendToNativeREPL": {
"default": false,
"description": "%python.REPL.sendToNativeREPL.description%",
"scope": "resource",
"type": "boolean",
"tags": [
"onExP",
"preview"
]
},
"python.REPL.provideVariables": {
"default": true,
"description": "%python.REPL.provideVariables.description%",
"scope": "resource",
"type": "boolean"
},
"python.testing.autoTestDiscoverOnSaveEnabled": {
"default": true,
"description": "%python.testing.autoTestDiscoverOnSaveEnabled.description%",
Expand Down
13 changes: 5 additions & 8 deletions extensions/positron-python/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@
"python.poetryPath.description": "Path to the poetry executable.",
"python.quietMode.description": "Start Positron's IPython shell in quiet mode, to suppress initial version and help messages (restart Positron to apply).",
"python.pixiToolPath.description": "Path to the pixi executable.",
"python.EnableREPLSmartSend.description": "Toggle Smart Send for the Python REPL. Smart Send enables sending the smallest runnable block of code to the REPL on Shift+Enter and moves the cursor accordingly.",
"python.REPL.sendToNativeREPL.description": "Toggle to send code to Python REPL instead of the terminal on execution. Turning this on will change the behavior for both Smart Send and Run Selection/Line in the Context Menu.",
"python.REPL.provideVariables.description": "Toggle to provide variables for the REPL variable view for the native REPL.",
"python.tensorBoard.logDirectory.description": "Set this setting to your preferred TensorBoard log directory to skip log directory prompt when starting TensorBoard.",
"python.tensorBoard.logDirectory.markdownDeprecationMessage": "Tensorboard support has been moved to the extension [Tensorboard extension](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.tensorboard). Instead use the setting `tensorBoard.logDirectory`.",
"python.tensorBoard.logDirectory.deprecationMessage": "Tensorboard support has been moved to the extension Tensorboard extension. Instead use the setting `tensorBoard.logDirectory`.",
Expand All @@ -109,7 +106,7 @@
"python.installModulesInTerminal.description": "Whether to install Python modules (such as `ipykernel`) in the Terminal, instead of in a background process. Installing modules in the Terminal allows you to see the output of the installation command.",
"walkthrough.pythonWelcome.title": "Get Started with Python Development",
"walkthrough.pythonWelcome.description": "Your first steps to set up a Python project with all the powerful tools and features that the Python extension has to offer!",
"walkthrough.step.python.createPythonFile.title": "Create a Python file",
"walkthrough.step.python.createPythonFile.title": "Create a Python file",
"walkthrough.step.python.createPythonFolder.title": "Open a Python project folder",
"walkthrough.step.python.createPythonFile.description": {
"message": "[Open](command:toSide:workbench.action.files.openFile) or [create](command:toSide:workbench.action.files.newUntitledFile?%7B%22languageId%22%3A%22python%22%7D) a Python file - make sure to save it as \".py\".\n[Create Python File](command:toSide:workbench.action.files.newUntitledFile?%7B%22languageId%22%3A%22python%22%7D)",
Expand All @@ -121,7 +118,7 @@
},
"walkthrough.step.python.createPythonFolder.description": {
"message": "[Open](command:workbench.action.files.openFolder) or create a project folder.\n[Open Project Folder](command:workbench.action.files.openFolder)",
"comment": [
"comment": [
"{Locked='](command:workbench.action.files.openFolder'}",
"Do not translate the 'command:*' part inside of the '(..)'. It is an internal command syntax for VS Code",
"Please make sure there is no space between the right bracket and left parenthesis: ]( this is an internal syntax for links"
Expand Down Expand Up @@ -151,7 +148,7 @@
"walkthrough.step.python.createEnvironment.title": "Select or create a Python environment",
"walkthrough.step.python.createEnvironment.description": {
"message": "Create an environment for your Python project or use [Select Python Interpreter](command:python.setInterpreter) to select an existing one.\n[Create Environment](command:python.createEnvironment)\n**Tip**: Run the ``Python: Create Environment`` command in the [Command Palette](command:workbench.action.showCommands).",
"comment": [
"comment": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some funky formatting inconsistencies between positron and the positron-python (that hopefully should be resolved soon with #5838) that can result in this weirdness via format-on-save 😩

Are you able to remove these unrelated whitespace changes? I believe the easiest way is to command palette Format Document from inside the extensions/positron-python workspace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I originally kept them because they seemed like improvements, but I can remove them from this PR since they're unrelated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, we inherited the weirdness from the upstream. :)

"{Locked='](command:python.createEnvironment'}",
"{Locked='](command:workbench.action.showCommands'}",
"{Locked='](command:python.setInterpreter'}",
Expand All @@ -163,8 +160,8 @@
"walkthrough.step.python.runAndDebug.description": "Open your Python file and click on the play button on the top right of the editor, or press F5 when on the file and select \"Python File\" to run with the debugger. \n \n[Learn more](https://code.visualstudio.com/docs/python/python-tutorial#_run-hello-world)",
"walkthrough.step.python.learnMoreWithDS.title": "Keep exploring!",
"walkthrough.step.python.learnMoreWithDS.description": {
"message":"🎨 Explore all the features the Python extension has to offer by looking for \"Python\" in the [Command Palette](command:workbench.action.showCommands). \n 📈 Learn more about getting started with [data science](command:workbench.action.openWalkthrough?%7B%22category%22%3A%22ms-python.python%23pythonDataScienceWelcome%22%2C%22step%22%3A%22ms-python.python%23python.createNewNotebook%22%7D) in Python. \n ✨ Take a look at our [Release Notes](https://aka.ms/AA8dxtb) to learn more about the latest features. \n \n[Follow along with the Python Tutorial](https://aka.ms/AA8dqti)",
"comment":[
"message": "🎨 Explore all the features the Python extension has to offer by looking for \"Python\" in the [Command Palette](command:workbench.action.showCommands). \n 📈 Learn more about getting started with [data science](command:workbench.action.openWalkthrough?%7B%22category%22%3A%22ms-python.python%23pythonDataScienceWelcome%22%2C%22step%22%3A%22ms-python.python%23python.createNewNotebook%22%7D) in Python. \n ✨ Take a look at our [Release Notes](https://aka.ms/AA8dxtb) to learn more about the latest features. \n \n[Follow along with the Python Tutorial](https://aka.ms/AA8dqti)",
"comment": [
"{Locked='](command:workbench.action.showCommands'}",
"{Locked='](command:workbench.action.openWalkthrough?%7B%22category%22%3A%22ms-python.python%23pythonDataScienceWelcome%22%2C%22step%22%3A%22ms-python.python%23python.createNewNotebook%22%7D'}",
"Do not translate the 'command:*' part inside of the '(..)'. It is an internal command syntax for VS Code",
Expand Down
5 changes: 5 additions & 0 deletions extensions/positron-python/src/client/repl/replUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export async function getSelectedTextToExecute(textEditor: TextEditor): Promise<
* @returns boolean - True if sendToNativeREPL setting is enabled, False otherwise.
*/
export function getSendToNativeREPLSetting(): boolean {
// --- Start Positron ---
// This setting is hidden in favor of the Positron console.
// We leave the dead code path below to make merge conflicts easier to resolve.
return false;
// --- End Positron ---
const uri = getActiveResource();
const configuration = getConfiguration('python', uri);
return configuration.get<boolean>('REPL.sendToNativeREPL', false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,10 @@ function getVariableResultCacheKey(uri: string, parent: Variable | undefined, st
}

function isEnabled(resource?: Uri) {
// --- Start Positron ---
// This setting is hidden in favor of the Positron console.
// We leave the dead code path below to make merge conflicts easier to resolve.
return true;
// --- End Positron ---
return getConfiguration('python', resource).get('REPL.provideVariables');
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { inject, injectable } from 'inversify';
import { l10n, Position, Range, TextEditor, Uri } from 'vscode';

import {
IActiveResourceService,
// --- Start Positron ---
// IActiveResourceService,
// --- End Positron ---
IApplicationShell,
ICommandManager,
IDocumentManager,
Expand Down Expand Up @@ -36,7 +38,9 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {

private readonly commandManager: ICommandManager;

private activeResourceService: IActiveResourceService;
// --- Start Positron ---
// private activeResourceService: IActiveResourceService;
// --- End Positron ---

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error TS6133: 'configSettings' is declared but its value is never read.
Expand All @@ -49,7 +53,9 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {
this.interpreterService = serviceContainer.get<IInterpreterService>(IInterpreterService);
this.configSettings = serviceContainer.get<IConfigurationService>(IConfigurationService);
this.commandManager = serviceContainer.get<ICommandManager>(ICommandManager);
this.activeResourceService = this.serviceContainer.get<IActiveResourceService>(IActiveResourceService);
// --- Start Positron ---
// this.activeResourceService = this.serviceContainer.get<IActiveResourceService>(IActiveResourceService);
// --- End Positron ---
}

public async normalizeLines(code: string, wholeFileContent?: string, resource?: Uri): Promise<string> {
Expand Down Expand Up @@ -92,12 +98,16 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {
const startLineVal = activeEditor?.selection?.start.line ?? 0;
const endLineVal = activeEditor?.selection?.end.line ?? 0;
const emptyHighlightVal = activeEditor?.selection?.isEmpty ?? true;
let smartSendSettingsEnabledVal = true;
const configuration = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
if (configuration) {
const pythonSettings = configuration.getSettings(this.activeResourceService.getActiveResource());
smartSendSettingsEnabledVal = pythonSettings.REPL.enableREPLSmartSend;
}
// --- Start Positron ---
// This setting is hidden in favor of the Positron console.
const smartSendSettingsEnabledVal = true;
// let smartSendSettingsEnabledVal = true;
// const configuration = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
// if (configuration) {
// const pythonSettings = configuration.getSettings(this.activeResourceService.getActiveResource());
// smartSendSettingsEnabledVal = pythonSettings.REPL.enableREPLSmartSend;
// }
// --- End Positron ---
austin3dickey marked this conversation as resolved.
Show resolved Hide resolved

const input = JSON.stringify({
code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export class TerminalCodeExecutionProvider implements ICodeExecutionService {
const selection = await showWarningMessage(Diagnostics.invalidSmartSendMessage, Repl.disableSmartSend);
traceInfo(`Selected file contains invalid Python or Deprecated Python 2 code`);
if (selection === Repl.disableSmartSend) {
this.configurationService.updateSetting('REPL.enableREPLSmartSend', false, resource);
// --- Start Positron ---
// This setting is hidden in favor of the Positron console.
// this.configurationService.updateSetting('REPL.enableREPLSmartSend', false, resource);
// --- End Positron ---
}
} else {
await this.getTerminalService(resource).executeCommand(code);
Expand Down
34 changes: 19 additions & 15 deletions extensions/positron-python/src/test/repl/variableProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,26 +111,30 @@ suite('ReplVariablesProvider', () => {
assert.equal(results[0].variable.expression, 'myObject');
});

test('No variables are returned when variable provider is disabled', async () => {
enabled = false;
setVariablesForParent(undefined, [objectVariable]);
// --- Start Positron ---
// The setting for disabling the variable provider is hidden, so it's always enabled.

const results = await provideVariables(undefined);
// test('No variables are returned when variable provider is disabled', async () => {
// enabled = false;
// setVariablesForParent(undefined, [objectVariable]);

assert.isEmpty(results);
});
// const results = await provideVariables(undefined);

test('No change event from provider when disabled', async () => {
enabled = false;
let eventFired = false;
provider.onDidChangeVariables(() => {
eventFired = true;
});
// assert.isEmpty(results);
// });

executionEventEmitter.fire();
// test('No change event from provider when disabled', async () => {
// enabled = false;
// let eventFired = false;
// provider.onDidChangeVariables(() => {
// eventFired = true;
// });

assert.isFalse(eventFired, 'event should not have fired');
});
// executionEventEmitter.fire();

// assert.isFalse(eventFired, 'event should not have fired');
// });
// --- End Positron ---

test('Variables change event from provider should fire when execution happens', async () => {
let eventFired = false;
Expand Down
Loading
Loading