Skip to content

Commit 271dbb5

Browse files
settings: Remove settings related to upstream python REPL (#5931)
<!-- Thank you for submitting a pull request. If this is your first pull request you can find information about contributing here: * https://github.com/posit-dev/positron/blob/main/CONTRIBUTING.md We recommend synchronizing your branch with the latest changes in the main branch by either pulling or rebasing. --> <!-- Describe briefly what problem this pull request resolves, or what new feature it introduces. Include screenshots of any new or altered UI. Link to any GitHub issues but avoid "magic" keywords that will automatically close the issue. If there are any details about your approach that are unintuitive or you want to draw attention to, please describe them here. --> This PR removes the `python.REPL.*` settings that come from the upstream, which aren't useful in Positron since we don't use the python REPL. ### Release Notes <!-- Optionally, replace `N/A` with text to be included in the next release notes. The `N/A` bullets are ignored. If you refer to one or more Positron issues, these issues are used to collect information about the feature or bugfix, such as the relevant language pack as determined by Github labels of type `lang: `. The note will automatically be tagged with the language. These notes are typically filled by the Positron team. If you are an external contributor, you may ignore this section. --> #### New Features - N/A #### Bug Fixes - Removed some redundant settings related to the upstream python REPL (#5602) ### QA Notes <!-- Add additional information for QA on how to validate the change, paying special attention to the level of risk, adjacent areas that could be affected by the change, and any important contextual information not present in the linked issues. --> I validated that these settings don't appear in the settings menu anymore.
1 parent fe3a53c commit 271dbb5

File tree

8 files changed

+116
-96
lines changed

8 files changed

+116
-96
lines changed

extensions/positron-python/package.json

-22
Original file line numberDiff line numberDiff line change
@@ -773,28 +773,6 @@
773773
"preview"
774774
]
775775
},
776-
"python.REPL.enableREPLSmartSend": {
777-
"default": true,
778-
"description": "%python.EnableREPLSmartSend.description%",
779-
"scope": "resource",
780-
"type": "boolean"
781-
},
782-
"python.REPL.sendToNativeREPL": {
783-
"default": false,
784-
"description": "%python.REPL.sendToNativeREPL.description%",
785-
"scope": "resource",
786-
"type": "boolean",
787-
"tags": [
788-
"onExP",
789-
"preview"
790-
]
791-
},
792-
"python.REPL.provideVariables": {
793-
"default": true,
794-
"description": "%python.REPL.provideVariables.description%",
795-
"scope": "resource",
796-
"type": "boolean"
797-
},
798776
"python.testing.autoTestDiscoverOnSaveEnabled": {
799777
"default": true,
800778
"description": "%python.testing.autoTestDiscoverOnSaveEnabled.description%",

extensions/positron-python/package.nls.json

-3
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@
8383
"python.poetryPath.description": "Path to the poetry executable.",
8484
"python.quietMode.description": "Start Positron's IPython shell in quiet mode, to suppress initial version and help messages (restart Positron to apply).",
8585
"python.pixiToolPath.description": "Path to the pixi executable.",
86-
"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.",
87-
"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.",
88-
"python.REPL.provideVariables.description": "Toggle to provide variables for the REPL variable view for the native REPL.",
8986
"python.tensorBoard.logDirectory.description": "Set this setting to your preferred TensorBoard log directory to skip log directory prompt when starting TensorBoard.",
9087
"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`.",
9188
"python.tensorBoard.logDirectory.deprecationMessage": "Tensorboard support has been moved to the extension Tensorboard extension. Instead use the setting `tensorBoard.logDirectory`.",

extensions/positron-python/src/client/repl/replUtils.ts

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ export async function getSelectedTextToExecute(textEditor: TextEditor): Promise<
3939
* @returns boolean - True if sendToNativeREPL setting is enabled, False otherwise.
4040
*/
4141
export function getSendToNativeREPLSetting(): boolean {
42+
// --- Start Positron ---
43+
// This setting is hidden in favor of the Positron console.
44+
// We leave the dead code path below to make merge conflicts easier to resolve.
45+
return false;
46+
// --- End Positron ---
4247
const uri = getActiveResource();
4348
const configuration = getConfiguration('python', uri);
4449
return configuration.get<boolean>('REPL.sendToNativeREPL', false);

extensions/positron-python/src/client/repl/variables/variablesProvider.ts

+5
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,10 @@ function getVariableResultCacheKey(uri: string, parent: Variable | undefined, st
155155
}
156156

157157
function isEnabled(resource?: Uri) {
158+
// --- Start Positron ---
159+
// This setting is hidden in favor of the Positron console.
160+
// We leave the dead code path below to make merge conflicts easier to resolve.
161+
return true;
162+
// --- End Positron ---
158163
return getConfiguration('python', resource).get('REPL.provideVariables');
159164
}

extensions/positron-python/src/client/terminals/codeExecution/helper.ts

+19-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { inject, injectable } from 'inversify';
66
import { l10n, Position, Range, TextEditor, Uri } from 'vscode';
77

88
import {
9-
IActiveResourceService,
9+
// --- Start Positron ---
10+
// IActiveResourceService,
11+
// --- End Positron ---
1012
IApplicationShell,
1113
ICommandManager,
1214
IDocumentManager,
@@ -36,7 +38,9 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {
3638

3739
private readonly commandManager: ICommandManager;
3840

39-
private activeResourceService: IActiveResourceService;
41+
// --- Start Positron ---
42+
// private activeResourceService: IActiveResourceService;
43+
// --- End Positron ---
4044

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

5561
public async normalizeLines(code: string, wholeFileContent?: string, resource?: Uri): Promise<string> {
@@ -92,12 +98,16 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {
9298
const startLineVal = activeEditor?.selection?.start.line ?? 0;
9399
const endLineVal = activeEditor?.selection?.end.line ?? 0;
94100
const emptyHighlightVal = activeEditor?.selection?.isEmpty ?? true;
95-
let smartSendSettingsEnabledVal = true;
96-
const configuration = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
97-
if (configuration) {
98-
const pythonSettings = configuration.getSettings(this.activeResourceService.getActiveResource());
99-
smartSendSettingsEnabledVal = pythonSettings.REPL.enableREPLSmartSend;
100-
}
101+
// --- Start Positron ---
102+
// This setting is hidden in favor of the Positron console.
103+
const smartSendSettingsEnabledVal = true;
104+
// let smartSendSettingsEnabledVal = true;
105+
// const configuration = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
106+
// if (configuration) {
107+
// const pythonSettings = configuration.getSettings(this.activeResourceService.getActiveResource());
108+
// smartSendSettingsEnabledVal = pythonSettings.REPL.enableREPLSmartSend;
109+
// }
110+
// --- End Positron ---
101111

102112
const input = JSON.stringify({
103113
code,

extensions/positron-python/src/client/terminals/codeExecution/terminalCodeExecution.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ export class TerminalCodeExecutionProvider implements ICodeExecutionService {
5656
const selection = await showWarningMessage(Diagnostics.invalidSmartSendMessage, Repl.disableSmartSend);
5757
traceInfo(`Selected file contains invalid Python or Deprecated Python 2 code`);
5858
if (selection === Repl.disableSmartSend) {
59-
this.configurationService.updateSetting('REPL.enableREPLSmartSend', false, resource);
59+
// --- Start Positron ---
60+
// This setting is hidden in favor of the Positron console.
61+
// this.configurationService.updateSetting('REPL.enableREPLSmartSend', false, resource);
62+
// --- End Positron ---
6063
}
6164
} else {
6265
await this.getTerminalService(resource).executeCommand(code);

extensions/positron-python/src/test/repl/variableProvider.test.ts

+19-15
Original file line numberDiff line numberDiff line change
@@ -111,26 +111,30 @@ suite('ReplVariablesProvider', () => {
111111
assert.equal(results[0].variable.expression, 'myObject');
112112
});
113113

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

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

120-
assert.isEmpty(results);
121-
});
121+
// const results = await provideVariables(undefined);
122122

123-
test('No change event from provider when disabled', async () => {
124-
enabled = false;
125-
let eventFired = false;
126-
provider.onDidChangeVariables(() => {
127-
eventFired = true;
128-
});
123+
// assert.isEmpty(results);
124+
// });
129125

130-
executionEventEmitter.fire();
126+
// test('No change event from provider when disabled', async () => {
127+
// enabled = false;
128+
// let eventFired = false;
129+
// provider.onDidChangeVariables(() => {
130+
// eventFired = true;
131+
// });
131132

132-
assert.isFalse(eventFired, 'event should not have fired');
133-
});
133+
// executionEventEmitter.fire();
134+
135+
// assert.isFalse(eventFired, 'event should not have fired');
136+
// });
137+
// --- End Positron ---
134138

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

extensions/positron-python/src/test/terminals/codeExecution/helper.test.ts

+64-46
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,30 @@
44
'use strict';
55

66
import { expect } from 'chai';
7-
import * as path from 'path';
7+
// --- Start Positron ---
8+
// import * as path from 'path';
9+
// --- End Positron ---
810
import { SemVer } from 'semver';
911
import * as TypeMoq from 'typemoq';
1012
import { Position, Range, Selection, TextDocument, TextEditor, TextLine, Uri } from 'vscode';
11-
import * as fs from '../../../client/common/platform/fs-paths';
13+
// --- Start Positron ---
14+
// import * as fs from '../../../client/common/platform/fs-paths';
15+
// --- End Positron ---
1216
import {
1317
IActiveResourceService,
1418
IApplicationShell,
1519
ICommandManager,
1620
IDocumentManager,
1721
IWorkspaceService,
1822
} from '../../../client/common/application/types';
19-
import { EXTENSION_ROOT_DIR, PYTHON_LANGUAGE } from '../../../client/common/constants';
23+
// --- Start Positron ---
24+
// import { EXTENSION_ROOT_DIR, PYTHON_LANGUAGE } from '../../../client/common/constants';
25+
import { PYTHON_LANGUAGE } from '../../../client/common/constants';
26+
// --- End Positron ---
2027
import '../../../client/common/extensions';
21-
import { ProcessService } from '../../../client/common/process/proc';
28+
// --- Start Positron ---
29+
// import { ProcessService } from '../../../client/common/process/proc';
30+
// --- End Positron ---
2231
import {
2332
IProcessService,
2433
IProcessServiceFactory,
@@ -34,7 +43,9 @@ import { CodeExecutionHelper } from '../../../client/terminals/codeExecution/hel
3443
import { ICodeExecutionHelper } from '../../../client/terminals/types';
3544
import { PYTHON_PATH } from '../../common';
3645

37-
const TEST_FILES_PATH = path.join(EXTENSION_ROOT_DIR, 'src', 'test', 'python_files', 'terminalExec');
46+
// --- Start Positron ---
47+
// const TEST_FILES_PATH = path.join(EXTENSION_ROOT_DIR, 'src', 'test', 'python_files', 'terminalExec');
48+
// --- End Positron ---
3849

3950
suite('Terminal - Code Execution Helper', () => {
4051
let activeResourceService: TypeMoq.IMock<IActiveResourceService>;
@@ -149,47 +160,54 @@ suite('Terminal - Code Execution Helper', () => {
149160
expect(execArgs).to.contain('normalizeSelection.py');
150161
});
151162

152-
async function ensureCodeIsNormalized(source: string, expectedSource: string) {
153-
configurationService
154-
.setup((c) => c.getSettings(TypeMoq.It.isAny()))
155-
.returns({
156-
REPL: {
157-
EnableREPLSmartSend: false,
158-
REPLSmartSend: false,
159-
},
160-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
161-
} as any);
162-
const actualProcessService = new ProcessService();
163-
processService
164-
.setup((p) => p.execObservable(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()))
165-
.returns((file, args, options) =>
166-
actualProcessService.execObservable.apply(actualProcessService, [file, args, options]),
167-
);
168-
const normalizedCode = await helper.normalizeLines(source);
169-
const normalizedExpected = expectedSource.replace(/\r\n/g, '\n');
170-
expect(normalizedCode).to.be.equal(normalizedExpected);
171-
}
172-
173-
['', '1', '2', '3', '4', '5', '6', '7', '8'].forEach((fileNameSuffix) => {
174-
test(`Ensure code is normalized (Sample${fileNameSuffix})`, async () => {
175-
configurationService
176-
.setup((c) => c.getSettings(TypeMoq.It.isAny()))
177-
.returns({
178-
REPL: {
179-
EnableREPLSmartSend: false,
180-
REPLSmartSend: false,
181-
},
182-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
183-
} as any);
184-
const code = await fs.readFile(path.join(TEST_FILES_PATH, `sample${fileNameSuffix}_raw.py`), 'utf8');
185-
const expectedCode = await fs.readFile(
186-
path.join(TEST_FILES_PATH, `sample${fileNameSuffix}_normalized_selection.py`),
187-
'utf8',
188-
);
189-
190-
await ensureCodeIsNormalized(code, expectedCode);
191-
});
192-
});
163+
// --- Start Positron ---
164+
// These tests are disabled because they require the EnableREPLSmartSend setting to be disabled.
165+
// In Positron that setting is hidden (see https://github.com/posit-dev/positron/pull/5931) so
166+
// it's always enabled.
167+
168+
// async function ensureCodeIsNormalized(source: string, expectedSource: string) {
169+
// configurationService
170+
// .setup((c) => c.getSettings(TypeMoq.It.isAny()))
171+
// .returns({
172+
// REPL: {
173+
// EnableREPLSmartSend: false,
174+
// REPLSmartSend: false,
175+
// },
176+
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
177+
// } as any);
178+
// const actualProcessService = new ProcessService();
179+
// processService
180+
// .setup((p) => p.execObservable(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()))
181+
// .returns((file, args, options) =>
182+
// actualProcessService.execObservable.apply(actualProcessService, [file, args, options]),
183+
// );
184+
// const normalizedCode = await helper.normalizeLines(source);
185+
// const normalizedExpected = expectedSource.replace(/\r\n/g, '\n');
186+
// expect(normalizedCode).to.be.equal(normalizedExpected);
187+
// }
188+
189+
// ['', '1', '2', '3', '4', '5', '6', '7', '8'].forEach((fileNameSuffix) => {
190+
// test(`Ensure code is normalized (Sample${fileNameSuffix})`, async () => {
191+
// configurationService
192+
// .setup((c) => c.getSettings(TypeMoq.It.isAny()))
193+
// .returns({
194+
// REPL: {
195+
// EnableREPLSmartSend: false,
196+
// REPLSmartSend: false,
197+
// },
198+
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
199+
// } as any);
200+
// const code = await fs.readFile(path.join(TEST_FILES_PATH, `sample${fileNameSuffix}_raw.py`), 'utf8');
201+
// const expectedCode = await fs.readFile(
202+
// path.join(TEST_FILES_PATH, `sample${fileNameSuffix}_normalized_selection.py`),
203+
// 'utf8',
204+
// );
205+
206+
// await ensureCodeIsNormalized(code, expectedCode);
207+
// });
208+
// });
209+
210+
// --- End Positron ---
193211

194212
test("Display message if there's no active file", async () => {
195213
documentManager.setup((doc) => doc.activeTextEditor).returns(() => undefined);

0 commit comments

Comments
 (0)