Skip to content

Commit

Permalink
Use runStartupCommand instead of runMagicCommand (#8486)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored Dec 8, 2021
1 parent e9bed0b commit e7381f4
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 33 deletions.
1 change: 1 addition & 0 deletions news/3 Code Health/8485.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove `jupyter.runMagicCommands` (which has been deprecared for over a year) in favor of `runStartupCommands`.
1 change: 0 additions & 1 deletion src/client/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export class JupyterSettings implements IWatchableJupyterSettings {
public remoteDebuggerPort: number = 0;
public colorizeInputBox: boolean = false;
public addGotoCodeLenses: boolean = false;
public runMagicCommands: string = '';
public runStartupCommands: string | string[] = [];
public debugJustMyCode: boolean = false;
public defaultCellMarker: string = '';
Expand Down
1 change: 0 additions & 1 deletion src/client/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ export interface IJupyterSettings {
readonly remoteDebuggerPort: number;
readonly colorizeInputBox: boolean;
readonly addGotoCodeLenses: boolean;
readonly runMagicCommands: string;
readonly runStartupCommands: string | string[];
readonly debugJustMyCode: boolean;
readonly defaultCellMarker: string;
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/jupyter/kernels/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ export class Kernel implements IKernel {
private async runStartupCommands() {
const settings = this.configService.getSettings(this.resourceUri);
// Run any startup commands that we specified. Support the old form too
let setting = settings.runStartupCommands || settings.runMagicCommands;
let setting = settings.runStartupCommands;

// Convert to string in case we get an array of startup commands.
if (Array.isArray(setting)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class IntellisenseProvider implements INotebookLanguageClientProvider, IE
private getNotebookHeader(uri: Uri) {
const settings = this.configService.getSettings(uri);
// Run any startup commands that we specified. Support the old form too
let setting = settings.runStartupCommands || settings.runMagicCommands;
let setting = settings.runStartupCommands;

// Convert to string in case we get an array of startup commands.
if (Array.isArray(setting)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ suite('Migrate data science settings', () => {
"python.dataScience.remoteDebuggerPort": 0,
"python.dataScience.colorizeInputBox": true,
"python.dataScience.addGotoCodeLenses": true,
"python.dataScience.runMagicCommands": "foo",
"python.dataScience.runStartupCommands": ["foo", "bar"],
"python.dataScience.debugJustMyCode": true,
"python.dataScience.defaultCellMarker": "foo",
Expand Down Expand Up @@ -125,7 +124,6 @@ suite('Migrate data science settings', () => {
"jupyter.remoteDebuggerPort": 0,
"jupyter.colorizeInputBox": true,
"jupyter.addGotoCodeLenses": true,
"jupyter.runMagicCommands": "foo",
"jupyter.runStartupCommands": [
"foo",
"bar"
Expand Down
27 changes: 0 additions & 27 deletions src/test/datascience/interactiveWindow.vscode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
waitForLastCellToComplete
} from './helpers';
import {
assertNotHasTextOutputInVSCode,
clickOKForRestartPrompt,
closeNotebooksAndCleanUpAfterTests,
defaultNotebookTestTimeout,
Expand Down Expand Up @@ -369,32 +368,6 @@ ${actualCode}
assert.equal(actualCellText, actualCode);
});

async function runMagicCommandsTest(settingValue: boolean) {
const settings = vscode.workspace.getConfiguration('jupyter', null);
await settings.update('magicCommandsAsComments', settingValue);
const code = `# %%
#!%%time
print('hi')`;
const { activeInteractiveWindow } = await submitFromPythonFile(interactiveWindowProvider, code, disposables);
const lastCell = await waitForLastCellToComplete(activeInteractiveWindow);
await waitForTextOutput(lastCell, 'hi', undefined, false);
return lastCell;
}

test('jupyter.magicCommandsAsComments: `true`', async () => {
const lastCell = await runMagicCommandsTest(true);
await waitForTextOutput(lastCell, 'Wall time:', undefined, false);
});

test('jupyter.magicCommandsAsComments: `false`', async () => {
const lastCell = await runMagicCommandsTest(false);

// Magic should have remained commented
for (let outputIndex = 0; outputIndex < lastCell.outputs.length; outputIndex++) {
assertNotHasTextOutputInVSCode(lastCell, 'Wall time:', outputIndex, false);
}
});

// todo@joyceerhl
// test('Verify CWD', () => { });
// test('Multiple executes go to last active window', async () => { });
Expand Down

0 comments on commit e7381f4

Please sign in to comment.