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

Use runStartupCommand instead of runMagicCommand #8486

Merged
merged 1 commit into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
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`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we remove it from the package.json? I thought VS code did that with deprecated stuff eventually?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It never existed in the package.json, hence the PR, it hasn't been there for a long time.

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