Skip to content
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

Refactor extension to remove old way of spawning python processes #439

Merged
merged 58 commits into from
Jan 3, 2018

Conversation

DonJayamanne
Copy link

Fixes #354

  • Code refactoring to remove execPythonFile function and use the new execution layer

octref and others added 30 commits November 3, 2017 13:11
* '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:
  Fix feedback service (#246)
  Fix django context initializer (#248)
  disable generation of tags file upon extension load (#264)
* upstream/master:
  Resolve pythonPath before comparing it to shebang (#273)
* upstream/master:
  Fixes #22 to Detect anaconda from known locations  (#221)
  Use workspaceFolder token instead of workspaceRoot (#267)
  Fix registry lookup response (#224)
  Fix issues when running without debugging and debugged code terminates (#249)
* upstream/master:
  Fix debugging tests (#304)
* upstream/master:
  Remove jupyter functionality in favor of Jupyter extension (#302)
  Drop Python 2 URLs (#307)
* upstream/master:
  Remove setting python.formatting.formatOnSave in favor of the vs code setting (#312)
* upstream/master:
  Remove setting linting.lintOnTextChange as it was never implemented (#315)
* upstream/master:
  Fix travis build error (#326)
* upstream/master:
  add new npm deps with improved gulp for dev (#328)
* upstream/master:
  Update version of inversify package (#329)
* upstream/master:
  Document our dev process (#330)
* upstream/master:
  Document contribution to the code along with coding standards (#321)
* upstream/master:
  Add Simplified Chinese translation of commands (#240)
* upstream/master:
  Fix package.json (#347)
* upstream/master:
  #34, #110 - suppress Intellisense in strings and comments (#339)
  Re-factor code python execution framework  (#345)
* upstream/master:
  Fix linters to make use of the new python code execution framework (#360)
  Update the versioning scheme (#356)
  Make npm happy in regards to line endings (#357)
* upstream/master:
  Ensure python path is not set if already set in user settings (#369)
  Use 'an' rather than 'a' before vowel words (#373)
* upstream/master:
  Use new environment variable parser (#362)
@DonJayamanne DonJayamanne changed the title Refactor extension to completely remove old way of spawning python processes WIP - Refactor extension to completely remove old way of spawning python processes Dec 15, 2017
@DonJayamanne DonJayamanne changed the title WIP - Refactor extension to completely remove old way of spawning python processes Refactor extension to completely remove old way of spawning python processes Dec 15, 2017
if (output.stdout.length > 0) {
// Take the first available version number, see below example.
// pip 9.0.1 from /Users/donjayamanne/anaconda3/lib/python3.6/site-packages (python 3.6).
// Take the second part, see below example.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the second part? And the example is the same, so it reads like you're taking two things from do different formats when it's two things from the same format.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old comments, will fix that.

} else {
args.push('custom');
args.push(this.pythonSettings.jediPath);
// Use preview version of jedi library.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would drop "library" from the comment.

} else {
const data = output.out;
// Possible there was an exception in parsing the data returned,
// so append the data then parse it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"data and then"

// Great example of poorly written code (this whole file is a mess).
// I think this needs to be removed, because this is misspelt, it is argments, 'U' is missing,
// And that case is handled further down
// case CommandType.Arguments: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, so I don't know what to do with this comment. 😄 If the code should be ripped out then rip it out and drop the comment. 😉

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do, was reluctant to clean up this messy file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

default:
break;
}
// Check if too many pending requets.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"requests"

@DonJayamanne
Copy link
Author

@brettcannon all issues have been addressed. Thanks

1 similar comment
@DonJayamanne
Copy link
Author

@brettcannon all issues have been addressed. Thanks

* upstream/master:
  Refactor formatters to use new execution framework (#426)
Copy link
Member

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a warning that my review was slightly rushed.

// tslint:disable-next-line:no-any
let responses: any[];
try {
responses = dataStr.split(/\r?\n/g).filter(line => line.length > 0).map(resp => JSON.parse(resp));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget about that helper on splitting lines. 😉

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@DonJayamanne
Copy link
Author

@brettcannon Thats fine, I'll leave the PR open. Lets get it reviewed correctly in the new year. I'll base other PRs off this branch.

* upstream/master:
  Release 0.9.1 (#458)
  Add localization for Japanese (#434)
  Add Svn to uriSchemesToIgnore (#443)
@DonJayamanne DonJayamanne changed the title Refactor extension to completely remove old way of spawning python processes Refactor extension to remove old way of spawning python processes Jan 2, 2018
return matches[0].trim();
}
}
throw new Error(`Unable to determine Pip version from output '${output.stdout}'`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically pip is always lowercased.


switch (cmd.command) {
case CommandType.Completions:
this.onCompletion(cmd, response);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe assign the method to a variable and then call it after the switch to minimize the chance of getting the call order wrong?

isPython3 = Promise.resolve(version.indexOf('3.') >= 0);
initializeDI();
const version = await ioc.getPythonVersion(rootWorkspaceUri);
isPython3 = version.indexOf('3.') >= 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break under Python 2.3 or Python 4.3. What you really want to know is whether something is Python 2 or not since Python 4 will be backwards-compatible with Python 3. IOW we want to set things up so that Python 2 is the special-case so when it comes time to drop support we can rip it out easily as well has not have issues when Python 4 is released.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Agreed.

@DonJayamanne
Copy link
Author

@brettcannon all done.

@DonJayamanne DonJayamanne merged commit aec4fb3 into microsoft:master Jan 3, 2018
@DonJayamanne DonJayamanne deleted the RefactorJediAndOthers branch January 4, 2018 19:49
DonJayamanne added a commit that referenced this pull request Jan 9, 2018
* upstream/master:
  Refactor parsing of environment variables (after 439) (#466)
  Refactor extension to remove old way of spawning python processes (#439)
DonJayamanne added a commit that referenced this pull request Jan 9, 2018
* CommonToolExecution:
  Refactor parsing of environment variables (after 439) (#466)
  Refactor extension to remove old way of spawning python processes (#439)
DonJayamanne added a commit that referenced this pull request Jan 9, 2018
* CommonToolExecution:
  Refactor parsing of environment variables (after 439) (#466)
  Refactor extension to remove old way of spawning python processes (#439)
@lock lock bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up tool execution in Language (usage of Jedi) server
3 participants