Commit Graph

11 Commits

Author SHA1 Message Date
Eric Traut
d5d27505ef Updated types in documentation to use PEP 604 syntax. 2022-10-24 20:06:21 -07:00
Eric Traut
c061adb5b8 Fixed typo in documentation. 2022-02-22 16:01:28 -07:00
Eric Traut
450524d004 Added support for parameter type inference based on annotated base class method signatures and on default argument expressions. 2022-02-22 12:42:14 -07:00
Eric Traut
17f37a2482 Fixed a typo in the documentation. 2022-01-06 13:02:31 -07:00
sasano8
a1ebf82bb8
Ambiguous tuples become as specific as possible. (#2291)
The rationale is as follows.

>Tuple Expressions
>When inferring the type of a tuple expression (in the absence of bidirectional inference hints), Pyright assumes that the tuple has a fixed length, and each tuple element is >typed as specifically as possible.

```python
# The inferred type is Tuple[Literal[1], Literal["a"], Literal[True]]
var1 = (1, "a", True)

def func1(a: int):
    # The inferred type is Tuple[int, int]
    var2 = (a, a)

    # If you want the type to be Tuple[int, ...]
    # (i.e. a homogenous tuple of indeterminate length),
    # use a type annotation.
    var3: Tuple[int, ...] = (a, a)
```
2021-09-10 12:27:42 -07:00
Eric Traut
4f03ba88c0 Added configuration option "strictSetInference" which is analogous to "strictListInference" and "strictDictionaryInference" but specifically for set expressions. 2021-04-03 08:35:40 -07:00
Eric Traut
e5714b3365 Added smarter handling of empty lists ([]) and dicts ({}). Previously, these were inferred to have types list[Unknown] and dict[Unknown, Unknown], respectively. They are now provided with a known type if the variable is assigned a known list or dict type along another code path. 2021-03-24 13:50:59 -07:00
Eric Traut
b7ae207558 Small improvements to documentation. 2020-08-02 14:20:07 -07:00
Eric Traut
63c9b5b691 Fixed a few typos in the inference documentation. 2020-07-27 21:03:20 -07:00
Eric Traut
838b293a4f Small improvements to type inference documentation. 2020-07-15 00:26:02 -07:00
Eric Traut
531ebc4694 Added documentation for type inference. 2020-07-14 23:02:50 -07:00