GeezerVison is showing github.com — Unit testing, debugger fix and flake8 · lfrodrigues/pythonVSCode@9535c91
File treeExpand file treeCollapse file tree Open diff view settings Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .vscode/launch.json +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 21 | 21 | "request": "attach", | 22 | 22 | "sourceMaps": true, | 23 | 23 | "port": 6004 | | 24 | + }, | | 25 | + { | | 26 | + "name": "Attach to python debug server", | | 27 | + "type": "node", | | 28 | + "request": "launch", | | 29 | + "runtimeArgs": [ | | 30 | + "--harmony" | | 31 | + ], | | 32 | + "program": "./out/client/debugger/main.js", | | 33 | + "stopOnEntry": false, | | 34 | + "args": [ | | 35 | + "--server=4711" | | 36 | + ], | | 37 | + "sourceMaps": true, | | 38 | + "outDir": "./out/client" | 24 | 39 | } | 25 | 40 | ] | 26 | 41 | } |
Collapse file Copy file name to clipboardExpand all lines: README.md +35-19Lines changed: 35 additions & 19 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | # Python | 2 | | -Linting, Debugging, Intellisense, auto-completion, code formatting, snippets, and more. | | 2 | +Linting, Debugging, Intellisense, auto-completion, code formatting, snippets, unit testing, and more. | 3 | 3 | Works on both Windows and Mac. | 4 | 4 |
| 5 | 5 | ##Features | 6 | | -* Linting (PyLint, Pep8 with support for config files) | | 6 | +* Linting (PyLint, Pep8, Flake8 with config files) | 7 | 7 | * Intellisense and autocompletion | 8 | | -* Code formatting (autopep8, yapf, with support for config files) | | 8 | +* Code formatting (autopep8, yapf, with config files) | 9 | 9 | * Renaming, Viewing references, Going to definitions, Go to Symbols | 10 | 10 | * View signature and similar by hovering over a function or method | 11 | 11 | * Debugging with support for local & global variables, arguments, expressions, watch window, stack information, break points | | 12 | +* Unit testing (unittests and nosetests, with config files) | 12 | 13 | * Sorting imports | 13 | 14 | * Snippets | 14 | 15 |
| 15 | | -## Issues, Feedback and Suggestions | 16 | | -[Gitbub Issues](https://github.com/DonJayamanne/pythonVSCode/issues) | | 16 | +## Issues and Feature Requests | | 17 | +[Github Issues](https://github.com/DonJayamanne/pythonVSCode/issues) | 17 | 18 |
| 18 | 19 | ## Feature Details (with confiuration) | 19 | 20 | * IDE Features | @@ -25,26 +26,30 @@ Works on both Windows and Mac. | 25 | 26 | * Intellisense and Autocomplete | 26 | 27 | * - Full intellisense | 27 | 28 | * - Support for docstring | | 29 | +* - Ability to include custom module paths (e.g. include paths for libraries like Google App Engine, etc) | | 30 | +* - - Use the setting python.autoComplete.extraPaths = [] | 28 | 31 | * Code formatting | 29 | 32 | * - Use either yapf or autopep8 for code formatting (defaults to autopep8) | 30 | 33 | * - auutopep8 configuration files supported | 31 | 34 | * - yapf configuration files supported | 32 | 35 | * Linting | 33 | 36 | * - It can be turned off (default is turn it on and use pylint) | 34 | | -* - pylint can be turned off | 35 | | -* - pyliny configuaration files supported | 36 | | -* - pep8 can be turned off | 37 | | -* - pep8 configuaration files supported | | 37 | +* - pylint can be turned on/off (default is on), supports standard configuaration files | | 38 | +* - pep8 can be turned on/off (default is off), supports standard configuaration files | | 39 | +* - flake8 can be turned on/off (default is on), supports standard configuaration files | 38 | 40 | * - Different categories of errors reported by pylint can be configured as warnings, errors, information or hits | 39 | | -* - Path to pylint and pep8 can be configured | 40 | | -* - Path to pep8 can be configured through config | | 41 | +* - Path to pylint, pep8 and flake8 and pep8 can be configured | 41 | 42 | * Debuggging | 42 | | -* - Local and Global variables | 43 | | -* - Arguments | 44 | 43 | * - Watch window | 45 | 44 | * - Evaluate Expressions | 46 | 45 | * - Step through code (Step in, Step out, Continue) | 47 | 46 | * - Add/remove break points | | 47 | +* - Local variables, Global variables and arguments (experimental, still needs some polishing) | | 48 | +* Unit Testing | | 49 | +* - unittests (default is on) | | 50 | +* - nosetests (default is off) | | 51 | +* - Test resutls are displayed in the "Python" output window | | 52 | +* - Future release will display results in a more structured manner integrated into the IDE | 48 | 53 | * Snippets | 49 | 54 |
| 50 | 55 |
| @@ -56,19 +61,30 @@ Works on both Windows and Mac. | 56 | 61 |
| 57 | 62 | ## Requirements | 58 | 63 | * Python is installed on the current system | 59 | | -* Pylint is installed for linting (optional, this can be turned off) | 60 | | -* - Install Pylint as follows: | | 64 | +* - Path to python can be configured | | 65 | +* Pylint is installed for linting (optional) | 61 | 66 | * - pip install pylint | 62 | | -* Pep8 is installed for linting (optional, this can be turned off) | | 67 | +* Pep8 is installed for linting (optional) | 63 | 68 | * - pip install pep8 | 64 | | -* Autopep8 is installed for code formatting | 65 | | -* - Install AutoPep8 as follows (ensure pep8 is installed): | | 69 | +* Flake8 is installed for linting (optional) | | 70 | +* - pip install flake8 | | 71 | +* Autopep8 is installed for code formatting (optional) | 66 | 72 | * - pip install pep8 | 67 | 73 | * - pip install --upgrade autopep8 | 68 | | - | | 74 | +* Yapf is installed for code formatting (optional) | | 75 | +* - pip install yapf | | 76 | +* nosetests for unit testing (optional) | | 77 | +* - pip install nose | 69 | 78 |
| 70 | 79 | ## Change Log | 71 | 80 |
| | 81 | +### Version 0.1.1 | | 82 | +* Added support for linting using flake8 | | 83 | +* Added support for unit testing using unittest and nosetest | | 84 | +* Added support for custom module paths for improved intellisense and autocomplete | | 85 | +* Modifications to debugger to display console output (generated using 'print' and the like) | | 86 | +* Modifications to debugger to accept arguments | | 87 | + | 72 | 88 | ### Version 0.1.0 | 73 | 89 | * Fixed linting of files on Mac | 74 | 90 | * Added support for linting using pep8 | |
Collapse file Copy file name to clipboardExpand all lines: package.json +81-7Lines changed: 81 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 30 | 30 | ], | 31 | 31 | "activationEvents": [ | 32 | 32 | "onLanguage:python", | 33 | | - "onCommand:python.sortImports" | | 33 | + "onCommand:python.sortImports", | | 34 | + "onCommand:python.runtests" | 34 | 35 | ], | 35 | 36 | "main": "./out/client/extension", | 36 | 37 | "contributes": { | | 44 | 45 | { | 45 | 46 | "command": "python.sortImports", | 46 | 47 | "title": "Python: Sort Imports" | | 48 | + }, | | 49 | + { | | 50 | + "command": "python.runtests", | | 51 | + "title": "Python: Run Unit Tests" | 47 | 52 | } | 48 | 53 | ], | 49 | 54 | "debuggers": [ | | 91 | 96 | "type": "object", | 92 | 97 | "title": "Python Configuration", | 93 | 98 | "properties": { | | 99 | + "python.pythonPath": { | | 100 | + "type": "string", | | 101 | + "default": "python", | | 102 | + "description": "Path to Python, you can use a custom version of Python by modifying this setting to include the full path." | | 103 | + }, | 94 | 104 | "python.linting.enabled": { | 95 | 105 | "type": "boolean", | 96 | 106 | "default": true, | | 106 | 116 | "default": false, | 107 | 117 | "description": "Whether to lint Python files using pep8" | 108 | 118 | }, | | 119 | + "python.linting.flake8Enabled": { | | 120 | + "type": "boolean", | | 121 | + "default": false, | | 122 | + "description": "Whether to lint Python files using flake8" | | 123 | + }, | 109 | 124 | "python.linting.lintOnTextChange": { | 110 | 125 | "type": "boolean", | 111 | 126 | "default": true, | | 124 | 139 | "python.linting.pylintCategorySeverity.convention": { | 125 | 140 | "type": "string", | 126 | 141 | "default": "Hint", | 127 | | - "description": "Severity of Pylint message type 'Convention/C'. Possible values include Error, Hint, Warning and Information." | | 142 | + "description": "Severity of Pylint message type 'Convention/C'.", | | 143 | + "enum": [ | | 144 | + "Hint", | | 145 | + "Error", | | 146 | + "Information", | | 147 | + "Warning" | | 148 | + ] | 128 | 149 | }, | 129 | 150 | "python.linting.pylintCategorySeverity.refactor": { | 130 | 151 | "type": "string", | 131 | 152 | "default": "Hint", | 132 | | - "description": "Severity of Pylint message type 'Refactor/R'. Possible values include Error, Hint, Warning and Information." | | 153 | + "description": "Severity of Pylint message type 'Refactor/R'.", | | 154 | + "enum": [ | | 155 | + "Hint", | | 156 | + "Error", | | 157 | + "Information", | | 158 | + "Warning" | | 159 | + ] | 133 | 160 | }, | 134 | 161 | "python.linting.pylintCategorySeverity.warning": { | 135 | 162 | "type": "string", | 136 | 163 | "default": "Warning", | 137 | | - "description": "Severity of Pylint message type 'Warning/W'. Possible values include Error, Hint, Warning and Information." | | 164 | + "description": "Severity of Pylint message type 'Warning/W'.", | | 165 | + "enum": [ | | 166 | + "Hint", | | 167 | + "Error", | | 168 | + "Information", | | 169 | + "Warning" | | 170 | + ] | 138 | 171 | }, | 139 | 172 | "python.linting.pylintCategorySeverity.error": { | 140 | 173 | "type": "string", | 141 | 174 | "default": "Error", | 142 | | - "description": "Severity of Pylint message type 'Error/E'. Possible values include Error, Hint, Warning and Information." | | 175 | + "description": "Severity of Pylint message type 'Error/E'.", | | 176 | + "enum": [ | | 177 | + "Hint", | | 178 | + "Error", | | 179 | + "Information", | | 180 | + "Warning" | | 181 | + ] | 143 | 182 | }, | 144 | 183 | "python.linting.pylintCategorySeverity.fatal": { | 145 | 184 | "type": "string", | 146 | 185 | "default": "Error", | 147 | | - "description": "Severity of Pylint message type 'Fatal/F'. Possible values include Error, Hint, Warning and Information." | | 186 | + "description": "Severity of Pylint message type 'Fatal/F'.", | | 187 | + "enum": [ | | 188 | + "Hint", | | 189 | + "Error", | | 190 | + "Information", | | 191 | + "Warning" | | 192 | + ] | 148 | 193 | }, | 149 | 194 | "python.linting.pylintPath": { | 150 | 195 | "type": "string", | | 156 | 201 | "default": "pep8", | 157 | 202 | "description": "Path to pep8, you can use a custom version of pep8 by modifying this setting to include the full path." | 158 | 203 | }, | | 204 | + "python.linting.flake8Path": { | | 205 | + "type": "string", | | 206 | + "default": "flake8", | | 207 | + "description": "Path to flake8, you can use a custom version of flake8 by modifying this setting to include the full path." | | 208 | + }, | 159 | 209 | "python.formatting.provider": { | 160 | 210 | "type": "string", | 161 | 211 | "default": "autopep8", | 162 | | - "description": "Provider for formatting. Possible options include 'autopep8' and 'yapf'." | | 212 | + "description": "Provider for formatting. Possible options include 'autopep8' and 'yapf'.", | | 213 | + "enum": [ | | 214 | + "autopep8", | | 215 | + "yapf" | | 216 | + ] | 163 | 217 | }, | 164 | 218 | "python.formatting.autopep8Path": { | 165 | 219 | "type": "string", | | 170 | 224 | "type": "string", | 171 | 225 | "default": "", | 172 | 226 | "description": "Path to yapf, you can use a custom version of yapf by modifying this setting to include the full path." | | 227 | + }, | | 228 | + "python.autoComplete.extraPaths": { | | 229 | + "type": "array", | | 230 | + "default": [], | | 231 | + "description": "List of paths to libraries and the like that need to be imported by auto complete engine. E.g. when using Google App SDK, the paths are not in system path, hence need to be added into this list." | | 232 | + }, | | 233 | + "python.unitTest.nosetestsEnabled": { | | 234 | + "type": "boolean", | | 235 | + "default": false, | | 236 | + "description": "Whether to enable or disable unit testing using nosetests." | | 237 | + }, | | 238 | + "python.unitTest.nosetestPath": { | | 239 | + "type": "string", | | 240 | + "default": "nosetests", | | 241 | + "description": "Path to nosetests, you can use a custom version of nosetests by modifying this setting to include the full path." | | 242 | + }, | | 243 | + "python.unitTest.unittestEnabled": { | | 244 | + "type": "boolean", | | 245 | + "default": true, | | 246 | + "description": "Whether to enable or disable unit testing using standard unittest (built into Python)." | 173 | 247 | } | 174 | 248 | } | 175 | 249 | } | |
Collapse file Copy file name to clipboardExpand all lines: pythonFiles/unittest.py Collapse file Copy file name to clipboard +20Lines changed: 20 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +'use strict'; | | 2 | + | | 3 | +import * as path from 'path'; | | 4 | +import * as fs from 'fs'; | | 5 | +import * as child_process from 'child_process'; | | 6 | + | | 7 | +export function sendCommand(commandLine: string, cwd: string): Promise<string> { | | 8 | + return new Promise<string>((resolve, reject) => { | | 9 | + | | 10 | + child_process.exec(commandLine, { cwd: cwd }, (error, stdout, stderr) => { | | 11 | + var hasErrors = (error && error.message.length > 0) || (stderr && stderr.length > 0); | | 12 | + if (hasErrors && (typeof stdout !== "string" || stdout.length === 0)) { | | 13 | + var errorMsg = (error && error.message) ? error.message : (stderr && stderr.length > 0 ? stderr.toString("utf-8") : ""); | | 14 | + return reject(errorMsg); | | 15 | + } | | 16 | + | | 17 | + resolve(stdout.toString('utf-8')); | | 18 | + }); | | 19 | + }); | | 20 | +} |
Collapse file Copy file name to clipboard +96Lines changed: 96 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +'use strict'; | | 2 | + | | 3 | +import * as vscode from 'vscode'; | | 4 | + | | 5 | +export interface IPythonSettings { | | 6 | + pythonPath: string; | | 7 | + linting: ILintingSettings; | | 8 | + formatting: IFormattingSettings; | | 9 | + unitTest: IUnitTestSettings; | | 10 | +} | | 11 | +export interface IUnitTestSettings { | | 12 | + nosetestsEnabled: boolean; | | 13 | + nosetestPath:string; | | 14 | + unittestEnabled: boolean; | | 15 | +} | | 16 | +export interface IPylintCategorySeverity { | | 17 | + convention: vscode.DiagnosticSeverity; | | 18 | + refactor: vscode.DiagnosticSeverity; | | 19 | + warning: vscode.DiagnosticSeverity; | | 20 | + error: vscode.DiagnosticSeverity; | | 21 | + fatal: vscode.DiagnosticSeverity; | | 22 | +} | | 23 | +export interface ILintingSettings { | | 24 | + enabled: boolean; | | 25 | + pylintEnabled: boolean; | | 26 | + pep8Enabled: boolean; | | 27 | + flake8Enabled: boolean; | | 28 | + lintOnTextChange: boolean; | | 29 | + lintOnSave: boolean; | | 30 | + maxNumberOfProblems: number; | | 31 | + pylintCategorySeverity: IPylintCategorySeverity; | | 32 | + pylintPath: string; | | 33 | + pep8Path: string; | | 34 | + flake8Path: string; | | 35 | +} | | 36 | +export interface IFormattingSettings { | | 37 | + provider: string; | | 38 | + autopep8Path: string; | | 39 | + yapfPath: string; | | 40 | +} | | 41 | +export interface IAutoCompeteSettings { | | 42 | + extraPaths: string[]; | | 43 | +} | | 44 | +export class PythonSettings implements IPythonSettings { | | 45 | + constructor() { | | 46 | + vscode.workspace.onDidChangeConfiguration(() => { | | 47 | + this.initializeSettings(); | | 48 | + }); | | 49 | + | | 50 | + this.initializeSettings(); | | 51 | + } | | 52 | + | | 53 | + private initializeSettings() { | | 54 | + var pythonSettings = vscode.workspace.getConfiguration("python"); | | 55 | + | | 56 | + this.pythonPath = pythonSettings.get<string>("pythonPath"); | | 57 | + | | 58 | + var lintingSettings = pythonSettings.get<ILintingSettings>("linting"); | | 59 | + if (this.linting) { | | 60 | + Object.assign<ILintingSettings, ILintingSettings>(this.linting, lintingSettings); | | 61 | + } | | 62 | + else { | | 63 | + this.linting = lintingSettings; | | 64 | + } | | 65 | + | | 66 | + var formattingSettings = pythonSettings.get<IFormattingSettings>("linting"); | | 67 | + if (this.formatting) { | | 68 | + Object.assign<IFormattingSettings, IFormattingSettings>(this.formatting, formattingSettings); | | 69 | + } | | 70 | + else { | | 71 | + this.formatting = formattingSettings; | | 72 | + } | | 73 | + | | 74 | + var autoCompleteSettings = pythonSettings.get<IAutoCompeteSettings>("autoComplete"); | | 75 | + if (this.autoComplete) { | | 76 | + Object.assign<IAutoCompeteSettings, IAutoCompeteSettings>(this.autoComplete, autoCompleteSettings); | | 77 | + } | | 78 | + else { | | 79 | + this.autoComplete = autoCompleteSettings; | | 80 | + } | | 81 | + | | 82 | + var unitTestSettings = pythonSettings.get<IUnitTestSettings>("unitTest"); | | 83 | + if (this.unitTest) { | | 84 | + Object.assign<IUnitTestSettings, IUnitTestSettings>(this.unitTest, unitTestSettings); | | 85 | + } | | 86 | + else { | | 87 | + this.unitTest = unitTestSettings; | | 88 | + } | | 89 | + } | | 90 | + | | 91 | + public pythonPath: string; | | 92 | + public linting: ILintingSettings; | | 93 | + public formatting: IFormattingSettings; | | 94 | + public autoComplete: IAutoCompeteSettings; | | 95 | + public unitTest: IUnitTestSettings; | | 96 | +} |
|