版本发布 8
## Changes: * 2dfeabc9f2ced43ebc672a6a7b85a99917694581 Published 1.1.410 * 79cc195a205ca526c3b5a796d8c1f6dec431fd3b Update NODE_VERSION to '22.x' in workflow files for consistency with vscode (#11460) * 505a9bcb8780582ebe76a7b354be8f23d5e23dab Update typeshed to 483fd73dcea6f5fbc04ea602e802e798024fa2e2 (#11416) * f06cf49e40560ecdf91f68337302ceb720407ad8 Fix hang in constraint solver for cyclic TypeVar lower bounds (#11413) (#11415) * 3619ecdf4f41ede49fe297196c976d4761cf4733 Faster tokenizer (#11392) * 34c556b79362cc527431de819ce77925b49c5e1d Push pylance changes to pyright (#11396) This list of changes was [auto generated](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=14167094&view=logs).</details>
## Changes: * ad444cc7a0923cb6127279fb95fe0b576d96d0d7 Publish 1.1.408 * cba32ea0b6f34f58e18348b2dba8b5155cc6eb0c Update typeshed to latest (#11211) * 1576956c32c8b75f3202203f3cdedd21c8d3f9f7 Fix completions for typeddicts with errors (#11177) * 45159a96da28cb48539c8c0e45d358339a7e3916 Update installation.md (#11175) * 5f7ce347e8fbf80c826870b4a95395916cce3454 Update PyCharm setup documentation (#11105) * 6f3b72c148dc9db557e133b84e0f9a962e31a9b1 Fixed bug in type narrowing logic for sequence pattern matching. This addresses #11056. (#11085) * 89825e1c4e1a37653772b1e93b70a29a77cf85b4 Fixed regression that results in a false positive when using the `pydantic.dataclasses.dataclass` decorator. This addresses #11060. (#11084) * 8d9df830e04b4ab1db0734abd53512fd6e298782 Fixed issue that prevents typeshed from eliminating `typing._TypedDict`. This addresses #11081. (#11083) * 906e40aadd920ef1702f858479ac75daa1d87798 pull-pylance-with-pyright-1.1.407-20251029-180818 (#11072) * d2a4d578454f86de1e8612811746748454f95066 pull-pylance-with-pyright-1.1.407-20251024-224406 (#11059) <details><summary><b>See More</b></summary> * de803205421a78bb83d1c2e4015582fe13c6f281 Update azure-pipelines-release.yml for Azure Pipelines * e32067c4a203d2106ae0fb2333fb7482e6f15f66 Update azure-pipelines-release.yml for Azure Pipelines This list of changes was [auto generated](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13055644&view=logs).</details>
## Changes: * 276448f4d1f9bef30601a5efaf112b0df9e40f10 Fixed package-lock files * 783ee6761a96b0668476dec953196d1ff11daa98 Published 1.1.407 * f9fc2aa85a9a606b689e90bf9555bbbf41f1bb4f Updated typeshed stubs to the latest version (#11051) * 5f599f92719e68b852f0dea3cffcfae3a19f2db5 Added error reporting for unknown or unsupported config settings. This addresses #11040. (#11045) * cadded6f4a2d04ad18f5ffa4133f0adee39476b4 Fixed regression that results in `--createstub` doing nothing. This addresses #11043. (#11044) * 538053da7a6007b5b121f612a443e6ccb83675ed Fixed bug that causes a false negative when a `TypedDict` overrides a parent with `extra_items` that are not `ReadOnly` with a `ReadOnly` field. This addresses #11037. (#11038) * ba3f0d4313dae034f0d6a6b57c772052b80662d3 Fixed bug that results in a false positive when a `namedtuple` functional form is used with a field starting with an underscore and `rename=True`. This addresses #11033. (#11034) * 80eb0dccbe69361b95b0c3f821af8c3719c5b51d Fixed bug in type narrowing for literal patterns. The runtime uses equality checks, so matching against the pattern `3` cannot necessarily narrow the type to `Literal[3]`. This addresses #11026. (#11028) * b1c9ae2bb843043987486bb9914ece57484d29df Fixed bug that results in a false positive error when a `with` statement has a single parenthesized context manager. This addresses #11020. (#11024) * 346f74cb92e1258c26adbf029ffab1240655753b Fixed a bug that causes a `@dataclass_transform` to fail if the decorator returns a callback protocol rather than a `Callable`. This addresses #11015. (#11018) <details><summary><b>See More</b></summary> * 20aa20a100027682203bc17d78c809a2959f6cf2 Pull Pylance with Pyright 1.1.406 (#11010) * 9ed33cf7be6150dc53244e8d4009c06e4daedeae Fixed bug that results in a spurious error when running pyright on Python 3.14 but configured for Python 3.13 or earlier. This addresses #11003. (#11006) * 6e877ddb100364e5249f4248aa81def5de63e4e6 Changed default Python version from 3.13 to 3.14 to reflect new stable version (#11004) * 69a5d849618443d8833d8626afd8f99a1ba6d91f Fixed bug that omit `**kwargs` parameter with an unpacked TypedDict with extra items. (#10997) [ #10996 ] * ed83d58de9314533c9f577edd72bd709242235e5 Eagerly exit isEnumClassWithMembers (#10990) * 17f24b348073681e24c845539e6afa01bc98b293 Updated diagnostic message to include "standard" mode. This addresses #10988. (#10989) * 30db40b689e325d3451a644e4361b3df71d33a15 Add users to notification list for manual validation (#10984) This list of changes was [auto generated](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=12631690&view=logs).</details>
## Changes: * 308f5c0f152320401cc767d912508502688a1819 Published 1.1.406 * 38317d66f6358a951ddb162336d1ddd2a061f0fa Fixed bug that results in false positive for module attributes that are synthesized for namespace modules. This addresses #10692. (#10972) * 676cd113ff841f2cfa320743432898e68700c076 Fixed several bugs related to subscripts with unpack operators, notably when the unpack targets a tuple with a known length. This addresses #10723. (#10971) * 8996f91155836b7de44d80fd733c4c2f2cea093f Removed remaining code that was left over from PEP 637, which was rejected. * f7285d95d3f31999d6fe17db21507ee3bb302aad Added special casing in `reportUnnecessaryComparison` check for modules. This addresses #10706. (#10970) * 907028c4d284e943ac45c237037be729f8b3b7ad Added check for the use of a `NewType` in a class pattern. This addresses #10784. (#10969) * 7b28a6103e7f7ad87dd04c6650d739d7f6ceb7fb Updated typeshed stubs to the latest version (#10968) * ad557b583f8db0a4260519e91f81468780cb52f6 Fixed bug that results in incorrect behavior when `partial` is applied to a function with a positional-only parameter separator. This addresses #10954. (#10967) * 6a92d6081349456d730468a2c1477164d5ed7c22 Bump tar-fs from 2.1.3 to 2.1.4 in /packages/vscode-pyright (#10965) * b0fb77d4886a2f427468f9a1fe9bc0c6a666ccf9 Fixed bug that causes workspace edits to include annotation IDs without changeAnnotations field. (#10902) [ #10671 ] <details><summary><b>See More</b></summary> * 79ff3e3b1e7c75781787e3b1b1ef3ed6edf7c3c2 Fix literal overload completions in call arguments (#10762) * 1a46b0f006fc9841195f755841dba940164c7e7e Clarified implicit import rules in docs. * 97ae524744ccb4c624ec70eec2b44d8d1caf3090 Fix regression in symlinked files (#10944) * b122ef906bbc740711b8df805c4fc004f1b83317 Fix mypy_primer to run again (#10945) * 135fa85132f24c248c3fe1475e7e40568816083d Subtle issue with change tracking when not doing analysis (#10918) * 7905b1936a0f42642c56bae9060d9f3112faddd0 Removed "reportShadowedImports" check and associated "renameShadowedFile" action. This feature is off by default in pyright although enabled by default in pylance. (#10891) * b182c80288f76ba615acdffa15b9253c0e67fb61 Fixed bug that results in spurious errors when a wildcard import targets a traditional `TypeVar` with the same name as a PEP 695 TypeVar. This addresses #10900. (#10903) * eaa43e434b581390dce07a7d4ab95e78d6a76a08 Reduced log level for "Skipping recursive symlink" when enumerating project files. * b4a158f48a92bf6ee3da930d4e38184c28c15ca9 Clarify editable install behavior with setuptools and uv (#10888) * d64f3fa0a805b2b4d5154a64af7d1e448e424ac5 pull-pylance-with-pyright-1.1.404-20250902-204731 (#10885) * b7c1e79f414c6ff03eaba51b81c6f3794d765165 pull-pylance-with-pyright-1.1.404-20250902-173744 (#10882) This list of changes was [auto generated](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=12493856&view=logs).</details>
Bug Fixes: * Fixed a bug in the type narrowing logic for the `S in D` type guard pattern (where S is a string literal and D is a TypedDict). If the TypedDict is not closed, the absence of the key within the TypedDict definition cannot eliminate the type during narrowing. * Fixed a bug that leads to a false negative when accessing a key on a TypedDict that is defined with `extra_items=Never`. * Fixed bug that results in incorrect variance inference when a property access method uses a method-local type variable to annotate the `self` parameter. * Fixed bug that results in a false positive error under certain circumstances where the second argument for a `super` call is a union. * Fixed bug that results in a false negative when deriving from a stdlib protocol class and not implementing one or more abstract methods. * Fixed bug that results in incorrect type narrowing behavior when the second argument to an `isinstance` call includes a union (specifically with the `|` operator) within a tuple expression. * Fixed a bug that results in a spurious error when `__class__()` is assigned to `Self`. * Added missing check for unquoted self references when calling `TypeAliasType` constructor manually (as opposed to using the PEP 695 `type` syntax). * Fixed a bug that results in incorrect expansion of the `bytes` promotion type if the value is a bytes literal. * Fixed bug in type narrowing logic for class patterns in a `match` statement. Negative type narrowing was incorrect when the subject is a literal type and the class is the corresponding non-literal class. Enhancements: * Improved handling of `__slots__` members to correctly model the case where a descriptor object is stored in a `__slots__` variable. * Modified `--verifytypes` output to expand type aliases in its error messages to help diagnose "partially unknown" conditions. * Enhanced `x is ...` type narrowing logic to narrow `Any | EllipsisType` to `EllipsisType` to match `x is None` narrowing logic. * Updated typeshed stubs to the latest version. Behavior Changes: * Switched internal usage of `builtins.function`, `typing.AwaitableGenerator`, and `typing._TypedDict` to `types.FunctionType`, `_typeshed._type_checker_internals.AwaitableGenerator`, and `_typeshed._type_checker_internals.TypedDictFallback`, respectively.
Bug Fixes: * Fixed bug that results in a false positive when accessing a generic attribute from an object whose type is `type[X]`. * Fixed bug that results in incorrect type narrowing of a variable that is shadowed in an inner-scoped comprehension. * Fixed bug that results in a false positive error when referencing a class-scoped type alias defined as a callable. * Fixed bug that causes bidirectional type inference not to be used in cases where a ternary expression is assigned to an annotated instance or class variable and the ternary condition narrows the type of `self` or `cls`. * Fixed bug that results in a spurious "type already specialized" error when using a class-scoped type alias defined using a `type` statement or `TypeAliasType` constructor. * Fixed a bug that leads to a hang when a generic type alias definition refers to itself. * Fixed a bug that results in missing diagnostic details under certain circumstances where bidirectional type inference is attempted in the assignment of an attribute. * Fixed a bug that results in a false positive error when calling a function with an unpacked TypedDict with `extra_items` when additional keyword args are passed. * [From pylance] Fixed regression introduced in 1.1.399 that caused pyright CLI to fail to run on Linux systems. Enhancements: * Extended "type(x) is C" type narrowing logic to support cases where `C` is a union of types or a type variable with a union upper bound. * Added support for PEP 765, which makes it a syntax error (or warning) in Python 3.14 if a `return`, `break` or `continue` is used to exit a `finally` clause. * Added check for named tuple field names that begin with an underscore. These result in a runtime exception. Behavior Change: * Reverted a recent change that extended the `reportPrivateImportUsage` check to enforce imports from submodules whose names begin with an underscore. This change was disruptive to users of the popular `pandas` library because it exports a submodule named `_typing`. This was originally intended to be experimental or private, but it was never fully addressed. The pandas maintainers will work to fix this issue (https://github.com/pandas-dev/pandas/issues/55231) over the next year. I'm going to back out this change to pyright in the meantime.
Bug Fixes: * Fixed bug that results in a spurious type error when a ParamSpec is used in conjunction with a dataclass and a contextmanager. * Fixed recent regression that results in a false negative when calling a function with a positional-only parameter whose type is generic and has a concrete default argument value. * Fixed regression that results in an `Unknown` type evaluation where previously `Any` was generated during bidirectional type inference. * Fixed bug that results in incorrect overload resolution when an unpacked argument is of unknown length and potentially matches multiple overloads. * Fixed bug that results in a variable being displayed as "not accessed" if it's used in an argument expression for a call expression whose base type is a module or `None`. * Fixed bug that results in a hang under certain very specific circumstances involving a protocol method that has been decorated in such a way that it can no longer be bound to the owning protocol class. * Fixed a bug that contributes to inconsistent type evaluation results when using the "--threads" feature. * Fixed bug that results in incorrect "literal math" result when dividing `Literal[0]` by a negative literal int value. * Fixed a bug in "literal math" for shift operators. If the RHS value is negative, the operation is invalid, so literal math shouldn't be applied. * Fixed bug in "literal math" logic for modulo and floor divide operators that affect cases where operands have different signs. Behavior Changes: * Changed algorithm for applying type narrowing upon assignment when one or both of the declared type or assigned type contain "Any". * Removed special-casing for async functions that skips check for implicit return when the return type is `NoReturn`. Enhancements: * Updated typeshed stubs to the latest version. * Extended `reportPrivateImportUsage` to report the use of symbols imported from private submodules in a "py.typed" or stub library. * Extended the `reportUnnecessaryComparision` check to support the patterns `x is None` and `x is not None` in cases where `x` is provably disjoint in type. * Added generalized support for assignment expressions (walrus operators) for type guards. * Extended the type narrowing logic for the `x == L` type guard pattern so it supports the case where `x` is `LiteralString` and `L` is a string literal.
Bug Fixes: * [From pylance] Fix problem with partial stub service not being part of Pyright CLI. * Added additional special-casing to `x in y` type guard logic to handle `LiteralString` values. * Partially eliminated inconsistent error reporting when calling a function with a default argument that is not assignable to the declared parameter type. An error will still be reported in the case where the declared parameter type includes an unsolved type variable in most cases, but it will no longer be reported if the unsolved type variable is due to a pseudo-generic class. * Fixed bug that results in an identifier being marked "unaccessed" if it is used in an argument expression to a call whose type is possibly unbound. * Fixed bug that leads to a false negative when evaluating a call expression where the callable type is `Any` and an argument expression uses dictionary unpacking but the operands type is not a mapping. * Fixed a bug that results in an incorrect "Unknown" type evaluation under certain circumstances involving an assignment to an annotated variable within a loop. * Fixed bug that results in incorrect bidirectional type inference when using nested constructor calls for dataclasses. * Fixed a bug that results in incorrect "literal math" results when using a floor divide `//` operator with literal operands whose signs differ. * Fixed a bug that results in a hang under certain circumstances when inferring the return type of a recursive function. Enhancements: * Changed type evaluator to make a best effort to evaluate the return type of a function call even if arguments are missing. * [From pylance] Implement support for pull diagnostics in pyright. * Added code to enforce that an argument in a call expression that is unpacked is iterable. * Improved support for unused import detection for import statements that target multi-part names. Behavior Changes: * Changed the type of `__path__` from `Iterable[str]` to `MutableSequence[str]`. Both are correct, but the latter is more precise. * Improved determinism of `--threads` diagnostic output by always sorting output by file path. * Improved reproducibility of CLI diagnostics in non-threaded case by sorting output by file path.