Commit Graph

5924 Commits

Author SHA1 Message Date
Eric Traut
bee1466d4a Fixed a bug that led to a false positive error about an "unknown type" in certain cases when using an assignment expression (walrus operator) in a loop. This addresses https://github.com/microsoft/pyright/issues/4557. 2023-01-31 16:52:11 -08:00
Eric Traut
1d461eac65 Addressed performance issue in code that includes loops and many interdependencies between variables with inferred types. The optimization involves the introduction of an incomplete type generation count that is updated when a the type cache is updated in a way that could affect previously-calculated incomplete types. This addresses https://github.com/microsoft/pyright/issues/4231. 2023-01-31 15:29:16 -08:00
Eric Traut
6df39e49fd Changed speculative type cache to return full cache entry in prep for a subsequent optimization. 2023-01-31 15:23:45 -08:00
Eric Traut
27211b8d6e Disabled type narrowing for expressions of the form "<literal> == X" and <literal> != X". These were never documented to work, and they were causing significant performance issues. Also reverted recent attempt to modify the code complexity algorithm, as this change is no longer necessary. This addresses https://github.com/microsoft/pylance-release/issues/3886#issuecomment-1410116374. 2023-01-31 07:58:17 -08:00
Eric Traut
3a97d0263b Fixed a bug in the handling of file specs (globs) used for the "include" configuration option. A directory wildcard pattern (**) was not handled correctly. This addresses https://github.com/microsoft/pyright/issues/4553. 2023-01-30 22:31:37 -08:00
Eric Traut
a503d72e0d Modified overload matching algorithm to more closely match that of mypy. In the case where one or more arguments evaluate to Any but those arguments map to parameters whose types are the same, the first overload is selected. Only in cases where an Any argument produces ambiguous results is an Unknown result produced. This addresses https://github.com/microsoft/pyright/issues/4546. 2023-01-30 21:44:09 -08:00
PylanceBot
88a32c7168
[PylanceBot] Pull Pylance with Pyright 1.1.291 (#4554) 2023-01-30 15:45:56 -08:00
Eric Traut
0176543898 Fixed a bug that led to a false negative when a backslash character was used within an expression segment of an f-string. This addresses https://github.com/microsoft/pyright/issues/4552. 2023-01-30 06:31:04 -08:00
Eric Traut
16b5b9a404 Fixed bug that resulted in a false positive when trying to assign a value of type NoneType to type[object]. This addresses https://github.com/microsoft/pyright/issues/4550. 2023-01-30 06:04:41 -08:00
Eric Traut
e5fd048b99 Improved type narrowing for truthy tests that involve int, str or bytes values. In the negative case, we can assume that the type is Literal[0], Literal[''] or Literal[b'']. 2023-01-29 11:54:05 -08:00
Eric Traut
50fadd7146 Fixed bug in command-line version of pyright that led to the inclusion of file names in the output diagnostic report in cases where diagnostics were completely suppressed for that file using the --level option. This addresses https://github.com/microsoft/pyright/issues/4549. 2023-01-29 11:09:05 -08:00
Eric Traut
38f2ceaab3 Fixed grammar in diagnostic message. 2023-01-29 10:57:30 -08:00
Eric Traut
7d65fa690e Fixed a bug that resulted in incorrect type narrowing for discriminated TypedDict types when the narrowed expression includes a member access subexpression. This addresses https://github.com/microsoft/pyright/issues/4548. 2023-01-29 09:53:43 -08:00
Eric Traut
95315d1b99 Fixed broken test case. 2023-01-29 08:02:16 -08:00
Eric Traut
248e5bd4ea Updated code complexity calculation in binder to take into account the number of unique expressions that are affected by branch and loop nodes in the code flow graph. This addresses https://github.com/microsoft/pyright/issues/4519. 2023-01-29 07:44:15 -08:00
Eric Traut
cce89d8212 Updated typeshed stubs to the latest version. 2023-01-27 22:32:36 -08:00
Eric Traut
d2643158c5 Extended the reportUnnecessaryComparison check to also handle conditions of the form x is None and x is not None. 2023-01-27 10:11:59 -08:00
Eric Traut
b17f64ddcb A few more tweaks to the documentation for consistency. 2023-01-27 09:29:38 -08:00
Eric Traut
3829e8e32d Tweaked documentation for readability. 2023-01-27 09:26:30 -08:00
Eric Traut
52ea2deac6 Fixed a bug that resulted in an infinite loop in some cases where list lists, sets or dicts were inferred loop construct. This addresses https://github.com/microsoft/pyright/issues/4535. 2023-01-27 07:51:03 -08:00
Eric Traut
83011a6672 Added filtering in hover provider for overloaded constructors. Filtering for other overloaded functions and methods was previously added, but constructors were overlooked. 2023-01-26 22:53:42 -08:00
Eric Traut
8940738e08 Added heuristic to better handle the case where a symbol is imported from two different modules, one in a try block and another in an except block. This pattern can be found in a number of libraries. This addresses https://github.com/microsoft/pyright/issues/4533. 2023-01-26 10:14:08 -08:00
Bill Schnurr
9eeeaf46c3
Adding a new setting ("formatFunctionSignature" in pyrightconfig and … (#4529)
Co-authored-by: Bill Schnurr <bschnurr@microsoft>
2023-01-26 10:02:18 -08:00
Eric Traut
f92996d62b Fixed a bug that caused a hang when a function that accepted a Callable with a ParamSpec was fed to itself as an argument. This addresses https://github.com/microsoft/pyright/issues/4524. 2023-01-25 16:30:55 -08:00
Eric Traut
8c8af6507a Fixed a bug that results in a false positive error in certain circumstances when a match statement is used within a loop. This addresses https://github.com/microsoft/pyright/issues/4526. 2023-01-25 12:40:59 -08:00
PylanceBot
0175810505
pull-pylance-with-pyright-1.1.291 (#4527) 2023-01-25 05:33:00 -08:00
Eric Traut
624fedaccb Published 1.1.291 2023-01-24 18:23:01 -08:00
Eric Traut
c6cda1f42c Added optimization to handle unions that contain large numbers of union literals. This addresses part of https://github.com/microsoft/pyright/discussions/4516#discussioncomment-4771824. 2023-01-24 15:52:47 -08:00
André Fontenele
7ca9a91823
fix: empty range for submodule fallback (#4522)
This addresses https://github.com/microsoft/pyright/issues/4521
Co-authored-by: Eric Traut <eric@traut.com>
2023-01-24 13:00:04 -08:00
Eric Traut
8c856d3098 Improved type analysis performance in some cases that involve protocol matching where the protocol incorporates an overloaded method. This partially addresses https://github.com/microsoft/pyright/discussions/4516#discussioncomment-4762888. 2023-01-24 12:53:36 -08:00
Eric Traut
b0d01a6e93 Revert "Improved type analysis performance in some cases that involve protocol matching where the protocol incorporates an overloaded method. This partially addresses https://github.com/microsoft/pyright/issues/4519."
This reverts commit cf4801e10e.
2023-01-24 12:52:50 -08:00
Eric Traut
cf4801e10e Improved type analysis performance in some cases that involve protocol matching where the protocol incorporates an overloaded method. This partially addresses https://github.com/microsoft/pyright/issues/4519. 2023-01-24 12:51:47 -08:00
Eric Traut
675fafdeb7 Removed the "draft" status of PEP 692 since it has been accepted by the SC. 2023-01-24 12:50:29 -08:00
Eric Traut
96b29389aa Fixed a bug that resulted in a false positive error when generic class with an invariant type parameter is used in specialized form as a type argument for a class with a contravariant type parameter. This addresses https://github.com/microsoft/pyright/issues/4517. 2023-01-23 19:11:35 -08:00
Eric Traut
24844047ca Fixed inconsistency within isinstance type guard logic when handling the narrowing of a type that contains a union with Any or Unknown. This addresses https://github.com/microsoft/pyright/issues/4508. 2023-01-23 18:40:11 -08:00
Eric Traut
84cf7e8f9c Revert "Fixed inconsistency within isinstance type guard logic when handling the narrowing of a type that contains a union with Any or Unknown. This addresses https://github.com/microsoft/pyright/issues/4508."
This reverts commit dd1e727929.
2023-01-23 11:10:38 -08:00
Eric Traut
dd1e727929 Fixed inconsistency within isinstance type guard logic when handling the narrowing of a type that contains a union with Any or Unknown. This addresses https://github.com/microsoft/pyright/issues/4508. 2023-01-22 21:48:35 -08:00
Eric Traut
4eef3dad90 Fixed a bug that resulted in incorrect type evaluation for a symbols within a py.typed module that is contained with a non-py.typed namespace package. This addresses https://github.com/microsoft/pyright/issues/4507. 2023-01-22 15:58:49 -08:00
Eric Traut
eca831a955 Fixed spelling for method in program.ts module. 2023-01-22 15:57:50 -08:00
Eric Traut
c0486a1663 Fixed a bug that led to a crash under certain circumstances when a dictionary expansion subexpression (**val) was used. 2023-01-22 09:07:12 -08:00
Eric Traut
0314c24133 Fixed a bug that led to a crash in certain circumstances where a TypedDict field annotation contained a circular reference to the TypedDict. 2023-01-22 09:07:12 -08:00
Erik De Bonte
591c04ec7a
Allow non-identifier characters immediately after #region (#4501) 2023-01-20 17:11:00 -08:00
Eric Traut
9fe3675562 Removed initsubclass3 test because it's not effective at catching a regression as it's designed to do. 2023-01-20 10:11:19 -08:00
Eric Traut
8d08659d22 Fixed a bug that led to the incorrect evaluation of StrEnum member types in some rare circumstances. The problem is due to a circular dependency in the enum.pyi type stub involving the StrEnum, ReprEnum and EnumMeta classes. The solution is to detect this case and defer evaluation to handle the circular dependency. This addresses https://github.com/microsoft/pyright/issues/3997. 2023-01-20 09:37:30 -08:00
Eric Traut
20fae82b48 Fixed misspelled words in comments within indentationUtils.ts 2023-01-20 08:16:41 -08:00
Eric Traut
bffc50a59d
Changed hover provider to limit its display of overloaded functions w… (#4492)
* Changed hover provider to limit its display of overloaded functions when hovering over a name that is part of a call expression. In such cases, the context of the call's arguments often provides sufficient context to select one (or in some cases, several) overloads.

* Added unit test for overload-aware hover capability.

Co-authored-by: Eric Traut <erictr@microsoft.com>
2023-01-19 09:38:03 -08:00
Eric Traut
b0fc5b0afb Moved common code from checker to parseTreeUtils so it can be used by language service providers. No functional change. 2023-01-18 19:10:10 -08:00
Eric Traut
dc4b8b45ba Fixed regression that resulted in an incorrect type evaluation of dict(a) when a is typed as Any or Unknown. This addresses https://github.com/microsoft/pyright/issues/4490. 2023-01-18 19:08:59 -08:00
Eric Traut
0659a661d0 When converting a class into a callable (by combining its __new__ and __init__ methods), capture the docstring of the constructor or class. This preserves docstrings when using a class decorator. This addresses https://github.com/microsoft/pyright/discussions/4488#discussioncomment-4721194. 2023-01-18 12:40:42 -08:00
PylanceBot
e96b3ece2b
pull-pylance-with-pyright-1.1.290 (#4489)
Co-authored-by: Bill Schnurr <bschnurr@microsoft.com>
Co-authored-by: HeeJae Chang <hechang@microsoft.com>
Co-authored-by: Erik De Bonte <erikd@microsoft.com>
Co-authored-by: Rich Chiodo <rchiodo@microsoft.com>
2023-01-18 12:01:42 -08:00