Skip to content

Set python.pythonPath in workspace/configuration LSP call #11084

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

Merged
merged 6 commits into from
Apr 13, 2020

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Apr 10, 2020

For #11083

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • Title summarizes what is changing.
  • Has a news entry file (remember to thank yourself!).
  • Appropriate comments and documentation strings in the code.
  • Has sufficient logging.
  • Has telemetry for enhancements.
  • Unit tests & system/integration tests are added/updated. (Not sure I can even test this; if I have LS in a test there's not a way for me to simulate a call without a real server to do it, which means mocking RPC.)
  • Test plan is updated as appropriate.
  • package-lock.json has been regenerated by running npm install (if dependencies have changed).
  • The wiki is updated with any design decisions/details.

@jakebailey jakebailey requested a review from karrtikr April 10, 2020 19:01
@jakebailey
Copy link
Member Author

jakebailey commented Apr 10, 2020

That code smell is confusing; TS on my machine could not collapse:

Thenable<any[]>
| Thenable<ResponseError<void>>
| Thenable<any[] | ResponseError<void>>

Into:

Thenable<any[] | ResponseError<void>>

Hence the redundant cast. But, somehow sonar's analysis is able to do so?

If I drop the cast, I get:

This expression is not callable.
  Each member of the union type '{ <TResult>(onfulfilled?: ((value: ResponseError<void>) => TResult | Thenable<TResult>) | undefined, onrejected?: ((reason: any) => TResult | Thenable<...>) | undefined): Thenable<...>; <TResult>(onfulfilled?: ((value: ResponseError<...>) => TResult | Thenable<...>) | undefined, onrejected?: ((reason: any) => void) ...' has signatures, but none of those signatures are compatible with each other.

@jakebailey jakebailey force-pushed the ls-middleware-pythonpath branch from bf7c49d to e298a27 Compare April 10, 2020 21:57
@codecov-io
Copy link

codecov-io commented Apr 11, 2020

Codecov Report

Merging #11084 into master will decrease coverage by 0.00%.
The diff coverage is 17.39%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11084      +/-   ##
==========================================
- Coverage   61.42%   61.41%   -0.01%     
==========================================
  Files         597      597              
  Lines       32756    32822      +66     
  Branches     4631     4645      +14     
==========================================
+ Hits        20121    20159      +38     
- Misses      11619    11645      +26     
- Partials     1016     1018       +2     
Impacted Files Coverage Δ
src/client/activation/node/manager.ts 27.77% <0.00%> (-0.53%) ⬇️
src/client/activation/languageClientMiddleware.ts 31.97% <10.52%> (-1.63%) ⬇️
src/client/activation/languageServer/manager.ts 83.87% <100.00%> (+0.26%) ⬆️
src/datascience-ui/react-common/arePathsSame.ts 75.00% <0.00%> (-12.50%) ⬇️
src/client/common/utils/platform.ts 64.70% <0.00%> (-11.77%) ⬇️
...ence/ipywidgets/localWidgetScriptSourceProvider.ts 88.13% <0.00%> (-3.39%) ⬇️
...t/common/application/webPanels/webPanelProvider.ts 32.14% <0.00%> (-2.48%) ⬇️
src/client/linters/pydocstyle.ts 86.66% <0.00%> (-2.23%) ⬇️
src/client/datascience/debugLocationTracker.ts 76.56% <0.00%> (-1.57%) ⬇️
...client/datascience/kernel-launcher/kernelFinder.ts 75.70% <0.00%> (-0.94%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0af7c29...da8fafa. Read the comment docs.

Copy link

@karrtikr karrtikr left a comment

Choose a reason for hiding this comment

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

LGTM otherwise.

token: CancellationToken,
next: ConfigurationRequest.HandlerSignature
): HandlerResult<any[], void> => {
const result = next(params, token);
Copy link

@karrtikr karrtikr Apr 13, 2020

Choose a reason for hiding this comment

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

Suggested change
const result = next(params, token);
const result = next(params, token) as any[] | ResponseError<void> | Thenable<any[] | ResponseError<void>>;

Choose a reason for hiding this comment

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

Does this help with the code smell?

Copy link
Member Author

Choose a reason for hiding this comment

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

It does, though I would really be interested in why there's a difference between Sonar and what we run locally, as doing this cast early throws away the safety of everything I've written... @DonJayamanne any clue?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, TS is happy if I change the type on result's decl rather than casting, so I'll just do that. If they change HandlerResult, then there's no cast to prevent detection.

Choose a reason for hiding this comment

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

added comments as to why you'd be getting the compilation errors
Solution - return the original value of result. I.e. in the function addPythonPath return the argument as the return value.

const addPytonPath = (settings:....) => {
	if (!(settings instanceof ResponseError)) {
		....
	}

	
	return settings;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Doing that (and dropping my hand-written type) doesn't change things:

image

Note the squiggle on then, as I'm still getting the message as written in #11084 (comment).

Meanwhile, Sonar's TS install has no problem with the original code I wrote if I were to drop the hand-written types entirely.

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
6.2% 6.2% Duplication

@jakebailey jakebailey merged commit f00e21b into microsoft:master Apr 13, 2020
@jakebailey jakebailey deleted the ls-middleware-pythonpath branch April 13, 2020 20:11
@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
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.

4 participants