-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Re-factor code python execution framework #345
Conversation
DonJayamanne
commented
Dec 4, 2017
- Ensure we have a generic way of executing python code, modules with support for env variables
- Improvements to gulp to speed up compilation and improved dev experience
- Added dependency injection
- Modifications to unit tests framework (running pytests, nose, etc in extension) to make use of the new python execution engine along with DI
- Code refactoring
- Move types into types.ts file
- Ensure all promises have exception handlers
- Use latest version of typescript
Archive of 0.7.0
* 'master' of https://github.com/Microsoft/vscode-python: Fixes #56 list all environments (#219) Fixes #57 Disable activation on debugging (#220) Fixes #26 Do not run linters when linters are disabled (#222)
* upstream/master: Fix typo in README.md (#252) Disable linter without workspaces (#241)
* upstream/master: Document contribution to the code along with coding standards (#321)
* upstream/master: Add Simplified Chinese translation of commands (#240)
Is this all the work instead of just the tests? |
Yes this is, but scooped just around the feature support of running pytest, nose and unit test in the extension, |
.vscode/tasks.json
Outdated
@@ -47,6 +47,26 @@ | |||
"isDefault": true | |||
} | |||
}, | |||
{ | |||
// Task that will replace 'Compile' and 'Hygiene', after having been battle-tested. |
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.
"after having been" -> "after being"
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.
Sorry my linguistic curiosity, but could you please explain the difference to a non-native speaker? "after having been" sounded fine to me...
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.
Yup, Bretts suggestion, makes sense to me.
@@ -1,155 +1,18 @@ | |||
/*--------------------------------------------------------------------------------------------- |
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.
Why the removal of the copyright notice?
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.
doh
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.
Fixed
src/client/common/variables/types.ts
Outdated
|
||
/** | ||
* An interface for a JavaScript object that | ||
* acts a dictionary. The keys are strings. |
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.
"acts a" -> "acts as a"
src/client/common/variables/types.ts
Outdated
* An interface for a JavaScript object that | ||
* acts a dictionary. The keys are strings. | ||
*/ | ||
export interface IStringDictionary<V> { |
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.
TS doesn't support this by default on the object
type?
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.
But that won't be strongly typed, this ensures properties are strings and values are of type V
.
src/client/linters/pylama.ts
Outdated
|
||
resolve(messages); | ||
return this.run(pylamaPath, pylamaArgs.concat(['--format=parsable', document.uri.fsPath]), document, this.getWorkspaceRootPath(document), cancellation, REGEX).then(messages => { | ||
// All messages in pylama are treated as warnings for now |
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.
Missing a period.
src/client/providers/lintProvider.ts
Outdated
} | ||
// set all diagnostics found in this pass, as this method always clears existing diagnostics. | ||
this.diagnosticCollection.set(document.uri, diagnostics); | ||
// Build the message and suffix the message with the name of the linter used |
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.
Period.
src/client/providers/lintProvider.ts
Outdated
this.diagnosticCollection.set(document.uri, diagnostics); | ||
// Build the message and suffix the message with the name of the linter used | ||
msgs.forEach(d => { | ||
// ignore magic commands from jupyter |
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.
Capitalize and period.
src/client/providers/lintProvider.ts
Outdated
diagnostics.push(createDiagnostics(d, document)); | ||
}); | ||
|
||
// Limit the number of messages to the max value |
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.
Period.
// We need to display the path relative to the current directory. | ||
fileName = fileName.substring(rootDirectory.length + 1); | ||
// we don't care about the compiled file. | ||
if (path.extname(fileName) === '.pyc') { |
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.
Do we need to worry about .pyo
files as well?
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.
Good pick.
procService.onExecObservable((file, args, options, callback) => { | ||
if (args.length > 1 && args[0] === '-c' && args[1].includes('import unittest') && args[1].includes('loader = unittest.TestLoader()')) { | ||
callback({ | ||
// Ensure any spaces added during code formatting or the like are removed |
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.
Period.
@brettcannon fixed. |
* upstream/master: Fix package.json (#347)
@@ -178,7 +179,7 @@ export class PythonSettings extends EventEmitter implements IPythonSettings { | |||
} | |||
// tslint:disable-next-line:function-name | |||
public static dispose() { | |||
if (!IS_TEST_EXECUTION) { | |||
if (!isTestExecution()) { |
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.
Alternative might be to define IPythonSettingsTest
with additional test methods so regular code does not see test functions. Or derive a class like PythonSettingsTest
with test methods and provide different factories to test and regular code.
Just a thought.
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.
Totally agreed, unfortunately that's a bigger chunk of work.
The DI layer in this PR, and the existing IPythonSettings interface should help with this (its just a matter of refactoring stuff).
However I'd defer that to a later PR