Eric Traut
484faf7ba3
Added support for new reportTypeCommentUsage
diagnostic check. It flag the usage of # type: xxx
comments for functions and variables. These are still supported for backward compatibility, but they are increasingly irrelevant and will likely be deprecated in the next few years.
2022-06-09 21:00:47 -07:00
Eric Traut
c5153a557c
Minor code cleanup — improved comments, etc.
2022-06-09 17:49:28 -07:00
Eric Traut
376bf81935
Added code to invalidate virtual file system cache when resetting the language server.
2022-06-09 17:48:43 -07:00
Eric Traut
44c7bf87c5
Fixed bug that resulted in a false negative when attempting to call pop
on a TypedDict with a key that is required.
2022-06-09 15:56:48 -07:00
Eric Traut
794d151050
Added new configuration setting called "defineConstant". It allows a configuration to specify one or more identifiers that should be assigned by pyright's binder to be constant anywhere they appear. Values can be boolean (true or false) or a string. If an identifier of this value is used within a conditional statement (like if not DEBUG:
) it will affect pyright's reachability analysis for the guarded code blocks.
2022-06-08 22:01:33 -07:00
Eric Traut
9b407f6c9e
Added code to detect and flag usage of # type: xxx
comments for for
and with
statements.
2022-06-08 20:34:04 -07:00
PylanceBot
bbc4282691
pull-pylance-with-pyright-1.1.253 ( #3556 )
...
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>
2022-06-08 10:16:10 -07:00
Eric Traut
ffb0ba7144
Published 1.1.253
2022-06-08 01:16:55 -07:00
Eric Traut
4d7d70d288
Fixed a bug that resulted in a false positive when using a captured variable within an inner function or lambda and the variable has been narrowed based on a NoReturn
call within a conditional block.
2022-06-07 11:19:48 -07:00
Eric Traut
bc4fa7e22b
Fixed a bug that resulted in spurious type evaluation errors when certain circular dependencies existed between class declarations. When evaluated in certain orders, a class type was being partially constructed with a corrupt MRO. This type was then cached and used in subsequent type evaluation steps, resulting in false positive errors.
2022-06-06 23:23:46 -07:00
Eric Traut
13256b4454
Small code cleanup. No functional change.
2022-06-06 22:33:20 -07:00
Eric Traut
4e0b2b9650
Fixed a bug in the reportIncompatibleMethodOverride
check that resulted in a false negatives when the override method accepted too few positional arguments but accepted a **kwargs
parameter.
2022-06-06 21:05:18 -07:00
Eric Traut
735a89b86f
Fixed bug in the "reportIncompatibleMethodOverride" check that results in a false positive if the parent class method has one or more keyword-only parameters and the override method has a kwargs of compatible type.
2022-06-06 16:41:46 -07:00
Eric Traut
b56e6b72fe
Fixed a bug that resulted in incorrect type evaluation when an asymmetric property (where the getter type doesn't match the setter type) also has a deleter.
2022-06-06 16:08:04 -07:00
Eric Traut
09a763ccfc
Small code cleanup and addition of comment for readability.
2022-06-06 15:48:37 -07:00
Eric Traut
5b348d534f
Updated typeshed stubs to the latest version.
2022-06-06 15:15:29 -07:00
Eric Traut
672b28c927
Enhanced bidirectional type inference for constructor calls to handle the case where a generic class has no __init__
method but has a __new__
method that informs the value of one or more type variables.
2022-06-06 15:15:15 -07:00
Eric Traut
22dbd0eee3
Fixed bug in type evaluator related to the handling of a recursive type alias that is self-referential. This resulted in various strange behaviors when this bogus type alias was later used as an annotation.
2022-06-06 09:18:18 -07:00
Eric Traut
e586d6f1f1
Fixed false positive error that occurs when using an issubclass
type guard to narrow a type to an abstract base class. The resulting type should be instantiable without receiving a "cannot instantiate ABC" error.
2022-06-05 22:04:19 -07:00
Eric Traut
1b09c1aea0
Added check for partially-evaluated classes when resolving symbols.
2022-06-05 14:28:01 -07:00
Eric Traut
29ddd505c4
Fixed style issue.
2022-06-05 10:23:03 -07:00
Eric Traut
8f471fdab1
Fixed bug in "--dependencies" command-line option. When used with partial stub files, it was not emitting the correct paths.
2022-06-05 10:19:59 -07:00
Eric Traut
d9beecf93b
Fixed a bug that resulted in a false positive error when using an unpacked TypedDict for a **kwargs parameter annotation, and the caller passes an unpacked TypedDict as an argument but the argument is a subclass of the parameter's TypedDict.
2022-06-05 10:10:04 -07:00
Eric Traut
ac576bbd47
Published 1.1.252
2022-06-04 16:47:14 -07:00
Eric Traut
e7759432d8
Reduced the max number of recursive inferred function return results from 16 to 12 to address a crash (stack overflow) that appears in the pylance telemetry.
2022-06-04 16:45:22 -07:00
Eric Traut
0dff59a90b
Fixed bug that causes false positive when the evaluated type of a default argument used within a base class must be specialized for a derived class.
2022-06-04 16:37:59 -07:00
Eric Traut
1528429c42
Refactored code in code flow engine related to NoReturn call evaluation. Improved handling of calls to overloads. If all overloads are annotated with NoReturn, the call is now evaluated as NoReturn. Previously, only the last overload was considered.
2022-06-04 11:44:57 -07:00
Eric Traut
7fb190f64b
Fixed regression in code flow analysis that depends on NoReturn call evaluation.
2022-06-04 10:48:59 -07:00
Eric Traut
9d201c9256
Added code to track partially-evaluated functions and lambdas and avoid caching them as complete types.
2022-06-04 10:43:43 -07:00
Eric Traut
08209850ee
Fixed bug in lambda type evaluation so it properly detects and reports when its type is incomplete due to recursion.
2022-06-04 10:40:12 -07:00
Eric Traut
66fc5a37c0
Renamed class type flag for clarity. No functional change.
2022-06-04 10:35:12 -07:00
Eric Traut
e786c86088
Increased maximum number of declarations (assignments) to consider when inferring the type of an unannotated variable. It was previously 16, but it is now 64.
2022-06-03 17:50:54 -07:00
Eric Traut
494d03f69d
Added check for a dataclass member that lacks a type annotation but is assigned a field descriptor. This combination results in a runtime exception in the dataclass implementation.
2022-06-03 17:42:44 -07:00
Eric Traut
a56e038779
Fixed bug that resulted in a crash (due to infinite recursion) in reference provider under certain circumstances involving symbol renames.
2022-06-02 13:41:13 -07:00
Eric Traut
c6e1d8dd97
Fixed a false positive error when the special form Unpack
is used in a context other than a type annotation.
2022-06-01 10:11:08 -07:00
Eric Traut
b46034527e
Published 1.1.251
2022-05-31 23:05:39 -07:00
Eric Traut
da7195914a
Fixed a bug that resulted in a false positive error when evaluating an expression a + b
where a is a LiteralString
. For purposes of binary expression evaluation, LiteralString
should act like a str
.
2022-05-30 12:20:59 -07:00
Eric Traut
00c40c1657
Fixed a bug in completion provider that resulted in incomplete member suggestions when a LiteralString
type is used.
2022-05-30 12:19:44 -07:00
Eric Traut
c67930ec03
Fixed a bug that led to a false positive when assigning a value to an index expression where the base type of the index was inferred rather than declared.
2022-05-30 11:48:43 -07:00
Eric Traut
7dfdbf42e0
Fixed a bug that led to a false negative in some instances when assigning an inappropriate type to a TypedDict key.
2022-05-30 11:48:34 -07:00
Eric Traut
2f214aeb8e
Fixed bug that resulted in a false positive error when using ==
or !=
operator with type(None)
.
2022-05-30 11:19:47 -07:00
Eric Traut
f2328237d3
Extended the "X in Y" type narrowing to support dict
, defaultdict
and OrderedDict
classes.
2022-05-30 00:55:22 -07:00
Eric Traut
6df560a638
Fixed a bug in the isinstance
and issubclass
type narrowing code paths. They were not handling nested tuples for the second argument.
2022-05-30 00:44:56 -07:00
Eric Traut
255497446a
Fixed bug in type narrowing logic for expressions of the form "X not in Y".
2022-05-29 23:54:15 -07:00
Eric Traut
469cc162f9
Added protocol matching optimization for the case where the source type and the destination protocol are both non-generic classes. In this case, we can safely cache the protocol relationship and shortcut future checks.
2022-05-29 22:43:11 -07:00
Eric Traut
3730932513
Added small performance enhancement for protocol matching. When a protocol mismatch is detected, the remainder of the members are skipped if the caller hasn't requested detailed diagnostic information.
2022-05-29 22:42:26 -07:00
Eric Traut
4646f69a16
Removed unused import from test case.
2022-05-29 22:41:14 -07:00
Eric Traut
da3d8fdf21
Improved type verifier so it can target submodules that are installed using an editable install mechanism.
2022-05-29 13:38:31 -07:00
Eric Traut
006541d053
Added logic to better handle the case where a symbol is defined multiple times with a TypeAlias
declaration. This is an error condition, but it does occur in some stdlib type stubs if pyright is configured to use "All" for the "pythonPlatform" setting.
2022-05-29 02:03:50 -07:00
Eric Traut
ee8f7c21d6
Fixed misleading diagnostic message associated with reportUnnecessaryComparison
check when !=
operator is used in the expression.
2022-05-29 00:31:52 -07:00