Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	lerna.json
#	packages/pyright-internal/package-lock.json
#	packages/pyright-internal/package.json
#	packages/pyright/package-lock.json
#	packages/pyright/package.json
#	packages/vscode-pyright/package-lock.json
#	packages/vscode-pyright/package.json
  • Loading branch information
DetachHead committed Jan 16, 2024
2 parents 2cf5c71 + cab9f88 commit 69c279f
Show file tree
Hide file tree
Showing 30 changed files with 17,958 additions and 18,595 deletions.
24 changes: 0 additions & 24 deletions docs/mypy-comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,30 +318,6 @@ def func2(x: list[int], y: list[str] | int):
reveal_type(v2) # pyright: "list[int | str]" ("list[list[str] | int]" is also a valid answer)
```

#### Constraint Solver: Higher-order Functions

If a generic higher-order function is passed another generic callable as an argument, pyright is able to solve the type variables for both the target function and the argument. Mypy isn’t able to handle higher-order functions.

```python
def identity(val: T) -> T:
return val


def higher_order1(cb: Callable[[S], T], arg: S) -> T:
return cb(arg)

v1 = higher_order1(identity, 1.0) # mypy generates an error
reveal_type(v1) # mypy: T, pyright: float


def higher_order2(cb: Callable[P, R], *args: P.args, **kwargs: P.kwargs) -> R:
return cb(*args, **kwargs)

v2 = higher_order2(identity, "") # mypy generates an error
reveal_type(v2) # mypy: T, pyright: str
```


### Value-Constrained Type Variables

When mypy analyzes a class or function that has in-scope value-constrained TypeVars, it analyzes the class or function multiple times, once for each constraint. This can produce multiple errors.
Expand Down
20 changes: 10 additions & 10 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"packages": [
"packages/*"
],
"version": "0.2.5",
"command": {
"version": {
"push": false,
"tagVersionPrefix": "v",
"message": "Published basedpyright %s"
"packages": [
"packages/*"
],
"version": "0.2.5",
"command": {
"version": {
"push": false,
"tagVersionPrefix": "",
"message": "Published %s"
}
}
}
}
Loading

0 comments on commit 69c279f

Please sign in to comment.