mirror of
https://github.com/microsoft/pyright.git
synced 2024-10-26 10:55:06 +03:00
Fixed a few typos in the pyright documentation.
This commit is contained in:
parent
e4e08c359f
commit
f8eb114de3
@ -57,7 +57,7 @@ c = "" # Error
|
||||
This example introduces the _Optional_ type, which is the same as a union with `None`.
|
||||
|
||||
```
|
||||
d: int | None = 4
|
||||
d: Optional[int] = 4
|
||||
d = b
|
||||
d = None
|
||||
d = "" # Error
|
||||
@ -203,14 +203,14 @@ def func1(val: Foo | Bar):
|
||||
else:
|
||||
reveal_type(val) # Foo
|
||||
|
||||
def func2(val: int | None):
|
||||
def func2(val: float | None):
|
||||
if val:
|
||||
reveal_type(val) # int
|
||||
reveal_type(val) # float
|
||||
else:
|
||||
reveal_type(val) # int | None
|
||||
reveal_type(val) # float | None
|
||||
```
|
||||
|
||||
In the example of `func1`, the type was narrowed in both the positive and negative cases. In the example of `func2`, the type was narrowed only the positive case because the type of `val` might be either `int` (specifically, a value of 0) or `None` in the negative case.
|
||||
In the example of `func1`, the type was narrowed in both the positive and negative cases. In the example of `func2`, the type was narrowed only the positive case because the type of `val` might be either `float` (specifically, a value of 0.0) or `None` in the negative case.
|
||||
|
||||
### Aliased Conditional Expression
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user