Skip to content

Conversation

@Kavakuo
Copy link
Contributor

@Kavakuo Kavakuo commented Oct 3, 2017

This implements #1261 and works best in combination with #1263 (otherwise clicking the CodeLens without an error is only possible with an opened workspace).

The CodeLens is only visible when the current selected interpreter is another than the interpreter specified in the shebang. Clicking the CodeLens changes the interpreter and after that the CodeLens disappears.

@Kavakuo Kavakuo force-pushed the feature#shebangDetection branch from 58def33 to 4bd97b2 Compare October 3, 2017 16:05
@Kavakuo Kavakuo changed the title CodeLens for Shebangs CodeLense for Shebangs Oct 3, 2017
@DonJayamanne
Copy link
Owner

@Kavakuo
Thanks for the PR, overall its fine apart from a few minor issues. One last thing I'd like for you to add are some unit tests.

@DonJayamanne
Copy link
Owner

@Kavakuo
I have merged some fixes to the unit tests into the master branch. Please merge the master into your branch. This will help with the testing on travis.

@Kavakuo Kavakuo changed the title CodeLense for Shebangs CodeLens for Shebangs Oct 3, 2017
@DonJayamanne
Copy link
Owner

@Kavakuo let me know if you need a hand with the unit tests.
Just have a look at the existing unit tests where I'm opening a local file and running the tests.
FYI - To speed up the tests you could delete some of the test directories (e.g. jupyter, common, linters, formatting, etc) - but don't commit those.

@Kavakuo
Copy link
Contributor Author

Kavakuo commented Oct 3, 2017

I think I made it 👍 I hope these tests are ok and the files I added are in the right place.
To run only a few tests I discovered the very helpful grep option for the testrunner configuration. Set it to "Shebang" to run my tests.

@Kavakuo
Copy link
Contributor Author

Kavakuo commented Oct 3, 2017

@DonJayamanne Everything fixed. Travis also passes 👍

@DonJayamanne
Copy link
Owner

@Kavakuo , please could you use async await everywhere in your tests.
There are other issues that haven't been completed, please have a look at my comments.

@Kavakuo
Copy link
Contributor Author

Kavakuo commented Oct 4, 2017

@DonJayamanne
Thanks for the hint to use async and await. I'm fairly inexperienced with typescript/nodejs. You mentioned before that there are other issues, but I think you forgot to list them.

@Kavakuo
Thanks for the PR, overall its fine apart from a few minor issues. One last thing I'd like for you to add are some unit tests.

@DonJayamanne DonJayamanne merged commit 14ef606 into DonJayamanne:master Oct 4, 2017
@DonJayamanne DonJayamanne added this to the October 2017 milestone Oct 4, 2017
@DonJayamanne
Copy link
Owner

@Kavakuo thanks for the PR.

@Kavakuo
Copy link
Contributor Author

Kavakuo commented Oct 4, 2017

@DonJayamanne
Thanks for merging and appreciating my ideas. If there are any problems in the future with my code, just let me know. It was my pleasure to contribute to this project!

@Kavakuo Kavakuo deleted the feature#shebangDetection branch October 4, 2017 23:25
@brettcannon
Copy link
Contributor

One thing I just realized is what happens if someone uses env, e.g. #!/usr/bin/env python?

@Kavakuo
Copy link
Contributor Author

Kavakuo commented Oct 5, 2017

Oh well, I think that won't work currently. Totally overseen this, because I usually use absolute paths. The extension would want to set /usr/bin/env python as python.pythonPath and detects that this is an invalid interpreter... 🤔 So there is currently also no support in general for setting python.pythonPath something that starts with /usr/bin/env.

I think the best solution is to build something that resolves the raw python.pythonPath value startung with /usr/bin/env to an absolute path before setting the interpreter. This would bring full support for /usr/bin/env values in the settings and it would be easy to resolve the shebang before showing the CodeLens as well.

Can look into this tomorrow. If you have other solution ideas or want to build this yourself, let me know. Should we open a new issue for this?

@brettcannon
Copy link
Contributor

Yeah, an issue would be good and I have no specific suggestions on how best to handle it.

@DonJayamanne
Copy link
Owner

I can fix that, basically i just evaluate the expression and get the path out of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants