Commit Graph

317 Commits

Author SHA1 Message Date
Eric Traut
21a67358df Specified that node.js 14.x should be used. 2022-05-21 10:47:05 -07:00
Eric Traut
42ad212d8d Added missing quotes in library documentation for __all__ statements. 2022-05-19 17:12:04 -07:00
Eric Traut
48c910d0e3 Added back git hook example for non-github users. 2022-05-19 16:04:32 -07:00
Eric Traut
4b65372d4a Changed CI integration instructions to point to the pyright-action project. 2022-05-19 15:34:10 -07:00
Eric Traut
5840e3eb7c Improved docs string for the --skipunannotated command line option. 2022-05-18 15:29:06 -07:00
Eric Traut
8d5da97ba6 More doc improvements. 2022-05-08 11:12:37 -07:00
Eric Traut
9f08b64bcd Added documentation for class and instance variables. 2022-05-08 11:09:48 -07:00
Eric Traut
3b5752431b Extended type guard for discriminated literal fields to support properties. 2022-04-29 20:39:32 -07:00
Eric Traut
2c7bcc81e1 Updated library guidance to include a small section on positional-only parameters. 2022-04-15 21:42:42 -07:00
Eric Traut
ab1fbfc0d6 Enhanced reportUnnecessaryComparison diagnostic check so it also detects cases where a function appears within a condition expression. This is a common source of programming error. 2022-04-10 23:33:41 -07:00
Eric Traut
8660a6f870
Added support for type guard based on a.b is None or a.b is not None patterns where b is a member variable that distinguishes two different classes. (#3273)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2022-04-01 11:06:53 -07:00
Eric Traut
d1e5c924bd Revert "Add support for type narrowing of NamedTuple fields with "is None" (#3271)"
This reverts commit e296cd58ee.
2022-03-29 20:02:54 -06:00
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