-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implements linting configuration #599
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
Changes from all commits
7675901
eb42669
2756974
c2c1ced
a108c96
14864a5
0ed51d6
51b544c
3cd11e6
82e0ad1
9295c1a
06eb1a5
e9db8e0
d12ca03
d8ab041
db75cd0
9ab2c47
d587485
1da5e0a
7668cee
1ac4932
2aa5a6c
5db31bd
560d2af
c71024d
31aa087
593ae05
e6d69bb
b5a23d3
cd200f7
7c33228
c4a6b90
f85b848
37c210b
61a5650
a10305e
bfcae78
42a5f79
e4ba322
7baec1a
9cb43e7
5a9c3fd
9800c4a
3205d33
de6a59c
c374a43
d1f429b
7eca943
595f63c
86e3e05
c02bd84
c15fdb2
29833eb
5c729db
a5aa108
7848d1b
2da60af
372c855
3800516
d3afee8
2f361f5
384ca3a
4dc23fb
82e4d52
8207953
8b701d2
c5ece0a
5972c11
11a4891
84562bf
b5c547a
ecb90a6
cd79d03
27a4244
34365a5
9071ea8
4e2c620
c090581
96fcba1
25c7d0a
c824c3e
9de1d81
36e2fa9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import * as child_process from 'child_process'; | |
import { EventEmitter } from 'events'; | ||
import * as path from 'path'; | ||
import * as vscode from 'vscode'; | ||
import { Uri } from 'vscode'; | ||
import { ConfigurationTarget, Uri } from 'vscode'; | ||
import { | ||
IAutoCompeteSettings, | ||
IFormattingSettings, | ||
|
@@ -61,19 +61,29 @@ export class PythonSettings extends EventEmitter implements IPythonSettings { | |
} | ||
// tslint:disable-next-line:function-name | ||
public static getInstance(resource?: Uri): PythonSettings { | ||
const workspaceFolder = resource ? vscode.workspace.getWorkspaceFolder(resource) : undefined; | ||
let workspaceFolderUri: Uri | undefined = workspaceFolder ? workspaceFolder.uri : undefined; | ||
if (!workspaceFolderUri && Array.isArray(vscode.workspace.workspaceFolders) && vscode.workspace.workspaceFolders.length > 0) { | ||
workspaceFolderUri = vscode.workspace.workspaceFolders[0].uri; | ||
} | ||
const workspaceFolderUri = PythonSettings.getSettingsUriAndTarget(resource).uri; | ||
const workspaceFolderKey = workspaceFolderUri ? workspaceFolderUri.fsPath : ''; | ||
|
||
if (!PythonSettings.pythonSettings.has(workspaceFolderKey)) { | ||
const settings = new PythonSettings(workspaceFolderUri); | ||
PythonSettings.pythonSettings.set(workspaceFolderKey, settings); | ||
} | ||
// tslint:disable-next-line:no-non-null-assertion | ||
return PythonSettings.pythonSettings.get(workspaceFolderKey)!; | ||
} | ||
|
||
public static getSettingsUriAndTarget(resource?: Uri): { uri: Uri | undefined, target: ConfigurationTarget } { | ||
const workspaceFolder = resource ? vscode.workspace.getWorkspaceFolder(resource) : undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use IWorkspaceService instead of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I prefer to use actual objects where possible since they work same way in tests as they do at run time. Mocking is more for something that cannot be instantiated easily for whatever reason (ex project system in big VS) or simulate things that are hard to change (such as registry data - which requires Windows and admin rights). |
||
let workspaceFolderUri: Uri | undefined = workspaceFolder ? workspaceFolder.uri : undefined; | ||
|
||
if (!workspaceFolderUri && Array.isArray(vscode.workspace.workspaceFolders) && vscode.workspace.workspaceFolders.length > 0) { | ||
workspaceFolderUri = vscode.workspace.workspaceFolders[0].uri; | ||
} | ||
|
||
const target = workspaceFolderUri ? ConfigurationTarget.WorkspaceFolder : ConfigurationTarget.Global; | ||
return { uri: workspaceFolderUri, target }; | ||
} | ||
|
||
// tslint:disable-next-line:function-name | ||
public static dispose() { | ||
if (!isTestExecution()) { | ||
|
@@ -138,7 +148,6 @@ export class PythonSettings extends EventEmitter implements IPythonSettings { | |
// Support for travis. | ||
this.linting = this.linting ? this.linting : { | ||
enabled: false, | ||
enabledWithoutWorkspace: false, | ||
ignorePatterns: [], | ||
flake8Args: [], flake8Enabled: false, flake8Path: 'flake', | ||
lintOnSave: false, maxNumberOfProblems: 100, | ||
|
@@ -167,7 +176,8 @@ export class PythonSettings extends EventEmitter implements IPythonSettings { | |
mypyCategorySeverity: { | ||
error: vscode.DiagnosticSeverity.Error, | ||
note: vscode.DiagnosticSeverity.Hint | ||
} | ||
}, | ||
pylintUseMinimalCheckers: false | ||
}; | ||
this.linting.pylintPath = getAbsolutePath(systemVariables.resolveAny(this.linting.pylintPath), workspaceRoot); | ||
this.linting.flake8Path = getAbsolutePath(systemVariables.resolveAny(this.linting.flake8Path), workspaceRoot); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use this command to disable linting as well?
Three buttons, last being the default VS Code button.
E.g.
Enable or disable linting [Enable Linting] [Disable Linting] [Close]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It currently shows
on/off
listThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍