Skip to content

Commit

Permalink
Stop using legacy python.linting.mypyArgs (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorads authored Aug 7, 2023
1 parent b0bce6c commit 79ddc65
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
14 changes: 1 addition & 13 deletions src/common/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,7 @@ function resolveVariables(value: string[], workspace?: WorkspaceFolder): string[
function getArgs(namespace: string, workspace: WorkspaceFolder): string[] {
const config = getConfiguration(namespace, workspace.uri);
const args = config.get<string[]>('args', []);

if (args.length > 0) {
return args;
}

const legacyConfig = getConfiguration('python', workspace.uri);
const legacyArgs = legacyConfig.get<string[]>('linting.mypyArgs', []);
if (legacyArgs.length > 0) {
traceLog(`Using legacy Mypy args from 'python.linting.mypyArgs': ${legacyArgs.join(' ')}.`);
return legacyArgs;
}

return [];
return args;
}

function getPath(namespace: string, workspace: WorkspaceFolder): string[] {
Expand Down
13 changes: 4 additions & 9 deletions src/test/ts_tests/tests/common/settings.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ suite('Settings Tests', () => {
pythonConfigMock
.setup((c) => c.get('linting.mypyArgs', []))
.returns(() => [])
.verifiable(TypeMoq.Times.atLeastOnce());
.verifiable(TypeMoq.Times.never());
pythonConfigMock
.setup((c) => c.get('linting.mypyPath', ''))
.returns(() => 'mypy')
Expand Down Expand Up @@ -214,8 +214,8 @@ suite('Settings Tests', () => {

pythonConfigMock
.setup((c) => c.get<string[]>('linting.mypyArgs', []))
.returns(() => ['${userHome}', '${workspaceFolder}', '${workspaceFolder:workspace1}', '${cwd}'])
.verifiable(TypeMoq.Times.atLeastOnce());
.returns(() => [])
.verifiable(TypeMoq.Times.never());
pythonConfigMock
.setup((c) => c.get('linting.mypyPath', ''))
.returns(() => '${userHome}/bin/mypy')
Expand All @@ -237,12 +237,7 @@ suite('Settings Tests', () => {
const settings: ISettings = await getWorkspaceSettings('mypy', workspace1);

assert.deepStrictEqual(settings.cwd, `${process.env.HOME || process.env.USERPROFILE}/bin`);
assert.deepStrictEqual(settings.args, [
process.env.HOME || process.env.USERPROFILE,
workspace1.uri.fsPath,
workspace1.uri.fsPath,
process.cwd(),
]);
assert.deepStrictEqual(settings.args, []);
assert.deepStrictEqual(settings.importStrategy, 'useBundled');
assert.deepStrictEqual(settings.interpreter, []);
assert.deepStrictEqual(settings.path, [`${process.env.HOME || process.env.USERPROFILE}/bin/mypy`]);
Expand Down

0 comments on commit 79ddc65

Please sign in to comment.