Commit Graph

5397 Commits

Author SHA1 Message Date
Eric Traut
c58d75c021
Fixed bug that can result in incorrect type evaluation behaviors if a call to type is used within a loop. This addresses #9023. (#9024) 2024-09-17 19:05:20 -07:00
Eric Traut
a56a4ecfcd Published 1.1.381 2024-09-17 15:52:44 -07:00
Erik De Bonte
06ab7a8899
Update Unicode range tables to match Unicode 16.0 (#9020) 2024-09-17 12:13:14 -07:00
Bill Schnurr
ea18695c34
Add new vscode signing (#8977) (#9019)
Add new vscode signing, make sure signature file is different from the source manifest file.
When publishing to marketplace reuse artifacts for VSIX, instead of downloading from github
Include new manifest and signature files when publishing to marketplace
2024-09-17 10:43:59 -07:00
Eric Traut
c20e613319
Fixed a bug that results in spurious "variable not allowed in type expression" errors when a type alias is used in a loop in both a type expression and a value expression. This addresses #9017. (#9018) 2024-09-17 10:01:45 -07:00
Rich Chiodo
e353c9dec5
Put back logic of recreating the background analysis token on every schedule analysis (#9016)
* Recreate the cancellation token every time we start analysis like we used to before

* Refactor how token is generated to match old way of doing things
2024-09-16 17:33:02 -07:00
Eric Traut
1eb1bc739a
Fixed a bug that results in a false positive type error and confusing error message when assigning to a class variable that uses Self in its type definition. This addresses #9011. (#9013) 2024-09-16 15:28:59 -07:00
Eric Traut
a203953bfe
Fixed bug that results in a confusing error message extension referencing a missing __set__ method when assigning to a class variable that is not a descriptor object. This addresses #9011. (#9014) 2024-09-16 15:28:13 -07:00
Rich Chiodo
e94fa867c5
Allow venvPath to be set in settings.json (#9007)
* Allow venvPath to be set on command line or in settings whether or not it's set in config file

* Fix setting the venvPath in the extension
2024-09-16 10:19:25 -07:00
Eric Traut
f3ed4990d3
Fixed bug that results in incorrect type narrowing when TypeIs intersects type[A] with type[B]. Previously, pyright was producing <subclass of type[A] and type[B]> but now produces type[<subclass of A and B>]. This addresses #9002 and #9003. (#9005) 2024-09-16 09:22:51 -07:00
Eric Traut
c799d9e718
Fixed bug that can theoretically result in spurious errors when evaluating expressions that involve parameter symbols. (#8999) 2024-09-15 17:59:18 -07:00
Eric Traut
fb5cc8c30c
Fixed bug that results in a spurious "symbol refers to itself" error under very specific conditions. This addresses #4513. (#8997) 2024-09-15 08:14:52 -07:00
Eric Traut
6c2812306c
Fixed bug that results in incorrect code flow involving a call to a NoReturn callable with a function decorator applied. This addresses https://github.com/microsoft/pylance-release/issues/6391. (#8996) 2024-09-14 22:43:52 -07:00
Eric Traut
ecdab9371c
Improved error message for type violation in assignment statement where the LHS is an instance variable reference. This addresses #8943. (#8994) 2024-09-14 20:38:09 -07:00
Eric Traut
7eb358a8e8 Fixed bug that results in incorrect reporting of the Python version in a deprecation diagnostic message. 2024-09-14 16:14:26 -07:00
Eric Traut
63c7c30c59
Expanded reportUnnecessaryIsinstance check to report cases where an isinstance or issubclass call always evaluates to False. This addresses #8961. (#8992) 2024-09-14 09:07:37 -07:00
Eric Traut
171f05214d
Fixed recent regression that results in incorrect type narrowing for isinstance in the negative case when using type as a filter. This addresses #8963 and #8988. (#8990) 2024-09-13 17:01:33 -07:00
Eric Traut
d3821e9e5d
Made adjustments to TypeForm behaviors based on feedback on draft PEP 747. (#8989) 2024-09-13 15:35:05 -07:00
Eric Traut
9ea762f416 Improved comment for clarity. 2024-09-13 10:01:29 -07:00
Daniel Colascione
edaeab2bc2
Mutate sourceFile imports list whenever it changes (#8986)
This change fixes a bug in which module imports stop resolving after
file edits that change the set of modules a file imports.

Previously, in _updateSourceFileImports, we would mutate the import
list of the source file we were updating only if the new imports list
was longer than the old list or any element mismatched between the old
and new lists. This behavior led to a situation in which, potentially
due to buffer editing, if the new import list was a prefix of the old
list, we would fail to call sourceFileInfo.mutate(). Consequently,
when those imports came back (perhaps due to further buffer editing)
we would skip adding them to the sourceFileInfo import list (because,
as we didn't call sourceFileInfo.mutate(), we falsely believe we still
had the imports). Because we skipped the addition logic, we would not
add the importing buffer to the importedBy lists of the imported
SourceFileInfo. If not updating the importedBy list ended up leaving
it empty, we regarded the imported source files as "not needed",
didn't parse them, and consequently failed to resolve symbols imported
from these modules.

Now, we call sourceFileInfo.mutate() when the old and new import lists
differ in any way, restoring correct behavior under buffer edits that
remove imports.
2024-09-13 09:58:56 -07:00
Eric Traut
c3580db832
Fixed a bug that results in incorrect narrowing of types for TypeIs user-defined type guard in certain cases when variable type is a union. This addresses #8966. (#8981) 2024-09-12 22:31:55 -07:00
Eric Traut
10b372d777
Fixed a bug that results in incorrect evaluation of a variable in a doubly-nested loop that is assigned a value in an assignment expression. This addresses #8979. (#8980) 2024-09-12 19:08:35 -07:00
Eric Traut
dd3ba0a96a
Fixed recent regression that results in a false positive error when attempting to assign the expression type(Any) to type type[Any]. This addresses #8973. (#8976) 2024-09-12 12:49:41 -07:00
Stella
a0ecfe25d6
Pull Pylance with Pyright 1.1.380 (#8969)
* Push pylance changes to pyright

* Update typeForm4.py
2024-09-11 16:36:53 -07:00
Eric Traut
0d92942a42
Fixed bug that results in incorrect type narrowing for sequence patterns in the negative (fall-through) case when the subject is a tuple with an unbounded entry. This addresses #8967. (#8968) 2024-09-11 14:30:16 -07:00
Eric Traut
d91a24b595 Published 1.1.380 2024-09-10 14:15:50 -07:00
Eric Traut
e1fd479eaf Updated typeshed stubs to the latest version. 2024-09-10 13:52:56 -07:00
Eric Traut
8698e60c1b
Removed support for custom callable type guard pattern. Now that typeshed defines this with a TypeIs, we no longer require custom logic here. This addresses #8944. (#8954) 2024-09-10 13:47:00 -07:00
Eric Traut
c83e30e0a5
Fixed several inconsistencies and bugs in the isinstance type narrowing code involving callables. (#8953) 2024-09-10 13:20:35 -07:00
Eric Traut
358d7dbff7
Fixed a bug that results in incorrect type narrowing for TypeIs when it is used with a Callable type form. This addresses #8951. (#8952) 2024-09-10 11:38:44 -07:00
Eric Traut
9f38f8d6b0 Removed some debugging code that was accidentally left in. 2024-09-10 09:27:36 -07:00
Eric Traut
498dd2f945 Fixed bug that causes a crash in the language server under certain circumstances with partially-written code that has syntax errors. 2024-09-09 17:05:56 -07:00
Eric Traut
76ae26c6b7 Fixed a bug in the stub generator to avoid emitting a from __future__ import statement, which has no meaning in stub files. 2024-09-09 17:04:31 -07:00
Eric Traut
b2fc167735 Fixed a bug in the stub generator so it properly outputs type aliases that use the PEP 613 TypeAlias qualifier. 2024-09-09 17:02:52 -07:00
Eric Traut
9c52b15619
Fixed a bug that results in incorrect type narrowing for the x is ... (ellipsis) type guard pattern. This addresses #8939. (#8940) 2024-09-09 11:35:05 -07:00
Eric Traut
ed761d9298
Fixed bug that results in incorrect type narrowing for the in (containment) operator when the filter includes class objects (instances of type). This addresses #8866. (#8935) 2024-09-08 17:21:48 -07:00
Eric Traut
8faec96982
Fixed a bug that leads to incorrect type narrowing with isinstance or TypeIs when the filter type (the second argument to isinstance) is a subclass of type. This addresses #8691 and #8686. (#8934) 2024-09-08 16:47:42 -07:00
Eric Traut
d1f9cdc1b3
Did another simplification pass for isinstance type narrowing. This brings isinstance narrowing more closely in line with TypeIs narrowing. (#8931) 2024-09-08 15:51:41 -07:00
Eric Traut
df4037979f Moved AssignTypeFlags enumeration from typeUtils to typeEvaluatorTypes module, which is a more appropriate place. 2024-09-08 14:24:46 -07:00
Eric Traut
9b40da59e6
Did another simplification pass for isinstance type narrowing. This fixes a number of inconsistent behaviors involving metaclasses. (#8929) 2024-09-08 13:26:10 -07:00
Eric Traut
6c051ca03f
Simplified check for unnecessary isinstance call. Removed a bunch of redundant code and fixed a number of bugs in the process. (#8928) 2024-09-08 09:39:59 -07:00
Eric Traut
ff60144691
Removed some redundant code from the isinstance type narrowing code path. (#8925) 2024-09-07 18:01:00 -07:00
Eric Traut
5994b3a5dc
Fixed a bug that leads to a false positive "default value is specified as ..." when using --verifytypes and the function has a decorator applied that uses a ParamSpec. This addresses #8905. (#8924) 2024-09-07 12:07:19 -07:00
Eric Traut
af65844b00
Added support for custom metaclasses that derive from ABCMeta. Classes instantiated from such metaclasses are now treated as abstract. This addresses #8910. (#8923) 2024-09-07 09:29:08 -07:00
Eric Traut
8191861840 Changed behavior to allow a value with type _AnnotatedAlias to be used with an implicit __getitem__ call even though this type is not documented or declared in typeshed. This addresses #8916. 2024-09-06 11:18:28 -07:00
Eric Traut
05435baad8
Removed support for python-2 raise statements with comma-delimited operands. (#8915)
Removed redundant logic for checking exception type in `raise x from y` statements.
Changed behavior of raise evaluation logic to allow type of exception to be `Never`. This addresses #8911.
2024-09-06 08:58:05 -07:00
Eric Traut
d841fb9e91
Changed the behavior of the dictionary expansion operator (**) when used in an argument expression for a call and the operand is a TypedDict. It now takes into account the fact that a (non-closed) TypedDict can contain additional keys with object values. This new behavior is consistent with mypy. This addresses #8894. (#8908) 2024-09-05 09:56:57 -07:00
Eric Traut
97f02dff47
Fixed recent regression that results in a false positive error under very specific circumstances involving a function with a TypeVar used in both a contravariant and covariant context and combined by union with other types in the contravariant context. This addresses #8864. (#8906) 2024-09-05 09:15:48 -07:00
Eric Traut
342d4af99f Minor function rename for clarity. No functional change. 2024-09-05 08:22:52 -07:00
Eric Traut
eeec0ecea2
Added performance optimization to better handle the case where a tuple expression contains thousands of entries. This is not typically found in hand-written code, but it can appear in computer-generated code. This addresses https://github.com/microsoft/pylance-release/issues/6351. (#8903) 2024-09-04 21:56:03 -07:00
Eric Traut
12d5fe168f
Fixed a bug that results in an incorrect type evaluation of a higher-order function that is passed an overloaded function. This addresses #8898. (#8900) 2024-09-04 17:21:31 -07:00
Eric Traut
49235d38ba
Fixed a bug that causes incorrect type narrowing of expressions used within a tuple expression in the subject expression of a match statement. This addresses #8897. (#8899) 2024-09-04 16:46:25 -07:00
Eric Traut
9287bfa5f8
Fixed a bug that results in a false positive error during protocol matching because writable class variables defined in a named tuple or a frozen dataclass were considered read-only. This addresses #8829. (#8896) 2024-09-04 14:44:49 -07:00
Heejae Chang
2fecb178fd
removed duplicated code and use same method to create default workspace key (#8893) 2024-09-04 11:23:40 -07:00
Eric Traut
56183a3de4
Fixed recent regression that results in a false positive under certain specific circumstances involving higher-order functions that return generic callable types. This addresses #8852. (#8892) 2024-09-04 10:55:00 -07:00
Eric Traut
bf2c2bd7c5
Fixed a recent regression that results in a false positive type error when converting certain constructors (such as for the class defaultdict) to a callable type. This addresses #8840. (#8890) 2024-09-04 10:14:14 -07:00
Eric Traut
dda4b84b75
Fixed a recent regression that results in incorrect type evaluation when using a two-argument form of super() and the second argument is type[Self]. This addresses #8763. (#8889) 2024-09-04 08:13:39 -07:00
Eric Traut
8312965d54 Published 1.1.379 2024-09-03 16:40:12 -07:00
Eric Traut
7abaf1996a
Fixed a bug that results in confusing hover information for an attrs … (#8883)
* Fixed a bug that results in confusing hover information for an attrs field that uses a converter. This addresses #8881.

* Restored previous behavior for modules.
2024-09-03 13:49:03 -07:00
Eric Traut
c29f903809 Fixed bug that results in incorrect type evaluation when assigning a recursive type alias to a tuple or list. This addresses #8879. 2024-09-02 14:29:44 -07:00
Eric Traut
386b7fe0a5 Added check for concatenated bytes and str literals. This addresses #8871. 2024-09-01 17:45:21 -07:00
Eric Traut
689857dcf2
Added provisional support for draft PEP 747 and the TypeForm special form. (#8875) 2024-09-01 12:03:42 -07:00
Eric Traut
4773ded01f
Fixed a bug that can result in difficult-to-reproduce type evaluation errors when modifying code in your editor and using pyright as a language server. (#8873) 2024-09-01 08:14:44 -07:00
Eric Traut
e43b6af921
Incorporated a bunch of code cleanup and refactoring changes from a side branch in preparation for new functionality. (#8872) 2024-08-31 16:09:35 -07:00
Eric Traut
a1a83f114a Fixed bug that results in the incorrect type when the Callable special form is used in a value expression. 2024-08-30 14:51:31 -07:00
Eric Traut
c979baf30b Updated some diagnostic strings to refer to "type expression" rather than "type annotation" since they apply to some cases that don't involve annotations. 2024-08-30 14:51:09 -07:00
Erik De Bonte
ce64adc17b
Pull Pylance with Pyright 1.1.378 (#8851) 2024-08-28 16:05:36 -07:00
dependabot[bot]
2fa36386d0
Bump webpack from 5.90.1 to 5.94.0 in /packages/pyright (#8845)
Bumps [webpack](https://github.com/webpack/webpack) from 5.90.1 to 5.94.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.90.1...v5.94.0)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-27 20:55:52 -07:00
Eric Traut
9c003e9ff0 Published 1.1.378 2024-08-27 20:43:42 -07:00
Eric Traut
79a46a8dea
Fixed a bug that results in a false negative when overloads overlap due to default values. (#8844) 2024-08-27 14:26:36 -07:00
Eric Traut
2e11a3c6b9 Did a cleanup pass on overload tests, giving them better names. 2024-08-27 14:00:22 -07:00
Eric Traut
4dc82f79ff
Fixed bug that results in a reportIncompatibleMethodOverride diagnostic being reported in the wrong location in some cases involving decorators. This addresses #8842. (#8843) 2024-08-27 09:20:48 -07:00
Eric Traut
6c45f06e55
Fixed a bug that resulted in incorrect evaluation when converting a constructor to a callable and the constructed class has a metaclass with a __call__ method whose cls parameter is annotated with type[T]. This addresses https://github.com/microsoft/pylance-release/issues/6297. (#8837) 2024-08-26 14:04:12 -07:00
Eric Traut
e87bda9f02
Changed the default value of the disableBytesTypePromotions setting from false to true. It has been over two years since PEP 688 was accepted, so it's time for us to stop treating bytes as an alias for bytes | bytearray | memoryview. This is a breaking change and may require an update to the pyright configuration for some code bases. This addresses #8834. (#8835) 2024-08-26 11:40:16 -07:00
Eric Traut
bdea6d0064
Added new type utils function isLiteralLikeType and fixed a few literal-related bugs that were masked by other logic. (#8828) 2024-08-25 09:43:28 -07:00
Eric Traut
ecef512ade Improved consistency of error messages that involve type mismatches. Switched to the (now standardized) term "assignable". 2024-08-25 09:33:05 -07:00
Eric Traut
9e21b36ddc Minor code clean-ups from working branch. No functional change. 2024-08-25 09:30:31 -07:00
Eric Traut
acc52c7420
Fixed bug that results in a crash in very specific circumstances that involve binding a method parameterized by a function-scoped ParamSpec. This addresses #8823. (#8824) 2024-08-23 19:31:04 -07:00
Eric Traut
020dea1381
Added some code improvements from a working branch: (#8822)
* Added some code improvements from a working branch:
* Created a shortened "fileId" for each source file. This reduces memory used for tracking symbols and TypeVars that are scoped to files.
* Removed some unused or redundant code.
* Added assertNever calls to catch potential bugs.
* Renamed a few symbols for consistency and readability.
* Improved handling of literal type expressions that are lazily parsed.
* Refactored literal type printing into a utility module.

* Fixed style issue.
2024-08-23 18:13:12 -07:00
PylanceBot
ce3d4c1fb7
[PylanceBot] Pull Pylance with Pyright 1.1.377 (#8811)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-08-22 15:04:13 -07:00
PylanceBot
ede08a0211
[PylanceBot] Pull Pylance with Pyright 1.1.377 (#8808)
* pull-pylance-with-pyright-1.1.377-10512633325

* remove duplicate line

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bill Schnurr <bschnurr@microsoft.com>
2024-08-22 12:26:42 -07:00
Eric Traut
16879a1839
Fixed a bug that results in false negatives for errors in argument expressions used in a call to functools.partial in some cases. This same issue also causes symbols accessed in these arg expressions to not be marked as referenced. This addresses #8807. (#8809) 2024-08-22 10:48:21 -07:00
Rich Chiodo
38b1bd29c6
Ensure default version and platform only once (#8802)
* Ensure default version and platform only once

* Refactor execEnv creation to after everything else

* Fix tests to do the same thing as service

* Comment missing .

* Default python version to behave as it did before
2024-08-21 16:12:36 -07:00
Eric Traut
a9bd905060 Fixed bug that results in incorrect logging of the pythonVersion string. This addresses #8798. 2024-08-21 08:47:48 -07:00
Eric Traut
2876baefd8 Published 1.1.377 2024-08-20 18:40:51 -07:00
Eric Traut
89193935f1
Added unreachable code reporting for case statements that are never matched based on type analysis. (#8788) 2024-08-20 08:04:53 -07:00
Eric Traut
c8be6d8ab6 Updated typeshed stubs to the latest version. 2024-08-19 20:59:46 -07:00
Eric Traut
1a7ad15591 Integrating some code cleanups done on a working branch. 2024-08-19 20:53:11 -07:00
Eric Traut
a93b66f06a
Fixed bug that results in a false positive error under very specific conditions involving a recursive type alias that is defined in terms of another type alias. This addresses #8784. (#8785) 2024-08-19 11:26:53 -07:00
Eric Traut
0b2dc24b79
Changed type checking logic to retain a reference to default expressions in function signatures, including synthesized signatures (such as __init__ methods in dataclasses). This allows the original default value expression to be printed in error messages and language server strings. This addresses #8781. (#8783) 2024-08-19 10:04:17 -07:00
Eric Traut
48bb33b46b
Fixed a bug that leads to incorrect type evaluation in certain specific conditions involving a function decorator with an return type inferred from an inner function parameterized by a ParamSpec. This addresses #8779. (#8780) 2024-08-17 09:00:40 -07:00
Eric Traut
bea4dc91b5
Fixed a bug that leads to a crash when --pythonversion and --threads CLI options are used together. This addresses #8775. (#8776) 2024-08-16 21:42:03 -07:00
Eric Traut
c42a1587b4
Fixed a bug that results in a false positive error when assigning a TypeGuard[T] or TypeIs[T] to a supertype of bool (like int). This addresses #8769. (#8771) 2024-08-16 00:06:36 -07:00
Eric Traut
ea55470da5
Fixed bug that results in a crash under certain circumstances when a ParamSpec without a scope is used illegally to specialize a class. This addresses #8757. (#8768) 2024-08-15 19:07:42 -07:00
Eric Traut
deaf2641cf Refactored binary operator code for readability. No functional change. 2024-08-13 22:46:55 -06:00
Eric Traut
7fd5ed20be Published 1.1.376 2024-08-13 17:56:41 -06:00
Eric Traut
796a483119
Fixed bug that leads to a hang under certain circumstances involving deeply-nested higher-order functions. This addresses #8723. (#8752) 2024-08-13 09:21:14 -06:00
Eric Traut
c9a4eb2252
Changed behavior for protocols that have methods with method-scoped type variables. These are no longer treated as free type variables during protocol matching, so they can be used to support rank-2 polymorphism. This behavior is not currently dictated by the typing spec, but it is more consistent with mypy. This addresses #8685. (#8751) 2024-08-12 23:55:05 -06:00
Eric Traut
cef8bbb903
Fixed bug that leads to false positive error when a protocol has a read-only property a class has a Final variable. This addresses #8744. (#8747) 2024-08-11 19:50:02 -06:00
Eric Traut
aff4bfbfa3 Did some code cleanup with unpacked tuples and TypeVarTuples. 2024-08-11 00:38:15 -06:00