| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1068,6 +1068,83 @@ | |||
| 1068 | 1068 | "Warning" | |
| 1069 | 1069 | ] | |
| 1070 | 1070 | }, | |
| 1071 | + "python.linting.pep8CategorySeverity.W": { | ||
| 1072 | + "type": "string", | ||
| 1073 | + "default": "Warning", | ||
| 1074 | + "description": "Severity of Pep8 message type 'W'.", | ||
| 1075 | + "enum": [ | ||
| 1076 | + "Hint", | ||
| 1077 | + "Error", | ||
| 1078 | + "Information", | ||
| 1079 | + "Warning" | ||
| 1080 | + ] | ||
| 1081 | + }, | ||
| 1082 | + "python.linting.pep8CategorySeverity.E": { | ||
| 1083 | + "type": "string", | ||
| 1084 | + "default": "Error", | ||
| 1085 | + "description": "Severity of Pep8 message type 'E'.", | ||
| 1086 | + "enum": [ | ||
| 1087 | + "Hint", | ||
| 1088 | + "Error", | ||
| 1089 | + "Information", | ||
| 1090 | + "Warning" | ||
| 1091 | + ] | ||
| 1092 | + }, | ||
| 1093 | + "python.linting.flake8CategorySeverity.F": { | ||
| 1094 | + "type": "string", | ||
| 1095 | + "default": "Error", | ||
| 1096 | + "description": "Severity of Flake8 message type 'F'.", | ||
| 1097 | + "enum": [ | ||
| 1098 | + "Hint", | ||
| 1099 | + "Error", | ||
| 1100 | + "Information", | ||
| 1101 | + "Warning" | ||
| 1102 | + ] | ||
| 1103 | + }, | ||
| 1104 | + "python.linting.flake8CategorySeverity.E": { | ||
| 1105 | + "type": "string", | ||
| 1106 | + "default": "Error", | ||
| 1107 | + "description": "Severity of Flake8 message type 'E'.", | ||
| 1108 | + "enum": [ | ||
| 1109 | + "Hint", | ||
| 1110 | + "Error", | ||
| 1111 | + "Information", | ||
| 1112 | + "Warning" | ||
| 1113 | + ] | ||
| 1114 | + }, | ||
| 1115 | + "python.linting.flake8CategorySeverity.W": { | ||
| 1116 | + "type": "string", | ||
| 1117 | + "default": "Warning", | ||
| 1118 | + "description": "Severity of Flake8 message type 'W'.", | ||
| 1119 | + "enum": [ | ||
| 1120 | + "Hint", | ||
| 1121 | + "Error", | ||
| 1122 | + "Information", | ||
| 1123 | + "Warning" | ||
| 1124 | + ] | ||
| 1125 | + }, | ||
| 1126 | + "python.linting.mypyCategorySeverity.error": { | ||
| 1127 | + "type": "string", | ||
| 1128 | + "default": "Error", | ||
| 1129 | + "description": "Severity of Mypy message type 'Error'.", | ||
| 1130 | + "enum": [ | ||
| 1131 | + "Hint", | ||
| 1132 | + "Error", | ||
| 1133 | + "Information", | ||
| 1134 | + "Warning" | ||
| 1135 | + ] | ||
| 1136 | + }, | ||
| 1137 | + "python.linting.mypyCategorySeverity.note": { | ||
| 1138 | + "type": "string", | ||
| 1139 | + "default": "Information", | ||
| 1140 | + "description": "Severity of Mypy message type 'Note'.", | ||
| 1141 | + "enum": [ | ||
| 1142 | + "Hint", | ||
| 1143 | + "Error", | ||
| 1144 | + "Information", | ||
| 1145 | + "Warning" | ||
| 1146 | + ] | ||
| 1147 | + }, | ||
| 1071 | 1148 | "python.linting.prospectorPath": { | |
| 1072 | 1149 | "type": "string", | |
| 1073 | 1150 | "default": "prospector", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ | |||
| 4 | 4 | import sys | |
| 5 | 5 | import json | |
| 6 | 6 | import traceback | |
| 7 | + import platform | ||
| 7 | 8 | ||
| 8 | 9 | WORD_RE = re.compile(r'\w') | |
| 9 | 10 | jediPreview = False | |
@@ -33,6 +34,17 @@ class JediCompletion(object): | |||
| 33 | 34 | def __init__(self): | |
| 34 | 35 | self.default_sys_path = sys.path | |
| 35 | 36 | self._input = io.open(sys.stdin.fileno(), encoding='utf-8') | |
| 37 | + if (os.path.sep == '/') and (platform.uname()[2].find('Microsoft') > -1): | ||
| 38 | + # WSL; does not support UNC paths | ||
| 39 | + self.drive_mount = '/mnt/' | ||
| 40 | + elif sys.platform == 'cygwin': | ||
| 41 | + # cygwin | ||
| 42 | + self.drive_mount = '/cygdrive/' | ||
| 43 | + else: | ||
| 44 | + # Do no normalization, e.g. Windows build of Python. | ||
| 45 | + # Could add additional test: ((os.path.sep == '/') and os.path.isdir('/mnt/c')) | ||
| 46 | + # However, this may have more false positives trying to identify Windows/*nix hybrids | ||
| 47 | + self.drive_mount = '' | ||
| 36 | 48 | ||
| 37 | 49 | def _get_definition_type(self, definition): | |
| 38 | 50 | is_built_in = definition.in_builtin_module | |
@@ -533,13 +545,33 @@ def _set_request_config(self, config): | |||
| 533 | 545 | if path and path not in sys.path: | |
| 534 | 546 | sys.path.insert(0, path) | |
| 535 | 547 | ||
| 548 | + def _normalize_request_path(self, request): | ||
| 549 | + """Normalize any Windows paths received by a *nix build of | ||
| 550 | + Python. Does not alter the reverse os.path.sep=='\\', | ||
| 551 | + i.e. *nix paths received by a Windows build of Python. | ||
| 552 | + """ | ||
| 553 | + if 'path' in request: | ||
| 554 | + if not self.drive_mount: | ||
| 555 | + return | ||
| 556 | + newPath = request['path'].replace('\\', '/') | ||
| 557 | + if newPath[0:1] == '/': | ||
| 558 | + # is absolute path with no drive letter | ||
| 559 | + request['path'] = newPath | ||
| 560 | + elif newPath[1:2] == ':': | ||
| 561 | + # is path with drive letter, only absolute can be mapped | ||
| 562 | + request['path'] = self.drive_mount + newPath[0:1].lower() + newPath[2:] | ||
| 563 | + else: | ||
| 564 | + # is relative path | ||
| 565 | + request['path'] = newPath | ||
| 566 | + | ||
| 536 | 567 | def _process_request(self, request): | |
| 537 | 568 | """Accept serialized request from VSCode and write response. | |
| 538 | 569 | """ | |
| 539 | 570 | request = self._deserialize(request) | |
| 540 | 571 | ||
| 541 | 572 | self._set_request_config(request.get('config', {})) | |
| 542 | 573 | ||
| 574 | + self._normalize_request_path(request) | ||
| 543 | 575 | path = self._get_top_level_module(request.get('path', '')) | |
| 544 | 576 | if path not in sys.path: | |
| 545 | 577 | sys.path.insert(0, path) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -109,7 +109,7 @@ | |||
| 109 | 109 | """ | |
| 110 | 110 | ||
| 111 | 111 | if platform.system().lower() == 'windows': | |
| 112 | - _cache_directory = os.path.join(os.getenv('APPDATA') or '~', 'Jedi', | ||
| 112 | + _cache_directory = os.path.join(os.getenv('LOCALAPPDATA') or '~', 'Jedi', | ||
| 113 | 113 | 'Jedi') | |
| 114 | 114 | elif platform.system().lower() == 'darwin': | |
| 115 | 115 | _cache_directory = os.path.join('~', 'Library', 'Caches', 'Jedi') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,6 +49,19 @@ export interface IPylintCategorySeverity { | |||
| 49 | 49 | error: vscode.DiagnosticSeverity; | |
| 50 | 50 | fatal: vscode.DiagnosticSeverity; | |
| 51 | 51 | } | |
| 52 | + export interface IPep8CategorySeverity { | ||
| 53 | + W: vscode.DiagnosticSeverity; | ||
| 54 | + E: vscode.DiagnosticSeverity; | ||
| 55 | + } | ||
| 56 | + export interface Flake8CategorySeverity { | ||
| 57 | + F: vscode.DiagnosticSeverity; | ||
| 58 | + E: vscode.DiagnosticSeverity; | ||
| 59 | + W: vscode.DiagnosticSeverity; | ||
| 60 | + } | ||
| 61 | + export interface IMypyCategorySeverity { | ||
| 62 | + error: vscode.DiagnosticSeverity; | ||
| 63 | + note: vscode.DiagnosticSeverity; | ||
| 64 | + } | ||
| 52 | 65 | export interface ILintingSettings { | |
| 53 | 66 | enabled: boolean; | |
| 54 | 67 | enabledWithoutWorkspace: boolean; | |
@@ -69,6 +82,9 @@ export interface ILintingSettings { | |||
| 69 | 82 | lintOnSave: boolean; | |
| 70 | 83 | maxNumberOfProblems: number; | |
| 71 | 84 | pylintCategorySeverity: IPylintCategorySeverity; | |
| 85 | + pep8CategorySeverity: IPep8CategorySeverity; | ||
| 86 | + flake8CategorySeverity: Flake8CategorySeverity; | ||
| 87 | + mypyCategorySeverity: IMypyCategorySeverity; | ||
| 72 | 88 | prospectorPath: string; | |
| 73 | 89 | pylintPath: string; | |
| 74 | 90 | pep8Path: string; | |
@@ -183,6 +199,19 @@ export class PythonSettings extends EventEmitter implements IPythonSettings { | |||
| 183 | 199 | fatal: vscode.DiagnosticSeverity.Error, | |
| 184 | 200 | refactor: vscode.DiagnosticSeverity.Hint, | |
| 185 | 201 | warning: vscode.DiagnosticSeverity.Warning | |
| 202 | + }, | ||
| 203 | + pep8CategorySeverity: { | ||
| 204 | + E: vscode.DiagnosticSeverity.Error, | ||
| 205 | + W: vscode.DiagnosticSeverity.Warning | ||
| 206 | + }, | ||
| 207 | + flake8CategorySeverity: { | ||
| 208 | + F: vscode.DiagnosticSeverity.Error, | ||
| 209 | + E: vscode.DiagnosticSeverity.Error, | ||
| 210 | + W: vscode.DiagnosticSeverity.Warning | ||
| 211 | + }, | ||
| 212 | + mypyCategorySeverity: { | ||
| 213 | + error: vscode.DiagnosticSeverity.Error, | ||
| 214 | + note: vscode.DiagnosticSeverity.Hint | ||
| 186 | 215 | } | |
| 187 | 216 | }; | |
| 188 | 217 | this.linting.pylintPath = getAbsolutePath(systemVariables.resolveAny(this.linting.pylintPath), workspaceRoot); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,6 +65,29 @@ export abstract class BaseLinter { | |||
| 65 | 65 | public abstract isEnabled(): Boolean; | |
| 66 | 66 | public abstract runLinter(document: vscode.TextDocument, cancellation: vscode.CancellationToken): Promise<ILintMessage[]>; | |
| 67 | 67 | ||
| 68 | + protected parseMessagesSeverity(error: string, categorySeverity: any): LintMessageSeverity { | ||
| 69 | + if (categorySeverity[error]) { | ||
| 70 | + let severityName = categorySeverity[error]; | ||
| 71 | + switch (severityName) { | ||
| 72 | + case 'Error': | ||
| 73 | + return LintMessageSeverity.Error; | ||
| 74 | + case 'Hint': | ||
| 75 | + return LintMessageSeverity.Hint; | ||
| 76 | + case 'Information': | ||
| 77 | + return LintMessageSeverity.Information; | ||
| 78 | + case 'Warning': | ||
| 79 | + return LintMessageSeverity.Warning; | ||
| 80 | + default: { | ||
| 81 | + if (LintMessageSeverity[severityName]) { | ||
| 82 | + return <LintMessageSeverity><any>LintMessageSeverity[severityName]; | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + return LintMessageSeverity.Information; | ||
| 89 | + } | ||
| 90 | + | ||
| 68 | 91 | protected run(command: string, args: string[], document: vscode.TextDocument, cwd: string, cancellation: vscode.CancellationToken, regEx: string = REGEX): Promise<ILintMessage[]> { | |
| 69 | 92 | let outputChannel = this.outputChannel; | |
| 70 | 93 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,20 +12,6 @@ export class Linter extends baseLinter.BaseLinter { | |||
| 12 | 12 | super('flake8', Product.flake8, outputChannel, workspaceRootPath); | |
| 13 | 13 | } | |
| 14 | 14 | ||
| 15 | - private parseMessagesCodeSeverity(error: string): baseLinter.LintMessageSeverity { | ||
| 16 | - | ||
| 17 | - let category_letter = error[0]; | ||
| 18 | - switch (category_letter) { | ||
| 19 | - case 'F': | ||
| 20 | - case 'E': | ||
| 21 | - return baseLinter.LintMessageSeverity.Error; | ||
| 22 | - case 'W': | ||
| 23 | - return baseLinter.LintMessageSeverity.Warning; | ||
| 24 | - default: | ||
| 25 | - return baseLinter.LintMessageSeverity.Information; | ||
| 26 | - } | ||
| 27 | - } | ||
| 28 | - | ||
| 29 | 15 | public isEnabled(): Boolean { | |
| 30 | 16 | return this.pythonSettings.linting.flake8Enabled; | |
| 31 | 17 | } | |
@@ -37,9 +23,9 @@ export class Linter extends baseLinter.BaseLinter { | |||
| 37 | 23 | let flake8Path = this.pythonSettings.linting.flake8Path; | |
| 38 | 24 | let flake8Args = Array.isArray(this.pythonSettings.linting.flake8Args) ? this.pythonSettings.linting.flake8Args : []; | |
| 39 | 25 | return new Promise<baseLinter.ILintMessage[]>((resolve, reject) => { | |
| 40 | - this.run(flake8Path, flake8Args.concat(['--format=%(row)d,%(col)d,%(code)s,%(code)s:%(text)s', document.uri.fsPath]), document, this.workspaceRootPath, cancellation).then(messages => { | ||
| 26 | + this.run(flake8Path, flake8Args.concat(['--format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s', document.uri.fsPath]), document, this.workspaceRootPath, cancellation).then(messages => { | ||
| 41 | 27 | messages.forEach(msg => { | |
| 42 | - msg.severity = this.parseMessagesCodeSeverity(msg.type); | ||
| 28 | + msg.severity = this.parseMessagesSeverity(msg.type, this.pythonSettings.linting.flake8CategorySeverity); | ||
| 43 | 29 | }); | |
| 44 | 30 | ||
| 45 | 31 | resolve(messages); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,19 +11,6 @@ export class Linter extends baseLinter.BaseLinter { | |||
| 11 | 11 | constructor(outputChannel: OutputChannel, workspaceRootPath?: string) { | |
| 12 | 12 | super('mypy', Product.mypy, outputChannel, workspaceRootPath); | |
| 13 | 13 | } | |
| 14 | - private parseMessagesSeverity(category: string): baseLinter.LintMessageSeverity { | ||
| 15 | - switch (category) { | ||
| 16 | - case 'error': { | ||
| 17 | - return baseLinter.LintMessageSeverity.Error; | ||
| 18 | - } | ||
| 19 | - case 'note': { | ||
| 20 | - return baseLinter.LintMessageSeverity.Hint; | ||
| 21 | - } | ||
| 22 | - default: { | ||
| 23 | - return baseLinter.LintMessageSeverity.Information; | ||
| 24 | - } | ||
| 25 | - } | ||
| 26 | - } | ||
| 27 | 14 | ||
| 28 | 15 | public isEnabled(): Boolean { | |
| 29 | 16 | return this.pythonSettings.linting.mypyEnabled; | |
@@ -38,7 +25,7 @@ export class Linter extends baseLinter.BaseLinter { | |||
| 38 | 25 | return new Promise<baseLinter.ILintMessage[]>((resolve, reject) => { | |
| 39 | 26 | this.run(mypyPath, mypyArgs.concat([document.uri.fsPath]), document, this.workspaceRootPath, cancellation, REGEX).then(messages => { | |
| 40 | 27 | messages.forEach(msg => { | |
| 41 | - msg.severity = this.parseMessagesSeverity(msg.type); | ||
| 28 | + msg.severity = this.parseMessagesSeverity(msg.type, this.pythonSettings.linting.mypyCategorySeverity); | ||
| 42 | 29 | msg.code = msg.type; | |
| 43 | 30 | }); | |
| 44 | 31 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,19 +12,6 @@ export class Linter extends baseLinter.BaseLinter { | |||
| 12 | 12 | super('pep8', Product.pep8, outputChannel, workspaceRootPath); | |
| 13 | 13 | } | |
| 14 | 14 | ||
| 15 | - private parseMessagesCodeSeverity(error: string): baseLinter.LintMessageSeverity { | ||
| 16 | - | ||
| 17 | - let category_letter = error[0]; | ||
| 18 | - switch (category_letter) { | ||
| 19 | - case 'E': | ||
| 20 | - return baseLinter.LintMessageSeverity.Error; | ||
| 21 | - case 'W': | ||
| 22 | - return baseLinter.LintMessageSeverity.Warning; | ||
| 23 | - default: | ||
| 24 | - return baseLinter.LintMessageSeverity.Information; | ||
| 25 | - } | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | 15 | public isEnabled(): Boolean { | |
| 29 | 16 | return this.pythonSettings.linting.pep8Enabled; | |
| 30 | 17 | } | |
@@ -36,9 +23,9 @@ export class Linter extends baseLinter.BaseLinter { | |||
| 36 | 23 | let pep8Path = this.pythonSettings.linting.pep8Path; | |
| 37 | 24 | let pep8Args = Array.isArray(this.pythonSettings.linting.pep8Args) ? this.pythonSettings.linting.pep8Args : []; | |
| 38 | 25 | return new Promise<baseLinter.ILintMessage[]>(resolve => { | |
| 39 | - this.run(pep8Path, pep8Args.concat(['--format=%(row)d,%(col)d,%(code)s,%(code)s:%(text)s', document.uri.fsPath]), document, this.workspaceRootPath, cancellation).then(messages => { | ||
| 26 | + this.run(pep8Path, pep8Args.concat(['--format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s', document.uri.fsPath]), document, this.workspaceRootPath, cancellation).then(messages => { | ||
| 40 | 27 | messages.forEach(msg => { | |
| 41 | - msg.severity = this.parseMessagesCodeSeverity(msg.type); | ||
| 28 | + msg.severity = this.parseMessagesSeverity(msg.type, this.pythonSettings.linting.pep8CategorySeverity); | ||
| 42 | 29 | }); | |
| 43 | 30 | ||
| 44 | 31 | resolve(messages); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,29 +10,6 @@ export class Linter extends baseLinter.BaseLinter { | |||
| 10 | 10 | super('pylint', Product.pylint, outputChannel, workspaceRootPath); | |
| 11 | 11 | } | |
| 12 | 12 | ||
| 13 | - private parseMessagesSeverity(category: string): baseLinter.LintMessageSeverity { | ||
| 14 | - if (this.pythonSettings.linting.pylintCategorySeverity[category]) { | ||
| 15 | - let severityName = this.pythonSettings.linting.pylintCategorySeverity[category]; | ||
| 16 | - switch (severityName) { | ||
| 17 | - case 'Error': | ||
| 18 | - return baseLinter.LintMessageSeverity.Error; | ||
| 19 | - case 'Hint': | ||
| 20 | - return baseLinter.LintMessageSeverity.Hint; | ||
| 21 | - case 'Information': | ||
| 22 | - return baseLinter.LintMessageSeverity.Information; | ||
| 23 | - case 'Warning': | ||
| 24 | - return baseLinter.LintMessageSeverity.Warning; | ||
| 25 | - default: { | ||
| 26 | - if (baseLinter.LintMessageSeverity[severityName]) { | ||
| 27 | - return <baseLinter.LintMessageSeverity><any>baseLinter.LintMessageSeverity[severityName]; | ||
| 28 | - } | ||
| 29 | - } | ||
| 30 | - } | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - return baseLinter.LintMessageSeverity.Information; | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | 13 | public isEnabled(): Boolean { | |
| 37 | 14 | return this.pythonSettings.linting.pylintEnabled; | |
| 38 | 15 | } | |
@@ -46,7 +23,7 @@ export class Linter extends baseLinter.BaseLinter { | |||
| 46 | 23 | return new Promise<baseLinter.ILintMessage[]>((resolve, reject) => { | |
| 47 | 24 | this.run(pylintPath, pylintArgs.concat(['--msg-template=\'{line},{column},{category},{msg_id}:{msg}\'', '--reports=n', '--output-format=text', document.uri.fsPath]), document, this.workspaceRootPath, cancellation).then(messages => { | |
| 48 | 25 | messages.forEach(msg => { | |
| 49 | - msg.severity = this.parseMessagesSeverity(msg.type); | ||
| 26 | + msg.severity = this.parseMessagesSeverity(msg.type, this.pythonSettings.linting.pylintCategorySeverity); | ||
| 50 | 27 | }); | |
| 51 | 28 | ||
| 52 | 29 | resolve(messages); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,3 @@ | |||
| 1 | - from third_party import lib0 | ||
| 2 | - from third_party import lib1 | ||
| 3 | - from third_party import lib2 | ||
| 4 | - from third_party import lib3 | ||
| 5 | - from third_party import lib4 | ||
| 6 | - from third_party import lib5 | ||
| 7 | - from third_party import lib6 | ||
| 8 | - from third_party import lib7 | ||
| 9 | - from third_party import lib8 | ||
| 10 | - from third_party import lib9 | ||
| 1 | + from third_party import (lib1, lib2, lib3, | ||
| 2 | + lib4, lib5, lib6, | ||
| 3 | + lib7, lib8, lib9) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments