Repository navigation
Added FSWatching base class and made related changes - #14605
Conversation
Codecov Report
@@ Coverage Diff @@
## main #14605 +/- ##
===========================================
- Coverage 64.89% 0.00% -64.90%
===========================================
Files 541 4 -537
Lines 25156 11 -25145
Branches 3545 0 -3545
===========================================
- Hits 16324 0 -16324
+ Misses 8170 11 -8159
+ Partials 662 0 -662
Continue to review full report at Codecov.
|
Eric Snow (ericsnowcurrently)
left a comment
There was a problem hiding this comment.
Thanks for working on this, Kartik Raj (@karrtikr). I think you're on the right track. My main recommendation is that you give FSWatchingLocator a meaningful purpose. Otherwise I don't think there is anything too major here, though I've noted a few places where I have concerns about correctness.
d65c331 to
183fdce
Compare
183fdce to
31f7c54
Compare
Eric Snow (ericsnowcurrently)
left a comment
There was a problem hiding this comment.
I've left a few relatively minor comments for which I'd appreciate a resolution before this gets merged.
Otherwise, LGTM.
| /** | ||
| * Location(s) to watch for python binaries. | ||
| */ | ||
| private readonly getRoots: () => Promise<string[]> | string, |
There was a problem hiding this comment.
| private readonly getRoots: () => Promise<string[]> | string, | |
| private readonly getRoots: () => Promise<string[]> | string[], |
There was a problem hiding this comment.
Actually it's getRoot(s) as explained in the doc. Not every locator has an array of locations they want to search (getWindowsAppsRoot), some just have a single location, so this is just convenience.
There was a problem hiding this comment.
I have added the string[] type but not removed string.
There was a problem hiding this comment.
If they have a single location then they return a single element array. Returning string means that the caller always has to check typeof result === 'string'. So it makes things simpler if we only return Promise<string[]> | string[].
(Also note that if you support return string then the return type should be Promise<string[] | string> | string[] | string. However, as I said, I don't think the distinction between string[] and string adds any value while it increases complexity.
There was a problem hiding this comment.
Returning string means that the caller always has to check typeof result === 'string'
I don't think so.. not sure why you say that. The caller for the "string" case here just passes in
constructor() {
super(
getWindowsStoreAppsRoot,
async () => this.kind,
{ executableBaseGlob: pythonExeGlob },
);
}While in string[] case
constructor() {
super(
() => [getWindowsStoreAppsRoot()],
async () => this.kind,
{ executableBaseGlob: pythonExeGlob },
);
}So adding the string type decreases complexity for the caller. Note this is just convenience.
There was a problem hiding this comment.
Ah, I see the problem. I was expecting it to return one of the following (and I believe it does):
() => Promise<string[]>() => string[]() => string
While you appear to be thinking it is:
() => Promise<string[]>string[]string
I'm pretty sure the correct form to also meet your expectations is:
string[] | string | () => Promise<string[]> | string[]
Though parentheses might be needed:
string[] | string | (() => Promise<string[]> | string[])
FWIW, I agree that the string[] | string types are convenient and should be okay.
commented
Nov 5, 2020
|
Kudos, SonarCloud Quality Gate passed!
|
Created a work item to move all low level locators separately.