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

Browser support #514

Merged
merged 31 commits into from
Aug 6, 2024
Merged

Browser support #514

merged 31 commits into from
Aug 6, 2024

Conversation

DetachHead
Copy link
Owner

@DetachHead DetachHead commented Jul 22, 2024

doesn't address #295, this is only for the playground

microbit-matt-hillsdon and others added 17 commits August 4, 2021 13:42
I've seen it give syntax errors and basic completions.

No types are available except the one that I've rammed into the file
system as a proof of concept.

There are a couple of changes outside of the new package that need some
careful consideration.

Lots could be broken here as a variety of NodeJS modules have been
stubbed out or polyfilled.
Config loading does use the fs abstraction but not for the cwd.
We don't care so default it.
Reducing the diff between this and server.ts.
It's a syntax error so immediately scuppers things for Safari.

This seems to be sufficient to get it running. Minimal testing so far
but a big step forward.

This specific change seems safe and well tested.
Uses an abstraction over Web Workers and worker_threads. A bit of a pain
due to transferList.

It requires a bit of a dance to create the Workers, particularly as
Safari has no nested worker support. Browser clients will need updating
to the new incantation.

Also adds minimal file system operations. These are a stop-gap solution.
Interesting to see the import resolver hook and the nascent host
abstraction.
Update from upstream.

Align URI parsing in browser-server.ts with corresponding changes to server.ts (we have several more occurrences in our added FS APIs).
…r' into browser

# Conflicts:
#	packages/pyright-internal/jest.config.js
#	packages/pyright-internal/src/analyzer/backgroundAnalysisProgram.ts
#	packages/pyright-internal/src/analyzer/sourceFile.ts
#	packages/pyright-internal/src/backgroundAnalysis.ts
#	packages/pyright-internal/src/backgroundAnalysisBase.ts
#	packages/pyright-internal/src/backgroundThreadBase.ts
#	packages/pyright-internal/src/languageServerBase.ts
@DetachHead DetachHead changed the title Browser Browser support Jul 22, 2024

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@DetachHead DetachHead requested a review from KotlinIsland August 5, 2024 16:08
# Conflicts:
#	packages/pyright-internal/src/analyzer/cacheManager.ts
@DetachHead DetachHead marked this pull request as ready for review August 5, 2024 16:13

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Aug 6, 2024

Diff from mypy_primer, showing the effect of this PR on open source code:

sympy (https://github.com/sympy/sympy)
-     Type of "P" is "(condition: Unknown, given_condition: Unknown | None = None, numsamples: Unknown | None = None, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Any | BernoulliDistribution | Probability | Self@Expr | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Lambda | int | None)" (reportUnknownVariableType)
+     Type of "P" is "(condition: Unknown, given_condition: Unknown | None = None, numsamples: Unknown | None = None, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Any | BernoulliDistribution | Probability | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Lambda | Relational | Unequality | int | None)" (reportUnknownVariableType)
-     Type of "E" is "(expr: Unknown, condition: Unknown | None = None, numsamples: Unknown | None = None, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Basic | Expectation | tuple[Unknown, ...] | Sum | Self@Expr | Order | Any | Piecewise | Equality | Relational | Unequality | Integral | ExpectationMatrix | None)" (reportUnknownVariableType)
+     Type of "E" is "(expr: Unknown, condition: Unknown | None = None, numsamples: Unknown | None = None, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Basic | Expectation | tuple[Unknown, ...] | Sum | Order | Any | Piecewise | Equality | Relational | Unequality | Integral | ExpectationMatrix | None)" (reportUnknownVariableType)
-     Type of "expectation" is "(expr: Unknown, var: Unknown, evaluate: bool = True, **kwargs: Unknown) -> (Any | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None)" (reportUnknownMemberType)
+     Type of "expectation" is "(expr: Unknown, var: Unknown, evaluate: bool = True, **kwargs: Unknown) -> (Any | Unknown | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None)" (reportUnknownMemberType)
-     Type of "expectation" is "(expr: Unknown, var: Unknown, evaluate: bool = True, **kwargs: Unknown) -> (Any | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None)" (reportUnknownMemberType)
+     Type of "expectation" is "(expr: Unknown, var: Unknown, evaluate: bool = True, **kwargs: Unknown) -> (Any | Unknown | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None)" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_discrete_rv.py:39:12 - error: Operator "-" not supported for types "Any | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None" and "Any | Unknown | Expr | int"
+   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_discrete_rv.py:39:12 - error: Operator "-" not supported for types "Any | Unknown | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None" and "Any | Unknown | Expr | int"
-     Operator "-" not supported for types "Expr*" and "Expr"
-     Operator "-" not supported for types "Expr*" and "int"
+     Operator "-" not supported for types "None" and "Expr"
+     Operator "-" not supported for types "None" and "int"
-     Type of "expectation" is "(expr: Unknown, var: Unknown, evaluate: bool = True, **kwargs: Unknown) -> (Any | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None)" (reportUnknownMemberType)
+     Type of "expectation" is "(expr: Unknown, var: Unknown, evaluate: bool = True, **kwargs: Unknown) -> (Any | Unknown | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None)" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_discrete_rv.py:39:37 - error: Operator "**" not supported for types "Any | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None" and "Literal[2]"
+   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_discrete_rv.py:39:37 - error: Operator "**" not supported for types "Any | Unknown | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None" and "Literal[2]"
-     Type of "expectation" is "(expr: Unknown, var: Unknown, evaluate: bool = True, **kwargs: Unknown) -> (Any | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None)" (reportUnknownMemberType)
+     Type of "expectation" is "(expr: Unknown, var: Unknown, evaluate: bool = True, **kwargs: Unknown) -> (Any | Unknown | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None)" (reportUnknownMemberType)
-     Type of "expectation" is "(expr: Unknown, var: Unknown, evaluate: bool = True, **kwargs: Unknown) -> (Any | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None)" (reportUnknownMemberType)
+     Type of "expectation" is "(expr: Unknown, var: Unknown, evaluate: bool = True, **kwargs: Unknown) -> (Any | Unknown | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None)" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_discrete_rv.py:69:12 - error: Operator "-" not supported for types "Any | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None" and "Any | Unknown | Expr | int"
+   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_discrete_rv.py:69:12 - error: Operator "-" not supported for types "Any | Unknown | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None" and "Any | Unknown | Expr | int"
-     Operator "-" not supported for types "Expr*" and "Expr"
-     Operator "-" not supported for types "Expr*" and "int"
+     Operator "-" not supported for types "None" and "Expr"
+     Operator "-" not supported for types "None" and "int"
-     Type of "expectation" is "(expr: Unknown, var: Unknown, evaluate: bool = True, **kwargs: Unknown) -> (Any | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None)" (reportUnknownMemberType)
+     Type of "expectation" is "(expr: Unknown, var: Unknown, evaluate: bool = True, **kwargs: Unknown) -> (Any | Unknown | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None)" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_discrete_rv.py:69:37 - error: Operator "**" not supported for types "Any | Unknown | tuple[Unknown, ...] | Sum | Self@Expr | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None" and "Literal[2]"
+   /tmp/mypy_primer/projects/sympy/sympy/stats/tests/test_discrete_rv.py:69:37 - error: Operator "**" not supported for types "Any | Unknown | tuple[Unknown, ...] | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Literal[0] | None" and "Literal[2]"
-     Type of "rewrite" is "Unknown | Any | ((..., deep: bool = True) -> (BernoulliDistribution | Any)) | ((..., deep: bool = True) -> (Probability | Any)) | ((..., deep: bool = True) -> (Self@Expr | Any)) | ((..., deep: bool = True) -> (Sum | Any)) | ((..., deep: bool = True) -> (Order | Any)) | ((..., deep: bool = True) -> (Piecewise | Any)) | ((..., deep: bool = True) -> (Basic | Any)) | ((..., deep: bool = True) -> (Equality | Any)) | ((..., deep: bool = True) -> (Relational | Any)) | ((..., deep: bool = True) -> (Unequality | Any)) | ((..., deep: bool = True) -> (Lambda | Any))" (reportUnknownMemberType)
+     Type of "rewrite" is "Unknown | Any | ((..., deep: bool = True) -> (BernoulliDistribution | Any)) | ((..., deep: bool = True) -> (Probability | Any)) | ((..., deep: bool = True) -> (Sum | Any)) | ((..., deep: bool = True) -> (Order | Any)) | ((..., deep: bool = True) -> (Piecewise | Any)) | ((..., deep: bool = True) -> (Basic | Any)) | ((..., deep: bool = True) -> (Equality | Any)) | ((..., deep: bool = True) -> (Lambda | Any)) | ((..., deep: bool = True) -> (Relational | Any)) | ((..., deep: bool = True) -> (Unequality | Any))" (reportUnknownMemberType)
-     Argument type is "BernoulliDistribution | Any | Probability | Self@Expr | Sum | Order | Piecewise | Basic | Equality | Relational | Unequality | Lambda | Unknown" (reportUnknownArgumentType)
+     Argument type is "BernoulliDistribution | Any | Probability | Sum | Order | Piecewise | Basic | Equality | Lambda | Relational | Unequality | Unknown" (reportUnknownArgumentType)
-     Type of "rewrite" is "Unknown | Any | ((..., deep: bool = True) -> (BernoulliDistribution | Any)) | ((..., deep: bool = True) -> (Probability | Any)) | ((..., deep: bool = True) -> (Self@Expr | Any)) | ((..., deep: bool = True) -> (Sum | Any)) | ((..., deep: bool = True) -> (Order | Any)) | ((..., deep: bool = True) -> (Piecewise | Any)) | ((..., deep: bool = True) -> (Basic | Any)) | ((..., deep: bool = True) -> (Equality | Any)) | ((..., deep: bool = True) -> (Relational | Any)) | ((..., deep: bool = True) -> (Unequality | Any)) | ((..., deep: bool = True) -> (Lambda | Any))" (reportUnknownMemberType)

... (truncated 758 lines) ...

@DetachHead DetachHead merged commit 4fd1e27 into main Aug 6, 2024
19 checks passed
@DetachHead DetachHead deleted the browser branch August 6, 2024 12:21
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.

2 participants