Commit Graph

491 Commits

Author SHA1 Message Date
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
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
Eric Traut
ea8628909a Added "reportTypedDictNotRequiredAccess" diagnostic rule and split out diagnostics that pertain specifically to unguarded accesses to non-required TypedDict keys. 2021-03-27 09:28:28 -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
cb4aad13dc
Added new top-level "extraPaths" config option for pythonconfig.json that specifies the default extraPaths to use when no execution environments apply to a file. Changed settings logic to use the new default extraPaths mechanism for the "python.analysis.extraPaths" setting. (#1632)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2021-03-15 17:43:31 -07:00
Eric Traut
b86718ed0d Fixed example configuration in documentation. 2021-03-10 08:01:50 -08:00
Eric Traut
09cb091fe9 Removed support for "venv" entry in execution environments since this never really worked. Clarified in documentation that import resolution within an execution environment is not transitive. 2021-03-09 18:19:36 -08:00
Eric Traut
9ac028e7ab Fixed bug in sample code for documentation. 2021-03-07 09:12:54 -08:00
Eric Traut
ee2b18986e Added more documentation for "implied else narrowing". 2021-03-07 09:12:06 -08:00
Eric Traut
adabd54bf8 Changed reportOverlappingOverload to be an error in strict mode. 2021-03-05 09:23:23 -07:00
Eric Traut
acdefc550c Updated documentation on type narrowing to cover "Narrowing for Implied Else". 2021-03-05 09:07:26 -07:00
Eric Traut
af4426c4d6 Clarified default value for reportOverlappingOverload setting in docs. 2021-03-04 17:48:45 -07:00
Eric Traut
a192486099 Renamed "--ignore-external" to "--ignoreexternal" for consistency. Removed undocuemented "!" mechanism for invoking this functionality. 2021-03-03 00:51:18 -07:00
Vlad Emelianov
dc7382d52f
Add --ignore-external CLI flag (#1564)
Co-authored-by: Eric Traut <eric@traut.com>
2021-03-03 00:42:37 -07:00
Eric Traut
e6f8dbf4fa
Implemented command-line switches for pythonplatform and pythonversion. These are overridden by pyrightconfig.json settings. (#1529)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2021-02-23 17:05:13 -07:00
Eric Traut
36d499cada Further clarified in the typed libraries docs that “from .A import X” form is honored only in “__init__.py”. 2021-02-23 01:10:51 -07:00
Eric Traut
b5017de462 Updated typed library documentation to explicitly mention import statements of the form “from . import A” and “from .A import X”. 2021-02-23 01:02:15 -07:00
Eric Traut
68fca4eab6 Added "reportOverlappingOverload" diagnostic rule, splitting out a few checks that were previously in the "reportGeneralTypeIssue" rule. This allows for finer-grained control over these overload checks. 2021-02-20 09:28:57 -07:00
Richard Höchenberger
2e1b01f866
Fix typo in import (#1476) 2021-02-12 07:03:58 -08:00
Eric Traut
36c168c1ae Changed the reportUnboundVariable default severity from "warning" to "none" when typeCheckingMode is "off". There were too many complaints of false positives from users who have no interest in type checking. 2021-02-05 21:57:48 -08:00
Eric Traut
77410d86e5 Updated typing guidance for libraries documentation based on @JelleZijlstra's feedback. 2021-02-02 20:54:00 -08:00
Simon Hawkins
0977764a7e
Update typed-libraries.md (#1369)
Fixed minor typos in documentation.
2021-01-13 16:55:27 -08:00
Eric Traut
3dc83c0b1a Fixed minor typos in documentation. 2021-01-06 07:38:29 -08:00
Eric Traut
d6206e6b61 Updated git hook to refer to a more recent version of pyright. 2021-01-03 16:11:16 -08:00
Eric Traut
f9db4dcc8a Updated README to refer to PEP 647. 2021-01-03 12:13:20 -08:00
Alexey Shamrin
ec7bf81cb8
correct useLibraryCodeForTypes CLI argument (#1322) 2020-12-28 07:46:39 -08:00
Eric Traut
51387b95cd Added documentation for the default severity levels for each type checking mode (off, basic and strict). 2020-12-27 21:50:35 -08:00
Eric Traut
fb4a4e92bd Added new diagnostic rule "reportUnusedCoroutine" that reports an error if the result returned by an async function is not consumed (awaited, assigned to a variable, etc.). This detects and reports a common error when using async coroutines. 2020-12-26 22:30:49 -08:00
Eric Traut
b1d9ab7002 Added a new diagnostic rule called "reportInvalidTypeVarUse" that flags errors when TypeVars are used incorrectly. In particular, it flags the use of a single instance of a TypeVar within a generic function signature. 2020-12-11 22:28:19 -08:00
Eric Traut
cf1a5790d2 Implemented new diagnostic rule reportUnusedCallResult that checks whether a call expression's results are consumed. If the results are None or Any, no diagnostic is produced. 2020-11-25 19:50:31 -08:00
Eric Traut
a44e254c32 Added support for new reportUnsupportedDunderAll diagnostic rule. It checks for unsupported manipulations of __all__. 2020-11-25 16:07:59 -08:00
Eric Traut
1601a177cd Added new diagnostic rule "reportFunctionMemberAccess" that reports an attempt to access, set or delete non-standard attributes of function objects. 2020-11-19 17:19:22 -08:00
Eric Traut
8cb9bfca41 Updated out-of-date information in type-stubs.md documentation. 2020-11-17 17:47:17 -08:00
Eric Traut
258202af72 Added more documentation about type narrowing and type guards. 2020-11-11 14:54:37 -08:00
Eric Traut
5e5e55449e Changed re-export logic for type stub and py.typed modules to honor the clarification that was recently added to PEP 484. Previously, any import that used an "as" clause was considered to be re-exported. Now, symbols are re-exported only if the "as" clause is redundant (i.e. it is of the form import A as A or from A import X as X). 2020-11-01 08:54:09 -08:00
Eric Traut
9046794205 Removed recently-added "reportInvalidTypeVarUse" diagnostic rule and associated checks. After further discussion, we decided that there are legitimate cases where a TypeVar can appear only once in a function signature. 2020-10-21 09:59:36 -07:00
Eric Traut
bb04ffa6be Added new diagnostic rule "reportInvalidTypeVarUse" that controls reporting of TypeVars that appear only once in a function signature. By default it is off in basic type checking mode but on in strict mode. 2020-10-19 13:30:06 -07:00
Eric Traut
246ff993e7 Fixed bug in decorator annotation documentation. 2020-10-14 20:14:08 -07:00
Eric Traut
57175e8d3a Did another editing pass on the typed library documentation for readability and consistency. 2020-10-02 23:56:37 -07:00
Eric Traut
af01be3244 Fixed documentation for building pyright. 2020-10-02 11:00:26 -07:00
Eric Traut
b2882fd6be Added support for the __all__ += <module>.__all__ idiom for mutating the __all__ value. This idiom is used by numpy. 2020-10-02 10:55:24 -07:00
Eric Traut
05cdaf9344 Added missing section on type aliases within typed library documentation. 2020-09-29 15:16:48 -07:00
Eric Traut
67e94f4c8a Fixed markdown rendering issue in docs. 2020-09-29 15:04:51 -07:00
Eric Traut
1cb2a3a950 Added detailed documentation for the "--verifytypes" option. 2020-09-29 15:03:14 -07:00
Eric Traut
dc5cd387fc Implemented new "verifytypes" command-line option that analyzes a py.typed package and reports missing or partially-unknown types. 2020-09-28 14:49:32 -07:00
Eric Traut
b6cd5eedae Fixed missing JSON field in command-line documentation. 2020-09-28 14:34:29 -07:00
Eric Traut
5d44a7e35d Updated import resolution documentation to accurately reflect recent changes related to py.typed packages. 2020-09-23 14:20:23 -07:00
Eric Traut
6378f7761f Changed reveal_type to use an information diagnostic severity rather than warning. Added support in CLI for information diagnostic severity. These were previously dropped. 2020-09-16 10:11:30 -07:00
Eric Traut
006f5d60d1 Changed python.analysis.logLevel to use "Information" rather than "Info" for consistency with Python extension. 2020-09-14 14:44:18 -07:00
Eric Traut
f72711b07b Added support for new "reportWildcardImportFromLibrary" diagnostic rule that checks for the use of wildcard imports from non-local modules. By default, it is reported as a warning, but in strict mode it is an error. 2020-09-12 20:31:25 -07:00
Eric Traut
6356575664 Changed the behavior of the command-line version of pyright when file specs are passed on the command line. Previously, file specs couldn't be used in conjunction with a config file. Now a config file is used, but the specified file specs override the "include" section of the config file. 2020-09-11 00:27:57 -07:00
Eric Traut
cea376e59b Added new diagnostic rule "reportPropertyTypeMismatch" that verifies that the type of the input parameter to a property's setter is assignable to the return type of the getter. 2020-09-05 14:55:12 -07:00
Eric Traut
0a65625e03 More documentation improvements. 2020-09-04 14:51:40 -07:00
Eric Traut
4fa40fba75 Minor tweak to documentation. 2020-09-04 14:32:38 -07:00
Eric Traut
6591dafce0 Documented the JSON output when "--outputjson" command-line option is used. 2020-09-04 14:30:14 -07:00
Jake Bailey
9e231b1292
Extensibility updates in threading and fourslash, add completion context (#995) 2020-09-02 19:01:49 -07:00
Eric Traut
9e46548fc5 Added new "reportMissingTypeArgument" diagnostic rule and enabled it by default in "strict" mode. It generates a diagnostic when a generic class or generic type alias is used in an annotation with no type arguments provided. Also fixed a bunch of inaccurate settings defaults in pyright's package.json. 2020-09-01 15:59:31 -07:00
Jake Bailey
da39a2a78a
Convert repo into a lerna monorepo, add a validation workflow (#978) 2020-08-28 19:46:48 -07:00
Eric Traut
295a6dd306 Changed capitalization of the python.analysis.logLevel setting so it matches Pylance. The settings code in Pyright is case insensitive, but the JSON editor emits a warning if the case doesn't match. 2020-08-20 09:17:32 -07:00
Eric Traut
07001963c2 Fixed documentation bug. 2020-08-15 16:14:04 -07:00
Eric Traut
605bcc482c Added support for narrowing types based on the pattern "A.B == <literal>" and "A.B != <literal>" when A has a union type and all members of the union have a field "B" with a declared literal type that discriminates one sub-type from another. 2020-08-15 16:11:23 -07:00
Eric Traut
b59542c6ed Improved command-line documentation to clarify that individual files specified on the command line will cause the config file to be ignored. 2020-08-14 23:07:23 -07:00
Eric Traut
9e1a67c418 Added more documentation about type concepts relating to mutable container types. 2020-08-12 12:29:13 -07:00
Eric Traut
7808935fa7 Added support for "useLibraryCodeForTypes" option in config file. It overrides the client setting of the same name or the "--lib" command-line option.
Fixed several bugs in logging for config errors.
2020-08-10 11:28:50 -07:00
Jake Bailey
b89504d593
Add python.analysis.autoImportCompletions to control auto-import completions (#917) 2020-08-05 16:00:11 -07:00
Eric Traut
109e2dfd71 Added new diagnostic rule "reportInvalidStubStatement" (on by default in strict mode, off otherwise) that reports diagnostics for statements that should not appear within a type stub file. 2020-08-04 22:02:56 -07:00
Eric Traut
997fd7d57c More docs improvements. 2020-08-02 14:50:14 -07:00
Eric Traut
c7dfba390d More docs improvements. 2020-08-02 14:48:48 -07:00
Eric Traut
b7ae207558 Small improvements to documentation. 2020-08-02 14:20:07 -07:00
Eric Traut
2ade4f0aeb Removed redundant documentation from configuration.md. 2020-07-30 18:52:17 -07:00
Eric Traut
63c9b5b691 Fixed a few typos in the inference documentation. 2020-07-27 21:03:20 -07:00
Eric Traut
f844bd2f1c Added new diagnostic rule "reportIncompatibleVariableOverride" which is similar to "reportIncompatibleMethodOverride" except that it reports incompatible overrides of variables (non-methods). 2020-07-26 10:32:21 -07:00
Eric Traut
dcfcd09a1e Updated CI docs. 2020-07-22 21:54:10 -07:00
Joe Paris
36e4fb3a30
Fixed typo (#876)
Fixed minor typo on line 33.
2020-07-22 17:45:07 -07:00
Eric Traut
2002520d0b Moved CI documentation to its own page. 2020-07-22 16:55:50 -07:00
Eric Traut
d687708503 Updated "getting started" documentation to include an example git hook definition. 2020-07-22 16:53:34 -07:00
Eric Traut
0cb83d36c8 Renamed setting "pyright.useLibraryCodeForTypes" to "python.analysis.useLibraryCodeForTypes" for compatibility with Pylance. The older setting name is still supported but will be removed in the future. 2020-07-16 15:58:09 -07:00
Eric Traut
3581910469 Improved documentation for useLibraryCodeForTypes setting. 2020-07-16 15:49:16 -07:00
Eric Traut
579fb7be69 Fixed an outdated statement in the configuration documentation. 2020-07-16 10:09:43 -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
Eric Traut
c80b8af3aa Updated "getting started" docs. 2020-07-11 14:40:01 -07:00
Eric Traut
5e4cbeca63 Fixed a few markdown issues in import resolution documentation. 2020-07-11 14:00:20 -07:00
Eric Traut
5526b9aafe More tweaks to import resolution documentation. 2020-07-11 13:42:17 -07:00
Eric Traut
19c8a47ff8 Changed Pyright import resolution order to match that described in PEP 561. In particular, stubs in stubPath are now searched prior to user code, and third-party typeshed stubs are searched only after installed packages are searched for stub packages and inline stubs. There is one place where Pyright's import resolution still differs from a strict interpretation of PEP 561: it searches stdlib typeshed stubs first (unless typeshedPath is defined, in which case it searches there). This is more consistent with the way the Python interpreter resolves stdlib types. 2020-07-11 13:39:32 -07:00
Eric Traut
5a57aaa14f Added more details to the import resolution documentation. 2020-07-11 12:53:17 -07:00
Eric Traut
9505d1b242 Added new section on debugging import resolution problems. 2020-07-11 12:40:29 -07:00
Eric Traut
ef1b4d8441 Missed a file. 2020-07-11 12:35:29 -07:00
Eric Traut
69c0841d7a Updated Pyright documentation for import resolution so it is more complete and better reflects the logic implemented in the code. 2020-07-11 12:35:05 -07:00
Eric Traut
f6200f9887 Switched "pyright.typeCheckingMode" to "python.analysis.typeCheckingMode" for compatibility with Pylance. 2020-07-05 15:28:37 -07:00
Eric Traut
faf4464ae0 Tweaked internals documentation for clarity. 2020-06-30 23:56:16 -07:00
Eric Traut
863721687b Added support for the new Python extension setting for pythonPath. This mechanism replaces the soon-to-be-deprecated "python.pythonPath" setting. 2020-06-21 11:03:40 -07:00
Eric Traut
cf794e30d5 Added documentation for python.analysis.logLevel setting. 2020-06-18 21:40:43 -07:00
Eric Traut
998304dc78 If the pythonPlatform or pythonVersion are not specified, they are now initialized based on the current platform and configured python interpreter. 2020-05-24 22:56:55 -07:00
Eric Traut
fcdaeba35e Updated documentation. 2020-05-24 00:36:06 -07:00
Eric Traut
500da74c69 Removed reportTypeshedErrors diagnostic rule. It no longer makes sense given how errors are being reported. 2020-05-23 14:00:50 -07:00
Jake Bailey
0a0cd61f85
Use docstrings from source code, fix references showing in libraries, add information level, client override support (#685) 2020-05-22 14:02:54 -07:00
Eric Traut
6f30005de1 Tweaked settings documentation to make it clear that we're deprecating pyright.openFilesOnly. Added backward compatibility support for python.analysis.openFilesOnly. 2020-05-15 15:42:27 -07:00
Jake Bailey
1d56d6765f
Fix windows bug, add PEP 604 printing, fix unused variable action, add stubPath and diagnosticMode (#673) 2020-05-15 13:01:55 -07:00
Heejae Chang
8e32a2d345
Introduced UnboundVariable and UndefinedVariable diagnostic rules and refactored auto import and add tests (#663) 2020-05-08 18:55:32 -07:00
Jake Bailey
11918674e7
Add extraPath support, accept minor versions in version_info, make completion extension async (#662) 2020-05-07 16:52:53 -07:00
Eric Traut
921de3097e Added support for "python.analysis.autoSearchPaths" setting. If enabled (as it is by default), it automatically adds "src" to the import search paths. It is common for workspaces to contain a directory by this name. 2020-04-25 14:26:46 -07:00
Hugues Valois
a97d8f155d
Add diagnostic for missing imported source file. (#636)
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
2020-04-21 16:24:53 -07:00
Eric Traut
c1fb36b50b Documented bash script for upgrading pyright and running it as part of CI. 2020-04-15 10:59:17 -07:00
Eric Traut
a0b48358f5 Implemented new setting "pyright.disableOrganizeImports". 2020-04-12 02:10:20 -07:00
Eric Traut
fa34df5306 Added new pyright.typeCheckingMode setting for VS Code extension that allows you to set the default rule set for type checking. Three values are supported: "off", "basic", and "strict". This setting can be overridden in the pyrightconfig.json file with the typeCheckingMode config key. 2020-04-08 00:44:56 -07:00
Eric Traut
aae44cbdb3 Added "reportGeneralTypeIssues" setting, which is set to "error" by default. Users can optionally change it to "warning" or "none". 2020-04-01 22:48:24 -07:00
Heejae Chang
4b194b0431
added auto venv detection, LS extension points, auto detection on library changes and more tests added. (#574)
auto venv detection makes sure pyright automatically exlude virtual environment from user codes
LS extension points lets plug in such as intellicode to extend what shows up in completion list
auto detection on library let pyright to refresh automatically when new packages are installed/removed.

more test coverage on code fix, new features and etc
2020-03-20 12:17:25 -07:00
Eric Traut
93804d3c07 Implemented "Restart Server" command. 2020-03-08 12:17:19 -07:00
Eric Traut
909f3e6408 Added "verboseOutput" config setting, allowing verbose logs to be enabled when used with VS Code extension. 2020-03-01 16:37:05 -08:00
Jake Bailey
02bdbdee07 Revert markdown changes, restore .vscode for server (#115) 2020-02-25 12:57:54 -08:00
Jake Bailey
8d2cca7289 Mass reformat ts/js/md with ESLint quick fixes and prettier (#113) 2020-02-24 16:52:23 -08:00
Eric Traut
3c8176542a Reverted default value of 'reportMissingTypeStubs' setting from 'warning' to 'none'. 2020-02-17 16:31:10 -07:00
Eric Traut
d3221ca343 Made a few small improvements to documentation. 2020-02-17 01:16:30 -07:00
Heejae Chang
b1e0ff81dd
made reportMissingTypeStub diagnostics warning by default and some refactoring around code actions. (#507)
* enable generate type stub diagnostic (and hence code action) on by default as "warning"

* refactored code action code a bit
2020-02-11 00:39:21 -08:00
Eric Traut
d7ded12962 Made small improvements to internals docs. 2020-02-04 13:08:58 -08:00
Eric Traut
e03712be1c Added new configuration setting reportImplicitStringConcatenation. 2020-01-09 00:38:23 -08:00
Eric Traut
897b0894af Added new setting reportUnknownArgumentType that emits an error or warning when an argument's expression type is unknown or partially unknown. 2020-01-05 22:02:05 -07:00
Eric Traut
d87356c076 Added reportSelfClsParameterName setting and defaulted it to warning. 2019-12-24 13:30:57 -07:00
Eric Traut
c39bca52a1 Added ".venv" and ".git" to default exclude paths. 2019-12-17 01:17:01 -07:00
Eric Traut
83be6ecfbe Added missing documentation for reportDuplicateImport. 2019-12-13 22:18:29 -08:00
Eric Traut
736545c21f Added new section to documentation that talks about type inference. 2019-12-13 22:11:47 -08:00
Eric Traut
a982b02e64 Added new configuration option "reportDuplicateImports" that generates an error or warning when a symbol or module is imported more than once in a source file. 2019-12-13 21:22:56 -08:00
Eric Traut
697997fa6f Added default excludes of **/node_modules and **/__pycache__ because these are almost never intended to be scanned for tracked source files. 2019-12-08 12:43:21 -08:00
Eric Traut
45f86b2965 Fixed a few punctuation issues. 2019-11-30 10:53:46 -08:00
cshesse
bd8212861a
Update configuration.md 2019-11-30 10:50:30 -08:00
cshesse
be084b15df
type: ignore 2019-11-24 09:19:15 -08:00
Eric Traut
cd93a97931 Exposed the useLibraryForTypes setting on the command line through a "--lib" switch. 2019-11-22 21:13:22 -08:00
Eric Traut
c0b6f99ae7 Added new 'outputjson' command-line option that formats output in JSON format. 2019-11-21 00:30:44 -08:00
Eric Traut
ad17925f50 Added new VS Code experimental setting "useLibraryCodeForTypes". If enabled, pyright will attempt to extract type information from library implementation files. 2019-11-19 21:50:27 -08:00
Eric Traut
4e559d327a Added config feature "reportAssertAlwaysTrue". It flags errant assert statements. 2019-11-17 18:02:46 -08:00
Saugat Acharya
8a9479552d
Update getting-started.md
- Remove double quotes before comment
- Highlight `pyrightconfig.json`
2019-11-17 19:01:04 +05:45
Eric Traut
894cdbd52b Added new VS Code setting "pyright.openFilesOnly", which is set to true. 2019-11-15 18:37:14 -08:00
Eric Traut
90caa3159e Renamed expressionEvaluator to typeEvaluator and typeAnalyzer to checker to better reflect their new roles. 2019-11-10 16:56:15 -08:00
Eric Traut
7be19b6a52 Expanded isinstance support (for both the reportUnnecessaryIsInstance switch and type constraints) to also support issubclass. 2019-10-24 23:22:03 -07:00
Eric Traut
358abe62e4 Added code to command-line version to report a non-zero exit code if the config file couldn't be read or parsed. 2019-10-23 23:34:27 -07:00
Eric Traut
41058eb22b Added config switch for reportUnknownLambdaType. 2019-10-04 23:39:04 -07:00
Eric Traut
3d9c094918 Added support for enableTypeIngoreComments switch. 2019-09-26 19:50:07 -07:00
Eric Traut
294cc3d12c Fixed some typos in documentation. 2019-09-26 19:38:48 -07:00
Eric Traut
0d9274a00e Updated configuration sample to include exclusion of node_modules and __pcache__. 2019-09-14 13:09:22 -07:00
Eric Traut
92a0b6e4be Completely eliminated postParseWalker, moving all name binding into the binder module. 2019-09-12 21:43:25 -07:00
Eric Traut
a5db38d69e Renamed "semantic analyzer" to "binder".
Moved import detection from post-parse walker into parser.
2019-09-12 18:02:12 -07:00
Eric Traut
797c790a42 Implemented reportUnnecessaryCast feature. 2019-09-05 17:40:25 +00:00
Eric Traut
f1c823ae5c Minor update to internals documentation. 2019-09-05 10:37:12 +00:00
Eric Traut
f272d78de8 Updated command-line documentation. 2019-09-05 00:42:08 +00:00
Eric Traut
1f3ed05adc Documented recent features. 2019-09-04 23:54:19 +00:00
Eric Traut
058d984755 Added new setting "pyright.disableLanguageServices" in VS Code extension for disabling language service features. 2019-08-16 22:51:50 -07:00
Eric Traut
7dc7e4e059 Implemented new "reportUnnecessaryIsInstance" check, which reports cases where isinstance is used where it's possible to determine that the result is always true or false. 2019-08-10 00:00:18 -07:00
Eric Traut
1d5475bfcb Added support for new rule: strictParameterNoneValue. 2019-08-04 15:18:51 -07:00
Eric Traut
bf9f25db7d Added wildcard support for include, exclude, ignore and strict paths in config filel. 2019-08-03 23:01:47 -07:00
Eric Traut
ec87aaea63 Fixed small bug in documentation. 2019-08-02 20:47:03 -07:00
Eric Traut
85a3eaf63c Added new rule "reportCallInDefaultInitializer" that reports usage of function calls within default value initialization expressions. 2019-08-02 16:50:18 -07:00
Eric Traut
3c9954eb30 Added "--dependencies" command-line switch that reports import dependency information for all source files that were analyzed. 2019-07-27 12:58:14 -07:00
Eric Traut
9e12d3e944 Updated implementation of reportPrivateUsage check to differentiate between protected class members (single underscore) and private class members (double underscore). 2019-06-24 11:50:35 -06:00
Eric Traut
f24806a985 Added new "strict" configuration setting. 2019-06-17 16:54:52 -06:00
Luca Dorigo
a13a3595de
Fix small typo that made list display incorrectly 2019-05-27 11:03:02 +02:00
Eric Traut
e71f64ac4a Added support for new config options: reportUnusedImport, reportUnusedClass, reportUnusedFunction, and reportUnusedVariable. 2019-05-23 20:31:23 -07:00
Eric Traut
866615aa5d Minor tweak to documentation. 2019-05-23 16:18:57 -07:00
Eric Traut
4213dd9211 Added documentation for "Never" internal type. 2019-05-23 16:16:37 -07:00
Eric Traut
f66856b503 Updated docs for new file-level comment. 2019-05-21 10:29:45 -07:00
Eric Traut
87030c7a06 Updated documentation to reflect new exit code behavior. 2019-05-16 20:28:04 -07:00
Eric Traut
7d5ff66df2 Added config options strictListInference and strictDictionaryInference. 2019-05-15 22:59:32 -07:00
Eric Traut
e55bee2c09 Updated getting-started instructions. 2019-05-11 19:53:25 -07:00
Eric Traut
b92873b2dd Added "reportConstantRedfinition" config option. 2019-05-11 19:28:23 -07:00
Eric Traut
01de6d61ed Added new config option "reportIncompatibleMethodOverrode". 2019-05-10 23:05:30 -07:00
Eric Traut
2f148e88a7 Small tweaks to version printing code. 2019-05-09 08:21:22 -07:00
Oleg Butuzov
76d464aaad --version cli argument added to pyright 2019-05-09 16:41:54 +03:00
Eric Traut
76697a8252 Added support for "reportUntypedNamedTuple" switch. 2019-05-01 18:43:45 -07:00
Eric Traut
71ffa702ed Renamed reportUnknownParameter to reportUnknownParameterType. Added reportUnknownVariableType and reportUnknownMemberType. 2019-04-28 22:20:29 -07:00
Eric Traut
955074c634 Added documentation for new strict mode. 2019-04-28 12:59:19 -07:00
Eric Traut
93595c1720 Added new config switch "reportUnknownParameter" to control reporting of unknown input and return parameter types. 2019-04-28 01:51:22 -07:00
Eric Traut
375e35e56d Added a bunch of verbose diagnostic information to help resolve import resolution issues. 2019-04-27 19:04:37 -07:00
Eric Traut
b3b7e76705 Added detection and reporting of invalid escape sequences in text literals. Added "reportInvalidStringEscapeSequences" to control reporting. 2019-04-21 11:10:41 -07:00
Eric Traut
ce813deed2 Implemented reportOptionalOperand switch.
Implemented stricter type checking related to binary and unary operations.
2019-04-19 23:33:01 -07:00
Eric Traut
9a08af039f Added "reportOptionalContextManager" config switch. 2019-04-18 19:59:59 -07:00
Eric Traut
2abd802fe6 Added new config feature: reportUntypedBaseClass. 2019-04-18 07:45:50 -07:00
Eric Traut
49a4f3452a Added new config option "reportPrivateUsage". 2019-04-16 19:03:39 -07:00
Eric Traut
1541046d7d Added configuration switch that enables reporting of import cycles. 2019-04-16 13:59:56 -07:00
Eric Traut
65239ba766 Added new config switch to control reporting of uses of Optional type as an iterable. 2019-04-15 23:14:39 -07:00
Eric Traut
21320b0288 Replaced --timing command-line switch with --stats, which prints out more information. 2019-04-14 17:44:44 -07:00