Kevin Coffey
e296cd58ee
Add support for type narrowing of NamedTuple fields with "is None" ( #3271 )
...
* Add support for type narrowing of NamedTuple fields with is None.
* Add description for `x.y is None` narrowing
Fix capitalization for filename of sample in test.
2022-03-29 19:59:55 -06:00
Eric Traut
189f0314bb
Another attempt at formatting
2022-03-20 14:35:38 -06:00
Eric Traut
fadeea36b4
Updated diagnostic rule table so it groups basic and strict diagnostics.
2022-03-20 14:34:42 -06:00
Eric Traut
d28c481535
Added new diagnostic check reportUnusedExpression
to catch bugs like a == 4
when a = 4
was intended.
2022-03-13 15:25:18 -06:00
Eric Traut
77dc80f48a
Clarified the role of __all__
in the libraries documentation.
2022-03-11 18:11:55 -07:00
Eric Traut
2aeac06f5e
Updated comments doc to talk about reportUnnecessaryTypeIgnoreComment.
2022-03-11 17:55:20 -07:00
Eric Traut
4cbd352d39
Added support for per-line suppression of diagnostics using # pyright: ignore
comment. This also supports rule-specific suppression using a list of diagnostic rules, as in # pyright: ignore [reportGeneralTypeIssues]
.
2022-03-11 09:47:41 -07:00
Eric Traut
a4900ebd03
Extended support for narrowing of index expressions to include those with negative subscripts, such as a[-1]
. This is supported for all supported type guard patterns.
2022-03-05 01:35:17 -07:00
Eric Traut
faecce31ad
Updated library guidance to clarify that submodules under a private module are also considered private.
2022-03-04 17:52:51 -07:00
Eric Traut
c9b9676e21
Updated package type verifier to differentiate between "unknown" and "ambiguous" types.
2022-02-24 15:12:36 -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
dc24fab779
Changed strictParameterNoneValue
to default to true rather than false. This reflects the updated guidance in PEP 484, which indicates that type checkers should not assume that a default argument of None
should imply an Optional
type.
2022-02-21 17:54:31 -07:00
Eric Traut
4d75f59065
Fixed typo in documentation.
2022-02-19 14:11:16 -07:00
Eric Traut
92b4028cd5
Changed the behavior of the package type verifier so it does not flag unannotated class or instance variables if a parent class provides a type annotation for a variable of the same name. The type is inherited in this case. Also updated the library guidance to reflect this change.
2022-02-11 10:25:48 -08:00
Jelle Zijlstra
3cc4e6ccdd
Document reveal_type() and reveal_locals() ( #2996 )
...
reveal_locals() was not documented anywhere, which may be part of why so few people know about it.
Happy to put this somewhere else if you prefer.
2022-02-05 19:21:30 -08:00
Eric Traut
94db5376c1
Added the ability to add new symbols to builtins
by simply adding a type stub file named __builtins__.pyi
locally.
2022-02-02 19:27:12 -08:00
Eric Traut
10a122ccd6
Fixed error in documentation for reportInvalidTypeVarUse.
2022-01-29 07:54:18 -08:00
Eric Traut
6776c0ce86
Fixed bug in documentation for reportMissingImports.
2022-01-29 00:05:40 -08:00
Eric Traut
a03acb0f41
Changed import resolution order to more closely match PEP 561. Typeshed stdlib type stubs are now resolved later in the import resolution process, after all local modules and modules within the python environment.
2022-01-27 22:57:30 -08:00
Eric Traut
b69843cf03
Updated type inference documentation to eliminate a statement that was leading to some confusion.
2022-01-27 13:20:55 -08:00
Eric Traut
b740ddfae5
Added new diagnostic check "reportMatchNotExhaustive" which reports cases where a match
statement doesn't exhaustively cover all cases.
2022-01-23 12:49:27 -08:00
Eric Traut
da81cdf22f
Updated documentation to cover the new # pyright: basic
comment.
2022-01-19 12:53:07 -08:00
Eric Traut
163ef21c3c
Changed "reportMissingSuperCall" to be off by default in strict mode.
2022-01-14 14:13:49 -08:00
Eric Traut
62ac83694e
Implemented a new diagnostic check "reportMissingSuperCall" that checks for __init__
, __init_subclass__
, __enter__
and __exit__
methods that fail to call through to their parent class(es) methods of the same name. This is a common source of bugs. The check is disabled by default in basic mode but enabled by default in strict mode.
2022-01-14 11:55:23 -08:00
Eric Traut
4934e906d5
Added new diagnostic check reportInconsistentConstructor
that checks for inconsistent input signatures between __new__
and __init__
methods.
2022-01-12 11:31:33 -08:00
Eric Traut
f9f4c34b5e
Added new diagnostic check reportUnnecessaryTypeIgnoreComment
that emits a diagnostic when a # type: ignore
comment has no effect.
2022-01-09 11:16:22 -07:00
Eric Traut
17f37a2482
Fixed a typo in the documentation.
2022-01-06 13:02:31 -07:00
Eric Traut
130c1cc055
Changed type guard logic that involves is
operator and literals to be limited to bool
and enum literals. It was making unsafe assumptions for other forms of literals.
2022-01-06 09:13:05 -07:00
Eric Traut
4fe3f1f7c0
Improved type narrowing for x == L
pattern to include x is L
, since they are equivalent. Likewise, extended x.y == L
pattern to include x.y is L
.
2022-01-05 15:19:37 -07:00
Eric Traut
c09480adb7
Updated CI script to make it clear that the latest pyright version should be used.
2022-01-03 17:43:08 -07:00
Eric Traut
d74b89a758
Added support for new type narrowing pattern: len(x) == L
and len(x) != L
where x
is a tuple or union of tuples and L
is a literal integer value.
2022-01-01 13:31:10 -07:00
Eric Traut
046eab4a8d
Added support for bool(x)
type guard.
2021-12-31 14:23:56 -07:00
Eric Traut
2f616204d9
Added documentation for pyright's overload matching algorithm.
2021-12-13 15:00:17 -08:00
Eric Traut
211ebe44dd
Changed class pattern matching behavior to support narrowing of Any
or Unknown
, exempting this case from the general "never narrow Any" rule.
2021-12-12 14:54:59 -08:00
Eric Traut
50b31d533f
Improved documentation.
2021-12-10 00:06:35 -08:00
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