Skip to content

Added FSWatching base class and made related changes #14605

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 10 commits into from
Nov 6, 2020

Conversation

karrtikr
Copy link

@karrtikr karrtikr commented Nov 4, 2020

Created a work item to move all low level locators separately.

@karrtikr karrtikr added the no-changelog No news entry required label Nov 4, 2020
@codecov-io
Copy link

codecov-io commented Nov 4, 2020

Codecov Report

Merging #14605 into main will decrease coverage by 64.89%.
The diff coverage is n/a.

Impacted file tree graph

@@             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     
Impacted Files Coverage Δ
src/client/debugger/constants.ts 0.00% <0.00%> (-100.00%) ⬇️
src/client/common/process/constants.ts 0.00% <0.00%> (-100.00%) ⬇️
src/client/common/platform/constants.ts 0.00% <0.00%> (-100.00%) ⬇️
src/client/interpreter/autoSelection/constants.ts 0.00% <0.00%> (-100.00%) ⬇️
src/client/interpreter/display/progressDisplay.ts
src/client/terminals/activation.ts
src/client/formatters/helper.ts
src/client/testing/codeLenses/main.ts
src/client/common/experiments/groups.ts
src/client/common/process/proc.ts
... and 526 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 f752706...21b740a. Read the comment docs.

Copy link

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, @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.

Copy link

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

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

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,

Choose a reason for hiding this comment

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

Suggested change
private readonly getRoots: () => Promise<string[]> | string,
private readonly getRoots: () => Promise<string[]> | string[],

Copy link
Author

@karrtikr karrtikr Nov 5, 2020

Choose a reason for hiding this comment

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

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.

Copy link
Author

Choose a reason for hiding this comment

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

I have added the string[] type but not removed string.

Choose a reason for hiding this comment

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

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.

Copy link
Author

Choose a reason for hiding this comment

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

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.

Choose a reason for hiding this comment

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

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.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 5, 2020

Kudos, SonarCloud Quality Gate passed!

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
0.0% 0.0% Duplication

@karrtikr karrtikr merged commit 16d4701 into microsoft:main Nov 6, 2020
@karrtikr karrtikr deleted the baseclass branch November 6, 2020 00:06
karthiknadig pushed a commit to karthiknadig/vscode-python that referenced this pull request Nov 9, 2020
* Add FSWatching locator base class

* Correct glob pattern to not match python3.2whoa

* Add documentation of python binary watcher

* Fix lint errors

* Update ignore list

* Add disposable registry

* Modify FSWatching Locator

* Code reviews

* Use string[]

* Remove list disposable getter
karthiknadig pushed a commit to karthiknadig/vscode-python that referenced this pull request Nov 9, 2020
* Add FSWatching locator base class

* Correct glob pattern to not match python3.2whoa

* Add documentation of python binary watcher

* Fix lint errors

* Update ignore list

* Add disposable registry

* Modify FSWatching Locator

* Code reviews

* Use string[]

* Remove list disposable getter
karthiknadig added a commit that referenced this pull request Nov 9, 2020
* Added FSWatching base class and made related changes (#14605)

* Add FSWatching locator base class

* Correct glob pattern to not match python3.2whoa

* Add documentation of python binary watcher

* Fix lint errors

* Update ignore list

* Add disposable registry

* Modify FSWatching Locator

* Code reviews

* Use string[]

* Remove list disposable getter

* Fix failing global virtual env watcher tests (#14633)

Co-authored-by: Kartik Raj <[email protected]>
karthiknadig added a commit that referenced this pull request Nov 26, 2020
* Cherry pick from main (#14644)

* Update shipped wheels version (#14615)

* Update shipped wheels version

* News item

* Remove redundant files (#14620)

* Add extension dependencies at build time (#14636)

* Use Node 12.15 in Insiders and Release GitHub Actions (#14641)

* Use Node 12.15 on all Insiders and Release GitHub Actions jobs (#14642)

Co-authored-by: Joyce Er <[email protected]>

* Cherry pic fixes into release for tests. (#14673)

* Added FSWatching base class and made related changes (#14605)

* Add FSWatching locator base class

* Correct glob pattern to not match python3.2whoa

* Add documentation of python binary watcher

* Fix lint errors

* Update ignore list

* Add disposable registry

* Modify FSWatching Locator

* Code reviews

* Use string[]

* Remove list disposable getter

* Fix failing global virtual env watcher tests (#14633)

Co-authored-by: Kartik Raj <[email protected]>

* Version, change log and cherrypicks for nov release (#14696)

* change log updates

* Update gifs

* Fix for interpreter selection (#14693)

* Fix for interpreter selection

* Fix linting errors

* Minor tweak to property removal

* Cherry pick "Bind function to correct this for workspace syms" (#14743)

* Fix #14674: Enable overriding "pythonPath" in the launcher

Fix #12462: Update launch.json schema to add "python" and remove "pythonPath"

Split the "pythonPath" debug property into "python", "debugAdapterPython", and "debugLauncherPython".

Do most debug config validation on fully expanded property values via resolveDebugConfigurationWithSubstitutedVariables().

Add fixups for legacy launch.json with "pythonPath".

* Point release change log and version update (#14750)

* Point release change log and version update

* Fix process picker (#14700)

* Workaround VSCode bug for process picker

* Fix how we pass in icons to VSCode

* update change log with cherry pick

Co-authored-by: Kartik Raj <[email protected]>

Co-authored-by: Joyce Er <[email protected]>
Co-authored-by: Kartik Raj <[email protected]>
Co-authored-by: Jake Bailey <[email protected]>
Co-authored-by: Pavel Minaev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog No news entry required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants