mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Added a few more minor improvements to the docs.
This commit is contained in:
parent
355361e8b3
commit
97b6231d13
@ -273,6 +273,10 @@ Many aspects of constraint solving are unspecified in PEP 484. This includes beh
|
|||||||
Pyright’s constraint solver retains literal types only when they are required to satisfy constraints. In other cases, it widens the type to a non-literal type. Mypy is inconsistent in its handling of literal types.
|
Pyright’s constraint solver retains literal types only when they are required to satisfy constraints. In other cases, it widens the type to a non-literal type. Mypy is inconsistent in its handling of literal types.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
T = TypeVar("T")
|
||||||
|
def identity(x: T) -> T:
|
||||||
|
return x
|
||||||
|
|
||||||
def func(one: Literal[1]):
|
def func(one: Literal[1]):
|
||||||
reveal_type(one) # Literal[1]
|
reveal_type(one) # Literal[1]
|
||||||
v1 = identity(one)
|
v1 = identity(one)
|
||||||
@ -289,10 +293,10 @@ As mentioned previously, pyright always uses unions rather than joins. Mypy typi
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
def func3(val1: T, val2: T) -> T:
|
def func(val1: T, val2: T) -> T:
|
||||||
...
|
...
|
||||||
|
|
||||||
reveal_type(func3("", 1)) # mypy: object, pyright: str | int
|
reveal_type(func("", 1)) # mypy: object, pyright: str | int
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Constraint Solver: Ambiguous Solution Scoring
|
#### Constraint Solver: Ambiguous Solution Scoring
|
||||||
|
Loading…
Reference in New Issue
Block a user