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

Switch to using URIs as much as possible #9641

Merged
merged 29 commits into from
Apr 13, 2022
Merged

Conversation

rchiodo
Copy link
Contributor

@rchiodo rchiodo commented Apr 9, 2022

Fixes #9599

@codecov-commenter
Copy link

codecov-commenter commented Apr 9, 2022

Codecov Report

Merging #9641 (906984d) into main (a2171fd) will decrease coverage by 9%.
The diff coverage is 22%.

@@          Coverage Diff           @@
##           main   #9641     +/-   ##
======================================
- Coverage    73%     63%    -10%     
======================================
  Files       194     201      +7     
  Lines      8428    9825   +1397     
  Branches   1231    1557    +326     
======================================
+ Hits       6175    6248     +73     
- Misses     1777    3079   +1302     
- Partials    476     498     +22     
Impacted Files Coverage Δ
src/platform/api/types.ts 100% <ø> (ø)
.../common/application/applicationEnvironment.base.ts 34% <ø> (ø)
src/platform/common/application/types.ts 100% <ø> (ø)
src/platform/common/platform/types.ts 100% <ø> (ø)
src/platform/common/process/pythonDaemon.node.ts 17% <0%> (ø)
...c/platform/common/process/pythonDaemonPool.node.ts 76% <ø> (ø)
...form/common/process/pythonExecutionFactory.node.ts 75% <0%> (ø)
src/platform/common/serviceRegistry.node.ts 100% <ø> (ø)
src/platform/common/types.ts 100% <ø> (ø)
src/platform/interpreter/contracts.node.ts 100% <ø> (ø)
... and 35 more

return path.join(this.pathUtils.home, macJupyterPath);
} else {
return path.join(this.pathUtils.home, linuxJupyterPath);
const userHomeDir = getUserHomeDir();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be 1 location to get the user home dir now. We had like 3 before.

if (getOSType() === OSType.Windows) {
return getEnvironmentVariable('USERPROFILE');
return fsPathToUri(getEnvironmentVariable('USERPROFILE') || homePath);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without the homePath stuff tests will fail on windows (for linux based tests)

@rchiodo rchiodo marked this pull request as ready for review April 12, 2022 20:25
@rchiodo rchiodo requested a review from a team as a code owner April 12, 2022 20:25
@@ -319,7 +320,7 @@ export interface IJupyterKernelSpec {
id?: string;
name: string;
language?: string;
path: string;
path: Uri;
Copy link
Member

Choose a reason for hiding this comment

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

Would a rename be considered here? This now shows up in some places like kernel.path.path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe as 'uri'?

Copy link
Member

Choose a reason for hiding this comment

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

I think that's more what I would expect. But a variable called path also being a Uri wouldn't really surprise me, so feel free to change or not based on what you think. Not a big diff for me.

@@ -57,12 +57,12 @@ export type PythonVersion = {
};
export type PythonEnvironment = {
displayName?: string;
path: string;
path: Uri;
Copy link
Member

Choose a reason for hiding this comment

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

Another possible path=>Uri name for the member.

Copy link
Member

@IanMatthewHuff IanMatthewHuff left a comment

Choose a reason for hiding this comment

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

There were a couple path variables that are now Uris that we could consider renaming. Looks good though.

@@ -4,6 +4,7 @@
'use strict';

import * as path from '../platform/vscode-path/path';
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have linters to ensure nodejs module path never gets used.
Or would we want to just replace path with vscode-path in webpack?

I'd think one of the above would be necessary to ensure we don't use path in web files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do have a linter that ensures no more usage of 'path' from nodejs anywhere except for '.node' files.

@@ -1205,7 +1218,7 @@ function compareAgainstKernelDisplayNameInNotebookMetadata(
argv: [],
display_name: notebookMetadata.kernelspec.display_name,
name: notebookMetadata.kernelspec.name,
path: ''
uri: Uri.file('')
Copy link
Contributor

@DonJayamanne DonJayamanne Apr 13, 2022

Choose a reason for hiding this comment

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

This feels very risky. I think we should mark path as a nullable property
we could have code paths where we check if path is empty e.g. if (path),
Such a condition would evaluate to false as the string is empty, now these would never show up in compilations and they'd always be true because its always an object and never an empty string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those were all handled with the rename. They wouldn't compile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cause before it used to have stuff like this:
interpreter || { path: string }.

Now when path is accessed it says interpreter doesn't have it.

The only risk here is if we had forced things to 'any'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And well our integration tests and unit tests would likely have caught it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

InterpreterOrUri was another example of where it was checking for '.path'. After the change of .path to a URI those still worked. After this rename, these turned into a compile time error and were actually correct. So this rename was necessary to catch that usage.

@rchiodo rchiodo merged commit ecc0aaf into main Apr 13, 2022
@rchiodo rchiodo deleted the rchiodo/common_path_fixup branch April 13, 2022 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch to using URIs everywhere possible
4 participants