Eric Traut
c5788d4916
Implemented support for type guards that are based on a local variable that is assigned an expression that narrows the type of the assigned expression. Some limitations apply. For details, refer to https://github.com/microsoft/pyright/blob/main/docs/type-concepts.md#narrowing-based-on-local-variable .
2021-12-09 23:56:44 -08:00
Eric Traut
e267b8adec
Improved handling of x in y
type guard to handle the case where y
is a tuple.
2021-12-08 00:17:46 -08:00
Eric Traut
7e59a19eaa
Updated library guidance doc to clarify point of confusion about import forms.
2021-12-01 08:57:29 -08:00
Eric Traut
28d60e62ae
Updated command-line documentation for consistency.
2021-11-29 22:31:14 -08:00
Jos Verlinde
8d32784230
extend documentation on JSON ( #2635 )
...
copying the information provided as answer to https://github.com/microsoft/pyright/issues/2634
2021-11-29 13:20:41 -08:00
Eric Traut
ed84eb7b36
Changed reportPropertyTypeMismatch to be disabled by default in all diagnostic modes.
2021-11-27 17:08:01 -08:00
Eric Traut
280d95cd80
Updated documentation for reportUnusedVariable.
2021-11-24 16:05:53 -08:00
Elijah K
c70cee87ea
Update configuration.md ( #2519 )
...
Links the description of the `executionEnvironment` option. Would have partially prevented a question in #2518 .
2021-10-30 11:09:25 -07:00
Eric Traut
cc7216e66e
Changed text representation of inferred type of self
and cls
parameters to Self@ClassName
. This is more consistent with the emerging standard for an explicit Self
type.
2021-10-29 21:21:32 -07:00
Eric Traut
ef773d2407
Added "--skipunannotated" option for command-line version of pyright. If specified, pyright skips type analysis of functions and methods that have no parameter or return type annotations. Return types of functions are also never inferred from the function implementation. This matches the default behavior of mypy and allows for more efficient analysis of complex code bases that are only partially annotated.
2021-10-22 23:17:29 -07:00
Eric Traut
3fbb23a5c4
Fixed typo in command-line docs.
2021-10-15 10:01:29 -07:00
Eric Traut
5f0317229c
Updated documentation for pythonPlatform to include "All".
2021-10-15 09:43:28 -07:00
Eric Traut
9976ff0436
Fixed a misleading statement in the documentation about the strict
config setting.
2021-10-14 14:56:49 -07:00
Eric Traut
38bd56b130
Clarified directory for tests
2021-10-12 00:10:29 -07:00
Eric Traut
06c69907fe
Added instructions for running tests.
2021-10-12 00:06:34 -07:00
Eric Traut
1cbb690b11
Added support for new type guard pattern: x[I] is None
and x[I] is not None
where x
is a tuple or union of tuples with known lengths and entry types and I
is an integer.
2021-10-06 22:48:14 -07:00
Eric Traut
ff55b895f9
Added new diagnostic check "reportMissingParameterType" that checks for function and method input parameters that are missing a type annotation.
2021-10-06 21:55:12 -07:00
Eric Traut
6107de9090
Added new "--warnings" command-line option that generates an exit code of 1 if one or more warnings are emitted. By default, only errors generate an exit code of 1.
2021-10-06 20:12:15 -07:00
Eric Traut
dbe41fa4d2
Made a few small improvements to the documentation.
2021-09-26 12:10:05 -07:00
Eric Traut
3fa5299614
Changed code that converts types to textual representation to prepend a tilde ("~") character for the inferred type of a "self" or "cls" parameter.
2021-09-24 20:01:48 -07:00
Eric Traut
14ad02575f
Extended reportCallInDefaultInitializer diagnostic check to disallow list, set or dict expressions in default argument expression.
2021-09-16 21:22:31 -07:00
Eric Traut
9035f64c71
Added reportPrivateImportUsage diagnostic rule, which reports usage of a symbol from a py.typed library that is not intended to be re-exported by the library's author. The rule is on by default in basic type checking mode but can be disabled. Completion provider no longer offers these symbols as completion suggestions.
2021-09-12 01:10:57 -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
Kyle Kovacs
ad0e8acf14
Add missing strictSetInference
option to table ( #2263 )
...
The `strictSetInference` row was missing from the Diagnostic Rule Defaults table.
2021-09-03 15:44:28 -07:00
Eric Traut
2202af33a7
Improved readability of docs.
2021-08-30 09:44:14 -07:00
Omer Tuchfeld
9edf6d2d1a
Fix docs/configuration.md misleading case sensitive Pyproject.toml
typo ( #2238 )
...
Creating `Pyproject.toml` as it is currently shown in the docs title will not work,
because the file name is case sensitive. It should be exactly `pyproject.toml`
2021-08-28 07:37:25 -07:00
Denis Eliseev
475a44273c
Update type-concepts.md ( #2230 )
2021-08-26 08:33:12 -07:00
Eric Traut
0bf45ea2ed
Added support for new type narrowing pattern for discriminating among tuples. The pattern is V[I] == L
or V[I] != L
where I
is an integer literal, L
is another literal value, V
is a tuple with a known length and a type at index I
that is declared as a literal type.
2021-08-06 23:17:21 -07:00
Eric Traut
f842817006
Updated docs for reportUnsupportedDunderAll.
2021-07-17 09:41:29 -06:00
Eric Traut
295db6af56
Disabled reportUnitializedInstanceVariable in strict mode, as intended.
2021-07-14 16:46:21 -06:00
Eric Traut
2156f2eb73
Implemented "reportUninitializedInstanceVariable" diagnostic check that looks for instance variables that are not initialized in the class body or constructor.
2021-07-14 16:13:49 -06:00
Eric Traut
845764c5ae
Modified reportUnnecessaryIsInstance
diagnostic to never report always-false conditions because the type checker no longer generates such conditions.
2021-07-03 10:03:49 -06:00
Eric Traut
c23d563a17
Took another swing at making the markdown processor in github do what I want in the typed-libraries documentation.
2021-06-22 10:01:50 -07:00
Eric Traut
bf66ff22c5
Fixed a few typos and formatting issues in typed-libraries documentation.
2021-06-22 10:00:30 -07:00
Eric Traut
0440272219
Added support for type narrowing conditional expressions of the form a is False
, a is True
, a is not False
and a is not True
.
2021-06-18 17:01:59 -07:00
Eric Traut
562a6b4848
In basic type checking mode, enabled the following diagnostic checks by default: reportOptionalSubscript, reportOptionalMemberAccess, reportOptionalCall, reportOptionalIterable, reportOptionalContextManager, and reportOptionalOperand.
2021-06-16 18:43:58 -07:00
Arnav Jindal
68a0cb85e0
Update command-line.md to emphazise flags with arguments ( #1980 )
...
* Update command-line.md
* Update command-line.md
* Update command-line.md
2021-06-12 09:20:57 -07:00
Yuichi Tateno (secon)
e09560c3ea
Fixing wrong type int
to str
of type-concepts.md ( #1958 )
2021-06-07 15:53:48 -07:00
Eric Traut
0f9d308827
Added documentation for conditional types reported with "*".
2021-05-29 15:43:09 -07:00
Eric Traut
eced7b57bd
Added support for "tagged union" type narrowing when the conditional expression is of the form x[K] == V
or x[K] != V
where x
is a union of TypedDict objects and K
is a literal str key value that refers to a field with a literal type and V
is a literal value.
2021-05-23 23:38:04 -07:00
Eric Traut
c52c928e66
Added type narrowing support for index expressions where the index value is a string literal.
2021-05-23 23:03:05 -07:00
Eric Traut
186e444652
Added new diagnostic rule "reportIncompleteStub", which reports a diagnostic for a module-level __getattr__
function in a type stub, indicating that it's incomplete. This check was previously part of the "reportUnknownMemberType" diagnostic rule.
2021-05-15 19:23:25 -07:00
Jake Bailey
893d08be8c
Update everything for main branch rename
2021-05-13 13:26:44 -07:00
Eric Traut
320a0a2fd3
Updated documentation to indicate that some forms of subscripts are supported in type guards.
2021-04-29 08:20:19 -07:00
Eric Traut
69a0c5594a
Added support for pyproject.toml files.
2021-04-20 21:51:39 -07:00
Steve Rice
bda2a94294
Update command line directions with new output format ( #1749 )
...
Since ba901d1449 (diff-c3f0fa903325059f6e7dda1116458aafa72061ac3d1a51ddfd077a5dc0801030R394)
, the `--outputjson` result schema has changed.
2021-04-08 17:36:48 -07:00
Eric Traut
27fb622a5e
Implemented new diagnostic rule "reportUnnecessaryComparison". It checks for "==" and "!=" comparisons where the LHS and RHS types have no overlap and the LHS has no __eq__
overload. This new diagnostic rule is off by default in normal type checking mode but is on in strict mode.
2021-04-08 16:32:08 -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
karthickeyan
3b5a6d1a02
Update configuration.md ( #1707 )
...
Fixing a typo in "extraPaths" of configuration.md document
2021-03-31 10:34:48 -07:00
Andrew Grangaard
9f544885bc
fix typo in settings documentation. ( #1699 )
2021-03-29 20:21:32 -07:00