Skip to content

chore(deps): update python linters

Vincent Meurisse requested to merge renovate/python-linters into main

This MR contains the following updates:

Package Type Update Change Pending
autoflake dev-dependencies minor 2.0.0 -> 2.3.1
bandit (source, changelog) dev-dependencies patch 1.7.4 -> 1.7.8
black (changelog) dev-dependencies minor 23.3.0 -> 23.12.1
isort (source, changelog) dev-dependencies minor 5.10.1 -> 5.13.2
pylint (changelog) dev-dependencies minor 2.12.2 -> 2.17.7
pyright (source) dependencies patch 1.1.215 -> 1.1.361 1.1.362

Release Notes

PyCQA/bandit (bandit)

v1.7.8

Compare Source

What's Changed

New Contributors

Full Changelog: https://github.com/PyCQA/bandit/compare/1.7.7...1.7.8

v1.7.7

Compare Source

What's Changed

New Contributors

Full Changelog: https://github.com/PyCQA/bandit/compare/1.7.6...1.7.7

v1.7.6

Compare Source

What's Changed

New Contributors

Full Changelog: https://github.com/PyCQA/bandit/compare/1.7.5...1.7.6

v1.7.5

Compare Source

What's Changed

New Contributors

Full Changelog: https://github.com/PyCQA/bandit/compare/1.7.4...1.7.5

psf/black (black)

v23.12.1

Compare Source

Packaging
  • Fixed a bug that included dependencies from the d extra by default (#​4108)

v23.12.0

Compare Source

Highlights

It's almost 2024, which means it's time for a new edition of Black's stable style! Together with this release, we'll put out an alpha release 24.1a1 showcasing the draft 2024 stable style, which we'll finalize in the January release. Please try it out and share your feedback.

This release (23.12.0) will still produce the 2023 style. Most but not all of the changes in --preview mode will be in the 2024 stable style.

Stable style
  • Fix bug where # fmt: off automatically dedents when used with the --line-ranges option, even when it is not within the specified line range. (#​4084)
  • Fix feature detection for parenthesized context managers (#​4104)
Preview style
  • Prefer more equal signs before a break when splitting chained assignments (#​4010)
  • Standalone form feed characters at the module level are no longer removed (#​4021)
  • Additional cases of immediately nested tuples, lists, and dictionaries are now indented less (#​4012)
  • Allow empty lines at the beginning of all blocks, except immediately before a docstring (#​4060)
  • Fix crash in preview mode when using a short --line-length (#​4086)
  • Keep suites consisting of only an ellipsis on their own lines if they are not functions or class definitions (#​4066) (#​4103)
Configuration
  • --line-ranges now skips Black's internal stability check in --safe mode. This avoids a crash on rare inputs that have many unformatted same-content lines. (#​4034)
Packaging
Integrations

v23.11.0

Compare Source

Highlights
  • Support formatting ranges of lines with the new --line-ranges command-line option (#​4020)
Stable style
  • Fix crash on formatting bytes strings that look like docstrings (#​4003)
  • Fix crash when whitespace followed a backslash before newline in a docstring (#​4008)
  • Fix standalone comments inside complex blocks crashing Black (#​4016)
  • Fix crash on formatting code like await (a ** b) (#​3994)
  • No longer treat leading f-strings as docstrings. This matches Python's behaviour and fixes a crash (#​4019)
Preview style
  • Multiline dicts and lists that are the sole argument to a function are now indented less (#​3964)
  • Multiline unpacked dicts and lists as the sole argument to a function are now also indented less (#​3992)
  • In f-string debug expressions, quote types that are visible in the final string are now preserved (#​4005)
  • Fix a bug where long case blocks were not split into multiple lines. Also enable general trailing comma rules on case blocks (#​4024)
  • Keep requiring two empty lines between module-level docstring and first function or class definition (#​4028)
  • Add support for single-line format skip with other comments on the same line (#​3959)
Configuration
  • Consistently apply force exclusion logic before resolving symlinks (#​4015)
  • Fix a bug in the matching of absolute path names in --include (#​3976)
Performance
  • Fix mypyc builds on arm64 on macOS (#​4017)
Integrations
  • Black's pre-commit integration will now run only on git hooks appropriate for a code formatter (#​3940)

v23.10.1

Compare Source

Highlights
  • Maintenance release to get a fix out for GitHub Action edge case (#​3957)
Preview style
  • Fix merging implicit multiline strings that have inline comments (#​3956)
  • Allow empty first line after block open before a comment or compound statement (#​3967)
Packaging
  • Change Dockerfile to hatch + compile black (#​3965)
Integrations
  • The summary output for GitHub workflows is now suppressible using the summary parameter. (#​3958)
  • Fix the action failing when Black check doesn't pass (#​3957)
Documentation

v23.10.0

Compare Source

Stable style
  • Fix comments getting removed from inside parenthesized strings (#​3909)
Preview style
  • Fix long lines with power operators getting split before the line length (#​3942)
  • Long type hints are now wrapped in parentheses and properly indented when split across multiple lines (#​3899)
  • Magic trailing commas are now respected in return types. (#​3916)
  • Require one empty line after module-level docstrings. (#​3932)
  • Treat raw triple-quoted strings as docstrings (#​3947)
Configuration
  • Fix cache versioning logic when BLACK_CACHE_DIR is set (#​3937)
Parser
  • Fix bug where attributes named type were not accepted inside match statements (#​3950)
  • Add support for PEP 695 type aliases containing lambdas and other unusual expressions (#​3949)
Output
  • Black no longer attempts to provide special errors for attempting to format Python 2 code (#​3933)
  • Black will more consistently print stacktraces on internal errors in verbose mode (#​3938)
Integrations
  • The action output displayed in the job summary is now wrapped in Markdown (#​3914)

v23.9.1

Compare Source

Due to various issues, the previous release (23.9.0) did not include compiled mypyc wheels, which make Black significantly faster. These issues have now been fixed, and this release should come with compiled wheels once again.

There will be no wheels for Python 3.12 due to a bug in mypyc. We will provide 3.12 wheels in a future release as soon as the mypyc bug is fixed.

Packaging
Performance
  • Store raw tuples instead of NamedTuples in Black's cache, improving performance and decreasing the size of the cache (#​3877)

v23.9.0

Compare Source

Preview style
  • More concise formatting for dummy implementations (#​3796)
  • In stub files, add a blank line between a statement with a body (e.g an if sys.version_info > (3, x):) and a function definition on the same level (#​3862)
  • Fix a bug whereby spaces were removed from walrus operators within subscript(#​3823)
Configuration
  • Black now applies exclusion and ignore logic before resolving symlinks (#​3846)
Performance
  • Avoid importing IPython if notebook cells do not contain magics (#​3782)
  • Improve caching by comparing file hashes as fallback for mtime and size (#​3821)
Blackd
  • Fix an issue in blackd with single character input (#​3558)
Integrations
  • Black now has an official pre-commit mirror. Swapping https://github.com/psf/black to https://github.com/psf/black-pre-commit-mirror in your .pre-commit-config.yaml will make Black about 2x faster (#​3828)
  • The .black.env folder specified by ENV_PATH will now be removed on the completion of the GitHub Action (#​3759)

v23.7.0

Compare Source

Highlights
  • Runtime support for Python 3.7 has been removed. Formatting 3.7 code will still be supported until further notice (#​3765)
Stable style
  • Fix a bug where an illegal trailing comma was added to return type annotations using PEP 604 unions (#​3735)
  • Fix several bugs and crashes where comments in stub files were removed or mishandled under some circumstances (#​3745)
  • Fix a crash with multi-line magic comments like type: ignore within parentheses (#​3740)
  • Fix error in AST validation when Black removes trailing whitespace in a type comment (#​3773)
Preview style
  • Implicitly concatenated strings used as function args are no longer wrapped inside parentheses (#​3640)
  • Remove blank lines between a class definition and its docstring (#​3692)
Configuration
  • The --workers argument to Black can now be specified via the BLACK_NUM_WORKERS environment variable (#​3743)
  • .pytest_cache, .ruff_cache and .vscode are now excluded by default (#​3691)
  • Fix Black not honouring pyproject.toml settings when running --stdin-filename and the pyproject.toml found isn't in the current working directory (#​3719)
  • Black will now error if exclude and extend-exclude have invalid data types in pyproject.toml, instead of silently doing the wrong thing (#​3764)
Packaging
  • Upgrade mypyc from 0.991 to 1.3 (#​3697)
  • Remove patching of Click that mitigated errors on Python 3.6 with LANG=C (#​3768)
Parser
  • Add support for the new PEP 695 syntax in Python 3.12 (#​3703)
Performance
  • Speed up Black significantly when the cache is full (#​3751)
  • Avoid importing IPython in a case where we wouldn't need it (#​3748)
Output
  • Use aware UTC datetimes internally, avoids deprecation warning on Python 3.12 (#​3728)
  • Change verbose logging to exactly mirror Black's logic for source discovery (#​3749)
Blackd
  • The blackd argument parser now shows the default values for options in their help text (#​3712)
Integrations
Documentation
  • Add a CITATION.cff file to the root of the repository, containing metadata on how to cite this software (#​3723)
  • Update the classes and exceptions documentation in Developer reference to match the latest code base (#​3755)
pycqa/isort (isort)

v5.13.2

Compare Source

v5.13.1

Compare Source

v5.13.0

Compare Source

v5.12.0

Compare Source

  • Removed support for Python 3.7
    • Fixed incompatiblity with latest poetry version
    • Added support for directory limitations within built in git hook

v5.11.5

Compare Source

  • Fixed incompatiblity with latest poetry version

v5.11.4

Compare Source

v5.11.3

Compare Source

v5.11.2

Compare Source

v5.11.1

Compare Source

v5.11.0

Compare Source

pylint-dev/pylint (pylint)

v2.17.7

Compare Source

2.17.7 is the last release before we only support pylint 3.0.0 or superior and python 3.8 or superior.

False Positives Fixed

  • Fix a regression in pylint 2.17.6 / astroid 2.15.7 causing various messages for code involving TypeVar.

    Closes #​9069

Other Bug Fixes

  • Fix crash in refactoring checker when unary operand used with variable in for loop.

    Closes #​9074

v2.17.6

Compare Source

Other Bug Fixes

  • When parsing comma-separated lists of regular expressions in the config, ignore commas that are inside braces since those indicate quantifiers, not delineation between expressions.

    Closes #​7229

  • sys.argv is now always correctly considered as impossible to infer (instead of using the actual values given to pylint).

    Closes #​9047

  • Don't show class fields more than once in Pyreverse diagrams.

    Closes #​8189

  • Don't show arrows more than once in Pyreverse diagrams.

    Closes #​8522

  • Don't show duplicate type annotations in Pyreverse diagrams.

    Closes #​8888

  • Don't add Optional to | annotations with None in Pyreverse diagrams.

    Closes #​9014

v2.17.5

Compare Source

What's new in Pylint 2.17.5?

Release date: 2023-07-26

False Positives Fixed

  • Fix a false positive for unused-variable when there is an import in a if TYPE_CHECKING: block and allow-global-unused-variables is set to no in the configuration.

    Closes #​8696

  • Fix false positives generated when supplying arguments as **kwargs to IO calls like open().

    Closes #​8719

  • Fix a false positive where pylint was ignoring method calls annotated as NoReturn during the inconsistent-return-statements check.

    Closes #​8747

  • Exempt parents with only type annotations from the invalid-enum-extension message.

    Closes #​8830

Other Bug Fixes

  • Fixed crash when a call to super() was placed after an operator (e.g. not).

    Closes #​8554

  • Fix crash for modified-while-iterating checker when deleting members of a dict returned from a call.

    Closes #​8598

  • Fix crash in invalid-metaclass check when a metaclass had duplicate bases.

    Closes #​8698

  • Avoid consider-using-f-string on modulos with brackets in template.

    Closes #​8720.

  • Fix a crash when __all__ exists but cannot be inferred.

    Closes #​8740

  • Fix crash when a variable is assigned to a class attribute of identical name.

    Closes #​8754

  • Fixed a crash when calling copy.copy() without arguments.

    Closes #​8774

Other Changes

  • Fix a crash when a nonlocal is defined at module-level.

    Closes #​8735

v2.17.4

Compare Source

False Positives Fixed

  • Fix a false positive for bad-dunder-name when there is a user-defined __index__ method.

    Closes #​8613

Other Bug Fixes

  • pyreverse: added escaping of vertical bar character in annotation labels produced by DOT printer to ensure it is not treated as field separator of record-based nodes.

    Closes #​8603

  • Fixed a crash when generating a configuration file: tomlkit.exceptions.TOMLKitError: Can't add a table to a dotted key caused by tomlkit v0.11.8.

    Closes #​8632

v2.17.3

Compare Source

What's new in Pylint 2.17.3?

Release date: 2023-04-24

False Positives Fixed

  • Fix unused-argument false positive when __new__ does not use all the arguments of __init__.

    Closes #​3670

  • Fix unused-import false positive for usage of six.with_metaclass.

    Closes #​7506

  • logging-not-lazy is not longer emitted for explicitly concatenated string arguments.

    Closes #​8410

  • Fix false positive for isinstance-second-argument-not-valid-type when union types contains None.

    Closes #​8424

  • Fixed unused-import so that it observes the dummy-variables-rgx option.

    Closes #​8500

  • Union typed variables without assignment are no longer treated as TypeAlias.

    Closes #​8540

  • Fix false positive for positional-only-arguments-expected when a function contains both a positional-only parameter that has a default value, and **kwargs.

    Closes #​8555

  • Fix false positive for keyword-arg-before-vararg when a positional-only parameter with a default value precedes *args.

    Closes #​8570

Other Bug Fixes

  • Improve output of consider-using-generator message for min()` calls with default`` keyword.

    Closes #​8563

v2.17.2

Compare Source

False Positives Fixed

  • invalid-name now allows for integers in typealias names:

    • now valid: Good2Name, GoodName2.
    • still invalid: _1BadName.

    Closes #​8485

  • No longer consider Union as type annotation as type alias for naming checks.

    Closes #​8487

  • unnecessary-lambda no longer warns on lambdas which use its parameters in their body (other than the final arguments), e.g. lambda foo: (bar if foo else baz)(foo).

    Closes #​8496

Other Bug Fixes

  • Fix a crash in pyreverse when "/" characters are used in the output filename e.g pyreverse -o png -p name/ path/to/project.

    Closes #​8504

v2.17.1

Compare Source

False Positives Fixed

  • Adds asyncSetUp to the default defining-attr-methods list to silence attribute-defined-outside-init warning when using unittest.IsolatedAsyncioTestCase.

    Refs #​8403

Other Bug Fixes

  • --clear-cache-post-run now also clears LRU caches for pylint utilities holding references to AST nodes.

    Closes #​8361

  • Fix a crash when TYPE_CHECKING is used without importing it.

    Closes #​8434

  • Fix a regression of preferred-modules where a partial match was used instead of the required full match.

    Closes #​8453

Internal Changes

  • The following utilities are deprecated in favor of the more robust in_type_checking_block and will be removed in pylint 3.0:

    • is_node_in_guarded_import_block
    • is_node_in_typing_guarded_import_block
    • is_typing_guard

    is_sys_guard is still available, which was part of is_node_in_guarded_import_block.

    Refs #​8433

v2.17.0

Compare Source

2.17 is a small release that is the first to support python 3.11 officially with the addition of TryStar nodes.

There's still two new default checks: bad-chained-comparison and implicit-flag-alias, one of them already fixed a previously undetected bug in sentry.

Thanks to the community effort our documentation is almost complete, and almost all messages should have a proper documentation now. A big thank you to everyone who participated !

The next release is going to be 3.0.0, bring breaking changes and enact long announced deprecations. There's going to be frequent beta releases, before the official releases, everyone is welcome to try the betas so we find problems before the actual release.

What's new in Pylint 2.17.0?

Release date: 2023-03-08

New Features

  • pyreverse now supports custom color palettes with the --color-palette option.

    Closes #​6738

  • Add invalid-name check for TypeAlias names.

    Closes #​7081

  • Accept values of the form <class name>.<attribute name> for the exclude-protected list.

    Closes #​7343

  • Add --version option to pyreverse.

    Refs #​7851

  • Adds new functionality with preferred-modules configuration to detect submodules.

    Refs #​7957

  • Support implicit namespace packages (PEP 420).

    Closes #​8154

  • Add globbing pattern support for --source-roots.

    Closes #​8290

  • Support globbing pattern when defining which file/directory/module to lint.

    Closes #​8310

  • pylint now supports TryStar nodes from Python 3.11 and should be fully compatible with Python 3.11.

    Closes #​8387

New Checks

  • Add a bad-chained-comparison check that emits a warning when there is a chained comparison where one expression is semantically incompatible with the other.

    Closes #​6559

  • Adds an implicit-flag-alias check that emits a warning when a class derived from enum.IntFlag assigns distinct integer values that share common bit positions.

    Refs #​8102

False Positives Fixed

  • Fix various false positives for functions that return directly from structural pattern matching cases.

    Closes #​5288

  • Fix false positive for used-before-assignment when typing.TYPE_CHECKING is used with if/elif/else blocks.

    Closes #​7574

  • Fix false positive for isinstance-second-argument-not-valid-type with union types.

    Closes #​8205

  • Fix false positive for used-before-assignment for named expressions appearing after the first element in a list, tuple, or set.

    Closes #​8252

  • Fix false positive for wrong-spelling-in-comment with class names in a python 2 type comment.

    Closes #​8370

False Negatives Fixed

  • Fix a false negative for 'missing-parentheses-for-call-in-test' when inference failed for the internal of the call as we did not need that information to raise correctly.

    Refs #​8185

  • Fix false negative for inconsistent-returns with while-loops.

    Closes #​8280

Other Bug Fixes

  • Fix used-before-assignment false positive when the walrus operator is used with a ternary operator in dictionary key/value initialization.

    Closes #​8125

  • Fix no-name-in-module false positive raised when a package defines a variable with the same name as one of its submodules.

    Closes #​8148

  • Fix a crash happening for python interpreter < 3.9 following a failed typing update.

    Closes #​8161

  • Fix nested-min-max suggestion message to indicate it's possible to splat iterable objects.

    Closes #​8168

  • Fix a crash happening when a class attribute was negated in the start argument of an enumerate.

    Closes #​8207

  • Prevent emitting invalid-name for the line on which a global statement is declared.

    Closes #​8307

Other Changes

  • Update explanation for global-variable-not-assigned and add confidence.

    Closes #​5073

  • The governance model and the path to become a maintainer have been documented as part of our effort to guarantee that the software supply chain in which pylint is included is secure.

    Refs #​8329

v2.16.4

Compare Source

False Positives Fixed

  • Fix false positive for isinstance-second-argument-not-valid-type with union types.

    Closes #​8205

v2.16.3

Compare Source

False Positives Fixed

  • Fix false positive for wrong-spelling-in-comment with class names in a python 2 type comment.

    Closes #​8370

Other Bug Fixes

  • Prevent emitting invalid-name for the line on which a global statement is declared.

    Closes #​8307

v2.16.2

Compare Source

New Features

  • Add --version option to pyreverse.

    Refs #​7851

False Positives Fixed

  • Fix false positive for used-before-assignment when typing.TYPE_CHECKING is used with if/elif/else blocks.

    Closes #​7574

  • Fix false positive for used-before-assignment for named expressions appearing after the first element in a list, tuple, or set.

    Closes #​8252

Other Bug Fixes

  • Fix used-before-assignment false positive when the walrus operator is used with a ternary operator in dictionary key/value initialization.

    Closes #​8125

  • Fix no-name-in-module false positive raised when a package defines a variable with the same name as one of its submodules.

    Closes #​8148

  • Fix nested-min-max suggestion message to indicate it's possible to splat iterable objects.

    Closes #​8168

  • Fix a crash happening when a class attribute was negated in the start argument of an enumerate.

    Closes #​8207

v2.16.1

Compare Source

Other Bug Fixes

  • Fix a crash happening for python interpreter < 3.9 following a failed typing update.

    Closes #​8161

v2.16.0

Compare Source

Summary -- Release highlights

In 2.16.0 we added aggregation and composition understanding in pyreverse, and a way to clear the cache in between run in server mode (originally for the VS Code integration). Apart from the bug fixes there's also a lot of new checks, and new extensions that have been asked for for a long time that were implemented.

If you want to benefit from all the new checks load the following plugins::

pylint.extensions.dict_init_mutate,
pylint.extensions.dunder,
pylint.extensions.typing,
pylint.extensions.magic_value,

We still welcome any community effort to help review, integrate, and add good/bad examples to the doc for #​5953. This should be doable without any pylint or astroid knowledge, so this is the perfect entrypoint if you want to contribute to pylint or open source without any experience with our code!

Last but not least @​clavedeluna and @​nickdrozd became triagers, welcome to the team !

What's new in Pylint 2.16.0?

Changes requiring user actions

  • The accept-no-raise-doc option related to missing-raises-doc will now be correctly taken into account all the time.

    Pylint will no longer raise missing-raises-doc (W9006) when no exceptions are documented and accept-no-raise-doc is true (issue #​7208). If you were expecting missing-raises-doc errors to be raised in that case, you will now have to add accept-no-raise-doc=no in your configuration to keep the same behavior. Closes #​7208

New Features

  • Added the no-header output format. If enabled with --output-format=no-header, it will not include the module name in the output. Closes #​5362

  • Added configuration option clear-cache-post-run to support server-like usage. Use this flag if you expect the linted files to be altered between runs. Refs #​5401

  • Add --allow-reexport-from-package option to configure the useless-import-alias check not to emit a warning if a name is reexported from a package. Closes #​6006

  • Update pyreverse to differentiate between aggregations and compositions. pyreverse checks if it's an Instance or a Call of an object via method parameters (via type hints) to decide if it's a composition or an aggregation. Refs #​6543

New Checks

  • Adds a pointless-exception-statement check that emits a warning when an Exception is created and not assigned, raised or returned. Refs #​3110

  • Add a shadowed-import message for aliased imports. Closes #​4836

  • Add new check called unbalanced-dict-unpacking to check for unbalanced dict unpacking in assignment and for loops. Closes #​5797

  • Add new checker positional-only-arguments-expected to check for cases when positional-only arguments have been passed as keyword arguments. Closes #​6489

  • Added singledispatch-method which informs that @singledispatch should decorate functions and not class/instance methods. Added singledispatchmethod-function which informs that @singledispatchmethod should decorate class/instance methods and not functions. Closes #​6917

  • Rename broad-except to broad-exception-caught and add new checker broad-exception-raised which will warn if general exceptions BaseException or Exception are raised. Closes #​7494

  • Added nested-min-max which flags min(1, min(2, 3)) to simplify to min(1, 2, 3). Closes #​7546

  • Extended use-dict-literal to also warn about call to dict() when passing keyword arguments. Closes #​7690

  • Add named-expr-without-context check to emit a warning if a named expression is used outside a context like if, for, while, or a comprehension. Refs #​7760

  • Add invalid-slice-step check to warn about a slice step value of 0 for common builtin sequences. Refs #​7762

  • Add consider-refactoring-into-while-condition check to recommend refactoring when a while loop is defined with a constant condition with an immediate if statement to check for break condition as a first statement. Closes #​8015

Extensions

  • Add new extension checker dict-init-mutate that flags mutating a dictionary immediately after the dictionary was created. Closes #​2876

  • Added bad-dunder-name extension check, which flags bad or misspelled dunder methods. You can use the good-dunder-names option to allow specific dunder names. Closes #​3038

  • Added consider-using-augmented-assign check for CodeStyle extension which flags x = x + 1 to simplify to x += 1. This check is disabled by default. To use it, load the code style extension with load-plugins=pylint.extensions.code_style and add consider-using-augmented-assign in the enable option. Closes #​3391

  • Add magic-number plugin checker for comparison with constants instead of named constants or enums. You can use it with --load-plugins=pylint.extensions.magic_value. Closes #​7281

  • Add redundant-typehint-argument message for typing plugin for duplicate assign typehints. Enable the plugin to enable the message with: --load-plugins=pylint.extensions.typing. Closes #​7636

False Positives Fixed

  • Fix false positive for unused-variable and unused-import when a name is only used in a string literal type annotation. Closes #​3299

  • Document a known false positive for useless-suppression when disabling line-too-long in a module with only comments and no code. Closes #​3368

  • trailing-whitespaces is no longer reported within strings. Closes #​3822

  • Fix false positive for global-variable-not-assigned when a global variable is re-assigned via an ImportFrom node. Closes #​4809

  • Fix false positive for use-maxsplit-arg with custom split method. Closes #​4857

  • Fix logging-fstring-interpolation false positive raised when logging and f-string with %s formatting. Closes #​4984

  • Fix false-positive for used-before-assignment in pattern matching with a guard. Closes #​5327

  • Fix use-sequence-for-iteration when unpacking a set with *. Closes #​5788

  • Fix deprecated-method false positive when alias for method is similar to name of deprecated method. Closes #​5886

  • Fix false positive assigning-non-slot when a class attribute is re-assigned. Closes #​6001

  • Fix false positive for too-many-function-args when a function call is assigned to a class attribute inside the class where the function is defined. Closes #​6592

  • Fixes false positive abstract-method on Protocol classes. Closes #​7209

  • Pylint now understands the kw_only keyword argument for dataclass. Closes #​7290, closes #​6550, closes #​5857

  • Fix false positive for undefined-loop-variable in for-else loops that use a function having a return type annotation of NoReturn or Never. Closes #​7311

  • Fix used-before-assignment for functions/classes defined in type checking guard. Closes #​7368

  • Fix false positive for unhashable-member when subclassing dict and using the subclass as a dictionary key. Closes #​7501

  • Fix the message for unnecessary-dunder-call for __aiter__ and __aneext__. Also only emit the warning when py-version >= 3.10. Closes #​7529

  • Fix used-before-assignment false positive when else branch calls sys.exit or similar terminating functions. Closes #​7563

  • Fix a false positive for used-before-assignment for imports guarded by typing.TYPE_CHECKING later used in variable annotations. Closes #​7609

  • Fix a false positive for simplify-boolean-expression when multiple values are inferred for a constant. Closes #​7626

  • unnecessary-list-index-lookup will not be wrongly emitted if enumerate is called with start. Closes #​7682

  • Don't warn about stop-iteration-return when using next() over itertools.cycle. Closes #​7765

  • Fixes used-before-assignment false positive when the walrus operator is used in a ternary operator. Closes #​7779

  • Fix missing-param-doc false positive when function parameter has an escaped underscore. Closes #​7827

  • Fixes method-cache-max-size-none false positive for methods inheriting from Enum. Closes #​7857

  • multiple-statements no longer triggers for function stubs using inlined .... Closes #​7860

  • Fix a false positive for used-before-assignment when a name guarded by if TYPE_CHECKING: is used as a type annotation in a function body and later re-imported in the same scope. Closes #​7882

  • Prevent used-before-assignment when imports guarded by if TYPE_CHECKING are guarded again when used. Closes #​7979

  • Fixes false positive for try-except-raise with multiple exceptions in one except statement if exception are in different namespace. Closes #​8051

  • Fix invalid-name errors for typing_extension.TypeVar. Refs #​8089

  • Fix no-kwoa false positive for context managers. Closes #​8100

  • Fix a false positive for redefined-variable-type when async methods are present. Closes #​8120

False Negatives Fixed

  • Code following a call to quit, exit, sys.exit or os._exit will be marked as unreachable. Refs #​519

  • Emit used-before-assignment when function arguments are redefined inside an inner function and accessed there before assignment. Closes #​2374

  • Fix a false negative for unused-import when one module used an import in a type annotation that was also used in another module. Closes #​4150

  • Flag superfluous-parens if parentheses are used during string concatenation. Closes #​4792

  • Emit used-before-assignment when relying on names only defined under conditions always testing false. Closes #​4913

  • consider-using-join can now be emitted for non-empty string separators. Closes #​6639

  • Emit used-before-assignment for further imports guarded by TYPE_CHECKING Previously, this message was only emitted for imports guarded directly under TYPE_CHECKING, not guarded two if-branches deep, nor when TYPE_CHECKING was imported from typing under an alias. Closes #​7539

  • Fix a false negative for unused-import when a constant inside typing.Annotated was treated as a reference to an import. Closes #​7547

  • consider-using-any-or-all message will now be raised in cases when boolean is initialized, reassigned during loop, and immediately returned. Closes #​7699

  • Extend invalid-slice-index to emit an warning for invalid slice indices used with string and byte sequences, and range objects. Refs #​7762

  • Fixes unnecessary-list-index-lookup false negative when enumerate is called with iterable as a kwarg. Closes #​7770

  • no-else-return or no-else-raise will be emitted if except block always returns or raises. Closes #​7788

  • Fix dangerous-default-value false negative when * is used. Closes #​7818

  • consider-using-with now triggers for pathlib.Path.open. Closes #​7964

Other Bug Fixes

  • Fix bug in detecting unused-variable when iterating on variable. Closes #​3044

  • Fix bug in scanning of names inside arguments to typing.Literal. See https://peps.python.org/pep-0586/#literals-enums-and-forward-references for details. Refs #​3299

  • Update disallowed-name check to flag module-level variables. Closes #​3701

  • Pylint will no longer deadlock if a parallel job is killed but fail immediately instead. Closes #​3899

  • Fix ignored files being linted when passed on stdin. Closes #​4354

  • Fix no-member false negative when augmented assign is done manually, without +=. Closes #​4562

  • Any assertion on a populated tuple will now receive a assert-on-tuple warning. Closes #​4655

  • missing-return-doc, missing-raises-doc and missing-yields-doc now respect the no-docstring-rgx option. Closes #​4743

  • Update reimported help message for clarity. Closes #​4836

  • consider-iterating-dictionary will no longer be raised if bitwise operations are used. Closes #​5478

  • Using custom braces in msg-template will now work properly. Closes #​5636

  • Pylint will now filter duplicates given to it before linting. The output should be the same whether a file is given/discovered multiple times or not. Closes #​6242, #​4053

  • Remove __index__ dunder method call from unnecessary-dunder-call check. Closes #​6795

  • Fixed handling of -- as separator between positional arguments and flags. This was not actually fixed in 2.14.5. Closes #​7003, Refs #​7096

  • Don't crash on OSError in config file discovery. Closes #​7169

  • Messages sent to reporter are now copied so a reporter cannot modify the message sent to other reporters. Closes #​7214

  • Fixed a case where custom plugins specified by command line could silently fail. Specifically, if a plugin relies on the init-hook option changing sys.path before it can be imported, this will now emit a bad-plugin-value message. Before this change, it would silently fail to register the plugin for use, but would load any configuration, which could have unintended effects. Fixes part of #​7264.

  • Update modified_iterating checker to fix a crash with for loops on empty list. Closes #​7380

  • Update wording for arguments-differ and arguments-renamed to clarify overriding object. Closes #​7390

  • disable-next is now correctly scoped to only the succeeding line. Closes #​7401

  • Fixed a crash in the unhashable-member checker when using a lambda as a dict key. Closes #​7453

  • Add mailcap to deprecated modules list. Closes #​7457

  • Fix a crash in the modified-iterating-dict checker involving instance attributes. Closes #​7461

  • invalid-class-object does not crash anymore when __class__ is assigned alongside another variable. Closes #​7467

  • --help-msg now accepts a comma-separated list of message IDs again. Closes #​7471

  • Allow specifying non-builtin exceptions in the overgeneral-exception option using an exception's qualified name. Closes #​7495

  • Report no-self-argument rather than no-method-argument for methods with variadic arguments. Closes #​7507

  • Fixed an issue where syntax-error couldn't be raised on files with invalid encodings. Closes #​7522

  • Fix false positive for redefined-outer-name when aliasing typing e.g. as t and guarding imports under t.TYPE_CHECKING. Closes #​7524

  • Fixed a crash of the modified_iterating checker when iterating on a set defined as a class attribute. Closes #​7528

  • Use py-version to determine if a message should be emitted for messages defined with max-version or min-version. Closes #​7569

  • Improve bad-thread-instantiation check to warn if target is not passed in as a keyword argument or as a second argument. Closes #​7570

  • Fixes edge case of custom method named next raised an astroid error. Closes #​7610

  • Fixed a multi-processing crash that prevents using any more than 1 thread on MacOS. The returned module objects and errors that were cached by the linter plugin loader cannot be reliably pickled. This means that dill would throw an error when attempting to serialise the linter object for multi-processing use. Closes #​7635.

  • Fix crash that happened when parsing files with unexpected encoding starting with 'utf' like utf13. Closes #​7661

  • Fix a crash when a child class with an __init__ method inherits from a parent class with an __init__ class attribute. Closes #​7742

  • Fix valid-metaclass-classmethod-first-arg default config value from "cls" to "mcs" which would cause both a false-positive and false-negative. Closes #​7782

  • Fixes a crash in the unnecessary_list_index_lookup check when using enumerate with start and a class attribute. Closes #​7821

  • Fixes a crash in stop-iteration-return when the next builtin is called without arguments. Closes #​7828

  • When pylint exit due to bad arguments being provided the exit code will now be the expected 32. Refs #​7931

  • Fixes a ModuleNotFound exception when running pylint on a Django project with the pylint_django plugin enabled. Closes #​7938

  • Fixed a crash when inferring a value and using its qname on a slice that was being incorrectly called. Closes #​8067

  • Use better regex to check for private attributes. Refs #​8081

  • Fix issue with new typing Union syntax in runtime context for Python 3.10+. Closes #​8119

Other Changes

  • Pylint now provides basic support for Python 3.11. Closes #​5920

  • Update message for abstract-method to include child class name. Closes #​7124

  • Update Pyreverse's dot and plantuml printers to detect when class methods are abstract and show them with italic font. For the dot printer update the label to use html-like syntax. Closes #​7346

  • The docparams extension now considers typing in Numpy style docstrings as "documentation" for the missing-param-doc message. Refs #​7398

  • Relevant DeprecationWarnings are now raised with stacklevel=2, so they have the callsite attached in the message. Closes #​7463

  • Add a minimal option to pylint-config and its toml generator. Closes #​7485

  • Add method name to the error messages of no-method-argument and no-self-argument. Closes #​7507

  • Prevent leaving the pip install cache in the Docker image. Refs #​7544

  • Add a keyword-only compare_constants argument to safe_infer. Refs #​7626

  • Add default_enabled option to optional message dict. Provides an option to disable a checker message by default. To use a disabled message, the user must enable it explicitly by adding the message to the enable option. Refs #​7629

  • Sort --generated-rcfile output. Refs #​7655

  • epylint is now deprecated and will be removed in pylint 3.0.0. All emacs and flymake related files were removed and their support will now happen in an external repository : https://github.com/emacsorphanage/pylint. Closes #​7737

  • Adds test for existing preferred-modules configuration functionality. Refs #​7957

Internal Changes

  • Add and fix regression tests for plugin loading. This shores up the tests that cover the loading of custom plugins as affected by any changes made to the sys.path during execution of an init-hook. Given the existing contract of allowing plugins to be loaded by fiddling with the path in this way, this is now the last bit of work needed to close Github issue #​7264. Closes #​7264

v2.15.10

Compare Source

False Positives Fixed

  • Fix use-sequence-for-iteration when unpacking a set with *.

    Closes #​5788

  • Fix false positive assigning-non-slot when a class attribute is re-assigned.

    Closes #​6001

  • Fixes used-before-assignment false positive when the walrus operator is used in a ternary operator.

    Closes #​7779

  • Prevent used-before-assignment when imports guarded by if TYPE_CHECKING are guarded again when used.

    Closes #​7979

Other Bug Fixes

  • Using custom braces in msg-template will now work properly.

    Closes #​5636

v2.15.9

Compare Source

False Positives Fixed

  • Fix false-positive for used-before-assignment in pattern matching with a guard.

    Closes #​5327

Other Bug Fixes

  • Pylint will no longer deadlock if a parallel job is killed but fail immediately instead.

    Closes #​3899

  • When pylint exit due to bad arguments being provided the exit code will now be the expected 32.

    Refs #​7931

  • Fixes a ModuleNotFound exception when running pylint on a Django project with the pylint_django plugin enabled.

    Closes #​7938

v2.15.8

Compare Source

False Positives Fixed

  • Document a known false positive for useless-suppression when disabling line-too-long in a module with only comments and no code.

    Closes #​3368

  • Fix logging-fstring-interpolation false positive raised when logging and f-string with %s formatting.

    Closes #​4984

  • Fixes false positive abstract-method on Protocol classes.

    Closes #​7209

  • Fix missing-param-doc false positive when function parameter has an escaped underscore.

    Closes #​7827

  • multiple-statements no longer triggers for function stubs using inlined ....

    Closes #​7860

v2.15.7

Compare Source

False Positives Fixed

  • Fix deprecated-method false positive when alias for method is similar to name of deprecated method.

    Closes #​5886

  • Fix a false positive for used-before-assignment for imports guarded by typing.TYPE_CHECKING later used in variable annotations.

    Closes #​7609

Other Bug Fixes

  • Pylint will now filter duplicates given to it before linting. The output should be the same whether a file is given/discovered multiple times or not.

    Closes #​6242, #​4053

  • Fixes a crash in stop-iteration-return when the next builtin is called without arguments.

    Closes #​7828

v2.15.6

Compare Source

False Positives Fixed

  • Fix false positive for unhashable-member when subclassing dict and using the subclass as a dictionary key.

    Closes #​7501

  • unnecessary-list-index-lookup will not be wrongly emitted if enumerate is called with start.

    Closes #​7682

  • Don't warn about stop-iteration-return when using next() over itertools.cycle.

    Closes #​7765

Other Bug Fixes

  • Messages sent to reporter are now copied so a reporter cannot modify the message sent to other reporters.

    Closes #​7214

  • Fixes edge case of custom method named next raised an astroid error.

    Closes #​7610

  • Fix crash that happened when parsing files with unexpected encoding starting with 'utf' like utf13.

    Closes #​7661

  • Fix a crash when a child class with an __init__ method inherits from a parent class with an __init__ class attribute.

    Closes #​7742

v2.15.5

Compare Source

What's new in Pylint 2.15.5?

Release date: 2022-10-21

False Positives Fixed

  • Fix a false positive for simplify-boolean-expression when multiple values are inferred for a constant.

    Closes #​7626

Other Bug Fixes

  • Remove __index__ dunder method call from unnecessary-dunder-call check.

    Closes #​6795

  • Fixed a multi-processing crash that prevents using any more than 1 thread on MacOS.

    The returned module objects and errors that were cached by the linter plugin loader cannot be reliably pickled. This means that dill would throw an error when attempting to serialise the linter object for multi-processing use.

    Closes #​7635.

Other Changes

  • Add a keyword-only compare_constants argument to safe_infer.

    Refs #​7626

  • Sort --generated-rcfile output.

    Refs #​7655

v2.15.4

Compare Source

False Positives Fixed

  • Fix the message for unnecessary-dunder-call for __aiter__ and __anext__. Also only emit the warning when py-version >= 3.10.

    Closes #​7529

Other Bug Fixes

  • Fix bug in detecting unused-variable when iterating on variable.

    Closes #​3044

  • Fixed handling of -- as separator between positional arguments and flags. This was not actually fixed in 2.14.5.

    Closes #​7003, Refs #​7096

  • Report no-self-argument rather than no-method-argument for methods with variadic arguments.

    Closes #​7507

  • Fixed an issue where syntax-error couldn't be raised on files with invalid encodings.

    Closes #​7522

  • Fix false positive for redefined-outer-name when aliasing typing e.g. as t and guarding imports under t.TYPE_CHECKING.

    Closes #​7524

  • Fixed a crash of the modified_iterating checker when iterating on a set defined as a class attribute.

    Closes #​7528

  • Fix bug in scanning of names inside arguments to typing.Literal. See https://peps.python.org/pep-0586/#literals-enums-and-forward-references for details.

    Refs #​3299

Other Changes

  • Add method name to the error messages of no-method-argument and no-self-argument.

    Closes #​7507

v2.15.3

Compare Source

  • Fixed a crash in the unhashable-member checker when using a lambda as a dict key.

    Closes #​7453

  • Fix a crash in the modified-iterating-dict checker involving instance attributes.

    Closes #​7461

  • invalid-class-object does not crash anymore when __class__ is assigned alongside another variable.

    Closes #​7467

  • Fix false positive for global-variable-not-assigned when a global variable is re-assigned via an ImportFrom node.

    Closes #​4809

  • Fix false positive for undefined-loop-variable in for-else loops that use a function having a return type annotation of NoReturn or Never.

    Closes #​7311

  • --help-msg now accepts a comma-separated list of message IDs again.

    Closes #​7471

v2.15.2

Compare Source

  • Fixed a case where custom plugins specified by command line could silently fail.

    Specifically, if a plugin relies on the init-hook option changing sys.path before it can be imported, this will now emit a bad-plugin-value message. Before this change, it would silently fail to register the plugin for use, but would load any configuration, which could have unintended effects.

    Fixes part of #​7264.

  • Fix used-before-assignment for functions/classes defined in type checking guard.

    Closes #​7368

  • Update modified_iterating checker to fix a crash with for loops on empty list.

    Closes #​7380

  • The docparams extension now considers typing in Numpy style docstrings as "documentation" for the missing-param-doc message.

    Refs #​7398

  • Fix false positive for unused-variable and unused-import when a name is only used in a string literal type annotation.

    Closes #​3299

  • Fix false positive for too-many-function-args when a function call is assigned to a class attribute inside the class where the function is defined.

    Closes #​6592

  • Fix used-before-assignment for functions/classes defined in type checking guard.

    Closes #​7368

  • Fix ignored files being linted when passed on stdin.

    Closes #​4354

  • missing-return-doc, missing-raises-doc and missing-yields-doc now respect the no-docstring-rgx option.

    Closes #​4743

  • Don't crash on OSError in config file discovery.

    Closes #​7169

  • disable-next is now correctly scoped to only the succeeding line.

    Closes #​7401

  • Update modified_iterating checker to fix a crash with for loops on empty list.

    Closes #​7380

v2.15.0

Compare Source

In pylint 2.15.0, we added a new check missing-timeout to warn of default timeout values that could cause a program to be hanging indefinitely.

We improved pylint's handling of namespace packages. More packages should be linted without resorting to using the --recursive=y option.

We still welcome any community effort to help review, integrate, and add good/bad examples to the doc for https://github.com/PyCQA/pylint/issues/5953. This should be doable without any pylint or astroid knowledge, so this is the perfect entrypoint if you want to contribute to pylint or open source without any experience with our code!

Internally, we changed the way we generate the release notes, thanks to DudeNr33. There will be no more conflict resolution to do in the changelog, and every contributor rejoice.

Marc Byrne became a maintainer, welcome to the team !

New Checks

  • Added new checker missing-timeout to warn of default timeout values that could cause a program to be hanging indefinitely.

    Refs #​6780

False Positives Fixed

  • Don't report super-init-not-called for abstract __init__ methods.

    Closes #​3975

  • Don't report unsupported-binary-operation on Python <= 3.9 when using the | operator with types, if one has a metaclass that overloads __or__ or __ror__ as appropriate.

    Closes #​4951

  • Don't report no-value-for-parameter for dataclasses fields annotated with KW_ONLY.

    Closes #​5767

  • Fixed inference of Enums when they are imported under an alias.

    Closes #​5776

  • Prevent false positives when accessing PurePath.parents by index (not slice) on Python 3.10+.

    Closes #​5832

  • unnecessary-list-index-lookup is now more conservative to avoid potential false positives.

    Closes #​6896

  • Fix double emitting trailing-whitespace for multi-line docstrings.

    Closes #​6936

  • import-error now correctly checks for contextlib.suppress guards on import statements.

    Closes #​7270

  • Fix false positive for no-self-argument/no-method-argument when a staticmethod is applied to a function but uses a different name.

    Closes #​7300

  • Fix undefined-loop-variable with break and continue statements in else blocks.

    Refs #​7311

False Negatives Fixed

  • Emit used-before-assignment when relying on a name that is reimported later in a function.

    Closes #​4624

  • Emit used-before-assignment for self-referencing named expressions (:=) lacking prior assignments.

    Closes #​5653

  • Emit used-before-assignment for self-referencing assignments under if conditions.

    Closes #​6643

  • Emit modified-iterating-list and analogous messages for dicts and sets when iterating literals, or when using the del keyword.

    Closes #​6648

  • Emit used-before-assignment when calling nested functions before assignment.

    Closes #​6812

  • Emit nonlocal-without-binding when a nonlocal name has been assigned at a later point in the same scope.

    Closes #​6883

  • Emit using-constant-test when testing the truth value of a variable or call result holding a generator.

    Closes #​6909

  • Rename unhashable-dict-key to unhashable-member and emit when creating sets and dicts, not just when accessing dicts.

    Closes #​7034, Closes #​7055

Other Bug Fixes

  • Fix a failure to lint packages with __init__.py contained in directories lacking __init__.py.

    Closes #​1667

  • Fixed a syntax-error crash that was not handled properly when the declared encoding of a file was utf-9.

    Closes #​3860

  • Fix a crash in the not-callable check when there is ambiguity whether an instance is being incorrectly provided to __new__().

    Closes #​7109

  • Fix crash when regex option raises a re.error exception.

    Closes #​7202

  • Fix undefined-loop-variable from walrus in comprehension test.

    Closes #​7222

  • Check for <cwd> before removing first item from sys.path in modify_sys_path.

    Closes #​7231

  • Fix sys.path pollution in parallel mode.

    Closes #​7246

  • Prevent useless-parent-delegation for delegating to a builtin written in C (e.g. Exception.__init__) with non-self arguments.

    Closes #​7319

Other Changes

  • bad-exception-context has been renamed to bad-exception-cause as it is about the cause and not the context.

    Closes #​3694

  • The message for literal-comparison is now more explicit about the problem and the solution.

    Closes #​5237

  • useless-super-delegation has been renamed to useless-parent-delegation in order to be more generic.

    Closes #​6953

  • Pylint now uses towncrier for changelog generation.

    Refs #​6974

  • Update astroid to 2.12.

    Refs #​7153

  • Fix crash when a type-annotated __slots__ with no value is declared.

    Closes #​7280

Internal Changes

  • Fixed an issue where it was impossible to update functional tests output when the existing output was impossible to parse. Instead of raising an error we raise a warning message and let the functional test fail with a default value.

    Refs #​6891

  • pylint.testutils.primer is now a private API.

    Refs #​6905

  • We changed the way we handle the changelog internally by using towncrier. If you're a contributor you won't have to fix merge conflicts in the changelog anymore.

    Closes #​6974

  • Pylint is now using Scorecards to implement security recommendations from the OpenSSF <https://openssf.org/>_. This is done in order to secure our supply chains using a combination of automated tooling and best practices, most of which were already implemented before.

    Refs #​7267

v2.14.5

Compare Source

  • Fixed a crash in the undefined-loop-variable check when enumerate() is used in a ternary expression.

    Closes #​7131

  • Fixed handling of -- as separator between positional arguments and flags.

    Closes #​7003

  • Fixed the disabling of fixme and its interaction with useless-suppression.

  • Allow lists of default values in parameter documentation for Numpy style.

    Closes #​4035

v2.14.4

Compare Source

  • The differing-param-doc check was triggered by positional only arguments.

    Closes #​6950

  • Fixed an issue where scanning . directory recursively with --ignore-path=^path/to/dir is not ignoring the path/to/dir directory.

    Closes #​6964

  • Fixed regression that didn't allow quoted init-hooks in option files.

    Closes #​7006

  • Fixed a false positive for modified-iterating-dict when updating an existing key.

    Closes #​6179

  • Fixed an issue where many-core Windows machines (>~60 logical processors) would hang when using the default jobs count.

    Closes #​6965

  • Fixed an issue with the recognition of setup.cfg files. Only .cfg files that are exactly named setup.cfg require section names that start with pylint..

    Closes #​3630

  • Don't report import-private-name for relative imports.

    Closes #​7078

v2.14.3

Compare Source

  • Fixed two false positives for bad-super-call for calls that refer to a non-direct parent.

    Closes #​4922, Closes #​2903

  • Fixed a false positive for useless-super-delegation for subclasses that specify the number of of parameters against a parent that uses a variadic argument.

    Closes #​2270

  • Allow suppressing undefined-loop-variable and undefined-variable without raising useless-suppression.

  • Fixed false positive for undefined-variable for __class__ in inner methods.

    Closes #​4032

v2.14.2

Compare Source

  • Fixed a false positive for unused-variable when a function returns an argparse.Namespace object.

    Closes #​6895

  • Avoided raising an identical undefined-loop-variable message twice on the same line.

  • Don't crash if lint.run._query_cpu() is run within a Kubernetes Pod, that has only a fraction of a cpu core assigned. Just go with one process then.

    Closes #​6902

  • Fixed a false positive in consider-using-f-string if the left side of a % is not a string.

    Closes #​6689

  • Fixed a false positive in unnecessary-list-index-lookup and unnecessary-dict-index-lookup when the subscript is updated in the body of a nested loop.

    Closes #​6818

  • Fixed an issue with multi-line init-hook options which did not record the line endings.

    Closes #​6888

  • Fixed a false positive for used-before-assignment when a try block returns but an except handler defines a name via type annotation.

  • --errors-only no longer enables previously disabled messages. It was acting as "emit all and only error messages" without being clearly documented that way.

    Closes #​6811

v2.14.1

Compare Source

  • Avoid reporting unnecessary-dict-index-lookup or unnecessary-list-index-lookup when the index lookup is part of a destructuring assignment.

    Closes #​6788

  • Fixed parsing of unrelated options in tox.ini.

    Closes #​6800

  • Fixed a crash when linting __new__() methods that return a call expression.

    Closes #​6805

  • Don't crash if we can't find the user's home directory.

    Closes #​6802

  • Fixed false positives for unused-import when aliasing typing e.g. as t and guarding imports under t.TYPE_CHECKING.

    Closes #​3846

  • Fixed a false positive regression in 2.13 for used-before-assignment where it is safe to rely on a name defined only in an except block because the else block returned.

    Closes #​6790

  • Fixed the use of abbreviations for some special options on the command line.

    Closes #​6810

  • Fix a crash in the optional pylint.extensions.private_import extension.

    Closes #​6624

  • bad-option-value (E0012) is now a warning unknown-option-value (W0012). Deleted messages that do not exist anymore in pylint now raise useless-option-value (R0022) instead of bad-option-value. This allows to distinguish between genuine typos and configuration that could be cleaned up. Existing message disables for bad-option-value will still work on both new messages.

    Refs #​6794

v2.14.0

Compare Source

Summary -- Release highlights

With 2.14 pylint only supports Python version 3.7.2 and above.

We introduced several new checks among which duplicate-value for sets, comparison-of-constants, and checks related to lambdas. We removed no-init and made no-self-use optional as they were too opinionated. We also added an option to generate a toml configuration: --generate-toml-config.

We migrated to argparse from optparse and refactored the configuration handling thanks to Daniël van Noord. On the user side it should change the output of the --help command, and some inconsistencies and bugs should disappear. The behavior between options set in a config file versus on the command line will be more consistent. For us, it will permit to maintain this part of the code easily in the future and anticipate optparse's removal in Python 3.12.

As a result of the refactor there are a lot of internal deprecations. If you're a library maintainer that depends on pylint, please verify that you're ready for pylint 3.0 by activating deprecation warnings.

We continued the integration of pylint-error and are now at 33%!. We still welcome any community effort to help review, integrate, and add good/bad examples in #​5953. This should be doable without any pylint or astroid knowledge, so this is the perfect entrypoint if you want to contribute to pylint or open source without any experience with our code!

New checkers

  • Added new checker comparison-of-constants.

    Closes #​6076

  • Added new checker typevar-name-mismatch: TypeVar must be assigned to a variable with the same name as its name argument.

    Closes #​5224

  • invalid-enum-extension: Used when a class tries to extend an inherited Enum class.

    Closes #​5501

  • Added new checker typevar-double-variance: The "covariant" and "contravariant" keyword arguments cannot both be set to "True" in a TypeVar.

    Closes #​5895

  • Add new check unnecessary-dunder-call for unnecessary dunder method calls.

    Closes #​5936

  • unnecessary-lambda-assignment: Lambda expression assigned to a variable. Define a function using the "def" keyword instead. unnecessary-direct-lambda-call: Lambda expression called directly. Execute the expression inline instead.

    Closes #​5976

  • potential-index-error: Emitted when the index of a list or tuple exceeds its length. This checker is currently quite conservative to avoid false positives. We welcome suggestions for improvements.

    Closes #​578

  • Added new checker unnecessary-list-index-lookup for indexing into a list while iterating over enumerate().

    Closes #​4525

  • Added new message called duplicate-value which identifies duplicate values inside sets.

    Closes #​5880

  • Added the super-without-brackets checker, raised when a super call is missing its brackets.

    Closes #​4008

Removed checkers

  • The no-init (W0232) warning has been removed. It's ok to not have an __init__ in a class.

    Closes #​2409

  • Removed the assign-to-new-keyword message as there are no new keywords in the supported Python versions any longer.

    Closes #​4683

  • Moved no-self-use check to optional extension. You now need to explicitly enable this check using load-plugins=pylint.extensions.no_self_use.

    Closes #​5502

Extensions

  • RedefinedLoopNameChecker

    • Added optional extension redefined-loop-name to emit messages when a loop variable is redefined in the loop body.

    Closes #​5072

  • DocStringStyleChecker

    • Re-enable checker bad-docstring-quotes for Python <= 3.7.

    Closes #​6087

  • NoSelfUseChecker

    • Added no-self-use check, previously enabled by default.

    Closes #​5502

Other Changes

  • Started ignoring underscore as a local variable for too-many-locals.

    Closes #​6488

  • Pylint can now be installed with an extra-require called spelling (pip install pylint[spelling]). This will add pyenchant to pylint's dependencies. You will still need to install the requirements for pyenchant (the enchant library and any dictionaries) yourself. You will also need to set the spelling-dict option.

    Refs #​6462

  • Improved wording of the message of deprecated-module

    Closes #​6169

  • Pylint now requires Python 3.7.2 or newer to run.

    Closes #​4301

  • We made a greater effort to reraise failures stemming from the astroid library as AstroidError, with the effect that pylint emits astroid-error rather than merely fatal. Regardless, please report any such issues you encounter!

  • We have improved our recognition of inline disable and enable comments. It is now possible to disable bad-option-value inline (as long as you disable it before the bad option value is raised, i.e. disable=bad-option-value,bad-message not disable=bad-message,bad-option-value ) as well as certain other previously unsupported messages.

    Closes #​3312

  • The main checker name is now main instead of master. The configuration does not need to be updated as sections' name are optional.

    Closes #​5467

  • Update invalid-slots-object message to show bad object rather than its inferred value.

    Closes #​6101

  • Fixed a crash in the not-an-iterable checker involving multiple starred expressions inside a call.

    Closes #​6372

  • Fixed a crash in the unused-private-member checker involving chained private attributes.

    Closes #​6709

  • Disable spellchecking of mypy rule names in ignore directives.

    Closes #​5929

  • implicit-str-concat will now be raised on calls like open("myfile.txt" "a+b") too.

    Closes #​6441

  • Fix a failure to respect inline disables for fixme occurring on the last line of a module when pylint is launched with --enable=fixme.

  • Removed the broken generate-man option.

    Closes #​5283 Closes #​1887

  • Fixed failure to enable deprecated-module after a disable=all by making ImportsChecker solely responsible for emitting deprecated-module instead of sharing responsibility with StdlibChecker. (This could have led to double messages.)

  • Added the generate-toml-config option.

    Refs #​5462

  • bad-option-value will be emitted whenever a configuration value or command line invocation includes an unknown message.

    Closes #​4324

  • Added the unrecognized-option message. Raised if we encounter any unrecognized options.

    Closes #​5259

  • Fix false negative for bad-string-format-type if the value to be formatted is passed in as a variable holding a constant.

  • The concept of checker priority has been removed.

  • The cache-max-size-none checker has been renamed to method-cache-max-size-none.

    Closes #​5670

  • The method-cache-max-size-none checker will now also check functools.cache.

    Closes #​5670

  • BaseChecker classes now require the linter argument to be passed.

  • The set_config_directly decorator has been removed.

  • Don't report useless-super-delegation for the __hash__ method in classes that also override the __eq__ method.

    Closes #​3934

  • Fix falsely issuing useless-suppression on the wrong-import-position checker.

    Closes #​5219

  • Fixed false positive no-member for Enums with self-defined members.

    Closes #​5138

  • Fix false negative for no-member when attempting to assign an instance attribute to itself without any prior assignment.

    Closes #​1555

  • Changed message type from redefined-outer-name to redefined-loop-name (optional extension) for redefinitions of outer loop variables by inner loops.

    Closes #​5608

  • By default the similarity checker will now ignore imports and ignore function signatures when computing duplication. If you want to keep the previous behaviour set ignore-imports and ignore-signatures to False.

  • Pylint now expands the user path (i.e. ~ to home/yusef/) and expands environment variables (i.e. home/$USER/$project to home/yusef/pylint for USER=yusef and project=pylint) for pyreverse's output-directory, import-graph, ext-import-graph, int-import-graph options, and the spell checker's spelling-private-dict-file option.

    Refs #​6493

  • Don't emit unsubscriptable-object for string annotations. Pylint doesn't check if class is only generic in type stubs only.

    Closes #​4369 and #​6523

  • Fix pyreverse crash RuntimeError: dictionary changed size during iteration

    Refs #​6612

  • Fix syntax for return type annotations in MermaidJS diagrams produced with pyreverse.

    Closes #​6467

  • Fix type annotations of class and instance attributes using the alternative union syntax in pyreverse diagrams.

  • Fix bug where it writes a plain text error message to stdout, invalidating output formats.

    Closes #​6597

  • The refactoring checker now also raises 'consider-using-a-generator' messages for max(), min() and sum().

    Refs #​6595

  • Update ranges for using-constant-test and missing-parentheses-for-call-in-test error messages.

  • Don't emit no-member inside type annotations with from __future__ import annotations.

    Closes #​6594

  • Fix unexpected-special-method-signature false positive for __init_subclass__ methods with one or more arguments.

    Closes #​6644

Deprecations

  • The ignore-mixin-members option has been deprecated. You should now use the new ignored-checks-for-mixins option.

    Closes #​5205

  • interfaces.implements has been deprecated and will be removed in 3.0. Please use standard inheritance patterns instead of __implements__.

    Refs #​2287

  • All Interface classes in pylint.interfaces have been deprecated. You can subclass the respective normal classes to get the same behaviour. The __implements__ functionality was based on a rejected PEP from 2001: https://peps.python.org/pep-0245/

    Closes #​2287

  • MapReduceMixin has been deprecated. BaseChecker now implements get_map_data and reduce_map_data. If a checker actually needs to reduce data it should define get_map_data as returning something different than None and let its reduce_map_data handle a list of the types returned by get_map_data. An example can be seen by looking at pylint/checkers/similar.py.

  • The config attribute of BaseChecker has been deprecated. You can use checker.linter.config to access the global configuration object instead of a checker-specific object.

    Refs #​5392

  • The level attribute of BaseChecker has been deprecated: everything is now displayed in --help, all the time.

    Refs #​5392

  • The set_option method of BaseChecker has been deprecated. You can use checker.linter.set_option to set an option on the global configuration object instead of a checker-specific object.

    Refs #​5392

  • The options_providers attribute of ArgumentsManager has been deprecated.

    Refs #​5392

  • Fix saving of persistent data files in environments where the user's cache directory and the linted file are on a different drive.

    Closes #​6394

  • The method-cache-max-size-none checker will now also check functools.cache.

  • The config attribute of PyLinter is now of the argparse.Namespace type instead of optparse.Values.

    Refs #​5392

  • UnsupportedAction has been deprecated.

    Refs #​5392

  • OptionsManagerMixIn has been deprecated.

    Refs #​5392

  • OptionParser has been deprecated.

    Refs #​5392

  • Option has been deprecated.

    Refs #​5392

  • OptionsProviderMixIn has been deprecated.

    Refs #​5392

  • ConfigurationMixIn has been deprecated.

  • The option_groups attribute of PyLinter has been deprecated.

    Refs #​5392

  • get_global_config has been deprecated. You can now access all global options from checker.linter.config.

    Refs #​5392

  • OptionsManagerMixIn has been replaced with ArgumentsManager. ArgumentsManager is considered private API and most methods that were public on OptionsManagerMixIn have now been deprecated and will be removed in a future release.

    Refs #​5392

  • OptionsProviderMixIn has been replaced with ArgumentsProvider. ArgumentsProvider is considered private API and most methods that were public on OptionsProviderMixIn have now been deprecated and will be removed in a future release.

    Refs #​5392

  • pylint.pyreverse.ASTWalker has been removed, as it was only used internally by a single child class.

    Refs #​6712

  • pyreverse: Resolving and displaying implemented interfaces that are defined by the __implements__ attribute has been deprecated and will be removed in 3.0.

    Refs #​6713

  • is_class_subscriptable_pep585_with_postponed_evaluation_enabled has been deprecated. Use is_postponed_evaluation_enabled(node) and is_node_in_type_annotation_context(node) instead.

    Refs #​6536

v2.13.9

Compare Source

2.13.9 is the last release supporting python interpreter between 3.6.2 and 3.7.2.

  • Respect ignore configuration options with --recursive=y.

    Closes #​6471

  • Fix false positives for no-name-in-module and import-error for numpy.distutils and pydantic.

    Closes #​6497

  • Fix IndexError crash in uninferable_final_decorators method.

    Relates to #​6531

  • Fix a crash in unnecessary-dict-index-lookup when subscripting an attribute.

    Closes #​6557

  • Fix a crash when accessing __code__ and assigning it to a variable.

    Closes #​6539

  • Fix a false positive for undefined-loop-variable when using enumerate().

    Closes #​6593

v2.13.8

Compare Source

  • Fix a false positive for undefined-loop-variable for a variable used in a lambda inside the first of multiple loops.

    Closes #​6419

  • Fix a crash when linting a file that passes an integer mode= to open

    Closes #​6414

  • Avoid reporting superfluous-parens on expressions using the is not operator.

    Closes #​5930

  • Fix a false positive for undefined-loop-variable when the else of a for loop raises or returns.

    Closes #​5971

  • Fix false positive for unused-variable for classes inside functions and where a metaclass is provided via a call.

    Closes #​4020

  • Fix false positive for unsubscriptable-object in Python 3.8 and below for statements guarded by if TYPE_CHECKING.

    Closes #​3979

v2.13.7

Compare Source

  • Fix a crash caused by using the new config from 2.14.0 in 2.13.x code.

    Closes #​6408

v2.13.6

Compare Source

  • Fix a crash in the unsupported-membership-test checker when assigning multiple constants to class attributes including __iter__ via unpacking.

    Closes #​6366

  • Asterisks are no longer required in Sphinx and Google style parameter documentation for missing-param-doc and are parsed correctly.

    Closes #​5815 Closes #​5406

  • Fixed a false positive for unused-variable when a builtin specified in --additional-builtins is given a type annotation.

    Closes #​6388

  • Fixed an AstroidError in 2.13.0 raised by the duplicate-code checker with ignore-imports or ignore-signatures enabled.

    Closes #​6301

v2.13.5

Compare Source

  • Fix false positive regression in 2.13.0 for used-before-assignment for homonyms between variable assignments in try/except blocks and variables in subscripts in comprehensions.

    Closes #​6069 Closes #​6136

  • lru-cache-decorating-method has been renamed to cache-max-size-none and will only be emitted when maxsize is None.

    Closes #​6180

  • Fix false positive for unused-import when disabling both used-before-assignment and undefined-variable.

    Closes #​6089

  • Narrow the scope of the unnecessary-ellipsis checker to:

    • functions & classes which contain both a docstring and an ellipsis.
    • A body which contains an ellipsis nodes.Expr node & at least one other statement.
  • Fix false positive for used-before-assignment for assignments taking place via nonlocal declarations after an earlier type annotation.

    Closes #​5394

  • Fix crash for redefined-slots-in-subclass when the type of the slot is not a const or a string.

    Closes #​6100

  • Only raise not-callable when all the inferred values of a property are not callable.

    Closes #​5931

  • Fix a false negative for subclassed-final-class when a set of other messages were disabled.

v2.13.4

Compare Source

  • Fix false positive regression in 2.13.0 for used-before-assignment for homonyms between variable assignments in try/except blocks and variables in a comprehension's filter.

    Closes #​6035

  • Include testing_pylintrc in source and wheel distributions.

    Closes #​6028

  • Fix crash in super-init-not-called checker when using ctypes.Union.

    Closes #​6027

  • Fix crash for unneccessary-ellipsis checker when an ellipsis is used inside of a container or a lambda expression.

    Closes #​6036 Closes #​6037 Closes #​6048

v2.13.3

Compare Source

  • Fix false positive for unnecessary-ellipsis when using an ellipsis as a default argument.

    Closes #​5973

  • Fix crash involving unbalanced tuple unpacking.

    Closes #​5998

  • Fix false positive for 'nonexistent-operator' when repeated '-' are separated (e.g. by parens).

    Closes #​5769

v2.13.2

Compare Source

  • Fix crash when subclassing a namedtuple.

    Closes #​5982

  • Fix false positive for superfluous-parens for patterns like "return (a or b) in iterable".

    Closes #​5803

  • Fix a false negative regression in 2.13.0 where protected-access was not raised on functions.

    Fixes #​5989

  • Better error messages in case of crash if pylint can't write the issue template.

    Refer to #​5987

v2.13.1

Compare Source

  • Fix a regression in 2.13.0 where used-before-assignment was emitted for the usage of a nonlocal in a try block.

    Fixes #​5965

  • Avoid emitting raising-bad-type when there is inference ambiguity on the variable being raised.

    Closes #​2793

  • Loosen TypeVar default name pattern a bit to allow names with multiple uppercase characters. E.g. HVACModeT or IPAddressT.

    Closes #​5981

  • Fixed false positive for unused-argument when a nonlocal name is used in a nested function that is returned without being called by its parent.

    Closes #​5187

  • Fix program crash for modified_iterating-list/set/dict when the list/dict/set being iterated through is a function call.

    Closes #​5969

  • Don't emit broken-noreturn and broken-collections-callable errors inside if TYPE_CHECKING blocks.

v2.13.0: 2.13.0

Compare Source

  • Add missing dunder methods to unexpected-special-method-signature check.

  • No longer emit no-member in for loops that reference self if the binary operation that started the for loop uses a self that is encapsulated in tuples or lists.

    Ref PyCQA/astroid#1360 Closes #​4826

  • Output better error message if unsupported file formats are used with pyreverse.

    Closes #​5950

  • Fix pyreverse diagrams type hinting for classmethods and staticmethods.

  • Fix pyreverse diagrams type hinting for methods returning None.

  • Fix matching --notes options that end in a non-word character.

    Closes #​5840

  • Updated the position of messages for class and function defintions to no longer cover the complete definition. Only the def or class + the name of the class/function are covered.

    Closes #​5466

  • using-f-string-in-unsupported-version and using-final-decorator-in-unsupported-version msgids were renamed from W1601 and W1602 to W2601 and W2602. Disabling using these msgids will break. This is done in order to restore consistency with the already existing msgids for apply-builtin and basestring-builtin from the now deleted python 3K+ checker. There is now a check that we're not using existing msgids or symbols from deleted checkers.

    Closes #​5729

  • The line numbering for messages related to function arguments is now more accurate. This can require some message disables to be relocated to updated positions.

  • Add --recursive option to allow recursive discovery of all modules and packages in subtree. Running pylint with --recursive=y option will check all discovered .py files and packages found inside subtree of directory provided as parameter to pylint.

    Closes #​352

  • Add modified-iterating-list, modified-iterating-dict and modified-iterating-set, emitted when items are added to or removed from respectively a list, dictionary or set being iterated through.

    Closes #​5348

  • Fix false-negative for assignment-from-none checker using list.sort() method.

    closes #​5722

  • New extension import-private-name: indicate imports of external private packages and objects (prefixed with _). It can be loaded using load-plugins=pylint.extensions.private_import.

    Closes #​5463

  • Fixed crash from arguments-differ and arguments-renamed when methods were defined outside the top level of a class.

    Closes #​5648

  • Removed the deprecated check_docs extension. You can use the docparams checker to get the checks previously included in check_docs.

    Closes #​5322

  • Added a testutil extra require to the packaging, as gitpython should not be a dependency all the time but is still required to use the primer helper code in pylint.testutil. You can install it with pip install pylint[testutil].

    Closes #​5486

  • Reinstated checks from the python3 checker that are still useful for python 3 (eq-without-hash). This is now in the pylint.extensions.eq_without_hash optional extension.

    Closes #​5025

  • Fixed an issue where ungrouped-imports could not be disabled without raising useless-suppression.

    Ref #​2366

  • Added several checkers to deal with unicode security issues (see Trojan Sources <https://trojansource.codes/>_ and PEP 672 <https://www.python.org/dev/peps/pep-0672/>_ for details) that also concern the readability of the code. In detail the following checks were added:

    • bad-file-encoding checks that the file is encoded in UTF-8 as suggested by PEP8 <https://www.python.org/dev/peps/pep-0008/#id20>*. UTF-16 and UTF-32 are not supported by Python <https://bugs.python.org/issue1503789>* at the moment. If this ever changes invalid-unicode-codec checks that they aren't used, to allow for backwards compatibility.

    • bidirectional-unicode checks for bidirectional unicode characters that could make code execution different than what the user expects.

    • invalid-character-backspace, invalid-character-carriage-return, invalid-character-sub, invalid-character-esc, invalid-character-zero-width-space and invalid-character-nul to check for possibly harmful unescaped characters.

    Closes #​5281

  • Use the tomli package instead of toml to parse .toml files.

Closes #​5885

  • Fix false positive - Allow unpacking of self in a subclass of typing.NamedTuple.

Closes #​5312

  • Fixed false negative unpacking-non-sequence when value is an empty list.

Closes #​5707

  • Better warning messages for useless else or elif when a function returns early.

    Closes #​5614

  • Fixed false positive consider-using-dict-comprehension when creating a dict using a list of tuples where key AND value vary depending on the same condition.

    Closes #​5588

  • Fixed false positive for global-variable-undefined when global is used with a class name

    Closes #​3088

  • Fixed false positive for unused-variable when a nonlocal name is assigned as part of a multi-name assignment.

    Closes #​3781

  • Fixed a crash in unspecified-encoding checker when providing None to the mode argument of an open() call.

    Closes #​5731

  • Fixed a crash involving a NewType named with an f-string.

    Closes #​5770 Ref PyCQA/astroid#1400

  • Improved bad-open-mode message when providing None to the mode argument of an open() call.

    Closes #​5733

  • Added lru-cache-decorating-method checker with checks for the use of functools.lru_cache on class methods. This is unrecommended as it creates memory leaks by never letting the instance getting garbage collected.

    Closes #​5670

  • Fixed crash with recursion error for inference of class attributes that referenced the class itself.

    Closes #​5408 Ref PyCQA/astroid#1392

  • Fixed false positive for unused-argument when a method overridden in a subclass does nothing with the value of a keyword-only argument.

    Closes #​5771 Ref PyCQA/astroid#1382

  • The issue template for crashes is now created for crashes which were previously not covered by this mechanism.

    Closes #​5668

  • Rewrote checker for non-ascii-name. It now ensures all Python names are ASCII and also properly checks the names of imports (non-ascii-module-import) as well as file names (non-ascii-file-name) and emits their respective new warnings.

    Non ASCII characters could be homoglyphs (look alike characters) and hard to enter on a non specialized keyboard. See Confusable Characters in PEP 672 <https://www.python.org/dev/peps/pep-0672/#confusable-characters-in-identifiers>_

  • When run in parallel mode pylint now pickles the data passed to subprocesses with the dill package. The dill package has therefore been added as a dependency.

  • An astroid issue where symlinks were not being taken into account was fixed

    Closes #​1470 Closes #​3499 Closes #​4302 Closes #​4798 Closes #​5081

  • Fix a crash in unused-private-member checker when analyzing code using type(self) in bound methods.

    Closes #​5569

  • Optimize parsing of long lines when missing-final-newline is enabled.

    Closes #​5724

  • Fix false positives for used-before-assignment from using named expressions in a ternary operator test and using that expression as a call argument.

    Closes #​5177, #​5212

  • Fix false positive for undefined-variable when namedtuple class attributes are used as return annotations.

    Closes #​5568

  • Fix false negative for undefined-variable and related variable messages when the same undefined variable is used as a type annotation and is accessed multiple times, or is used as a default argument to a function.

    Closes #​5399

  • Pyreverse - add output in mermaidjs format

  • Emit used-before-assignment instead of undefined-variable when attempting to access unused type annotations.

    Closes #​5713

  • Added confidence level CONTROL_FLOW for warnings relying on assumptions about control flow.

  • used-before-assignment now considers that assignments in a try block may not have occurred when the except or finally blocks are executed.

    Closes #​85, #​2615

  • Fixed false negative for used-before-assignment when a conditional or context manager intervened before the try statement that suggested it might fail.

    Closes #​4045

  • Fixed false negative for used-before-assignment in finally blocks if an except handler did not define the assignment that might have failed in the try block.

  • Fixed extremely long processing of long lines with comma's.

    Closes #​5483

  • Fixed crash on properties and inherited class methods when comparing them for equality against an empty dict.

    Closes #​5646

  • Fixed a false positive for assigning-non-slot when the slotted class defined __setattr__.

    Closes #​3793

  • Fixed a false positive for invalid-class-object when the object being assigned to the __class__ attribute is uninferable.

  • Fixed false positive for used-before-assignment with self-referential type annotation in conditional statements within class methods.

    Closes #​5499

  • Add checker redefined-slots-in-subclass: Emitted when a slot is redefined in a subclass.

    Closes #​5617

  • Fixed false positive for global-variable-not-assigned when the del statement is used

    Closes #​5333

  • By default, pylint does no longer take files starting with .# into account. Those are considered emacs file locks. See https://www.gnu.org/software/emacs/manual/html_node/elisp/File-Locks.html. This behavior can be reverted by redefining the ignore-patterns option.

    Closes #​367

  • Fixed a false positive for used-before-assignment when a named expression appears as the first value in a container.

    Closes #​5112

  • used-before-assignment now assumes that assignments in except blocks may not have occurred and warns accordingly.

    Closes #​4761

  • When evaluating statements after an except block, used-before-assignment assumes that assignments in the except blocks took place if the corresponding try block contained a return statement.

    Closes #​5500

  • Fixed a false negative for used-before-assignment when some but not all except handlers defined a name relied upon after an except block when the corresponding try block contained a return statement.

    Closes #​5524

  • When evaluating statements in the else clause of a loop, used-before-assignment assumes that assignments in the except blocks took place if the except handlers constituted the only ways for the loop to finish without breaking early.

    Closes #​5683

  • used-before-assignment now checks names in try blocks.

  • Fixed false positive with used-before-assignment for assignment expressions in lambda statements.

    Closes #​5360, #​3877

  • Fixed a false positive (affecting unreleased development) for used-before-assignment involving homonyms between filtered comprehensions and assignments in except blocks.

    Closes #​5586

  • Fixed crash with slots assignments and annotated assignments.

    Closes #​5479

  • Fixed crash on list comprehensions that used type as inner variable name.

    Closes #​5461

  • Fixed crash in use-maxsplit-arg checker when providing the sep argument to str.split() by keyword.

    Closes #​5737

  • Fix false positive for unused-variable for a comprehension variable matching an outer scope type annotation.

    Closes #​5326

  • Fix false negative for undefined-variable for a variable used multiple times in a comprehension matching an unused outer scope type annotation.

    Closes #​5654

  • Some files in pylint.testutils were deprecated. In the future imports should be done from the pylint.testutils.functional namespace directly.

  • Fixed false positives for no-value-for-parameter with variadic positional arguments.

    Closes #​5416

  • safe_infer no longer makes an inference when given two function definitions with differing numbers of arguments.

    Closes #​3675

  • Fix comparison-with-callable false positive for callables that raise, such as typing constants.

    Closes #​5557

  • Fixed a crash on __init__ nodes when the attribute was previously uninferable due to a cache limit size. This limit can be hit when the inheritance pattern of a class (and therefore of the __init__ attribute) is very large.

    Closes #​5679

  • Fix false positive for used-before-assignment from a class definition nested under a function subclassing a class defined outside the function.

    Closes #​4590

  • Fix unnecessary_dict_index_lookup false positive when deleting a dictionary's entry.

    Closes #​4716

  • Fix false positive for used-before-assignment when an except handler shares a name with a test in a filtered comprehension.

    Closes #​5817

  • Fix crash in unnecessary-dict-index-lookup checker if the output of items() is assigned to a 1-tuple.

    Closes #​5504

  • When invoking pylint, epylint, symilar or pyreverse by importing them in a python file you can now pass an argv keyword besides patching sys.argv.

    Closes #​5320

  • The PyLinter class will now be initialized with a TextReporter as its reporter if none is provided.

  • Fix super-init-not-called when parent or self is a Protocol

    Closes #​4790

  • Fix false positive not-callable with attributes that alias NamedTuple

    Partially closes #​1730

  • Emit redefined-outer-name when a nested except handler shadows an outer one.

    Closes #​4434 Closes #​5370

  • Fix false positive super-init-not-called for classes that inherit their init from a parent.

    Closes #​4941

  • encoding can now be supplied as a positional argument to calls that open files without triggering unspecified-encoding.

    Closes #​5638

  • Fatal errors now emit a score of 0.0 regardless of whether the linted module contained any statements

    Closes #​5451

  • fatal was added to the variables permitted in score evaluation expressions.

  • The default score evaluation now uses a floor of 0.

    Closes #​2399

  • Fix false negative for consider-iterating-dictionary during membership checks encapsulated in iterables or not in checks

    Closes #​5323

  • Fixed crash on uninferable decorators on Python 3.6 and 3.7

  • Add checker unnecessary-ellipsis: Emitted when the ellipsis constant is used unnecessarily.

    Closes #​5460

  • Disable checker bad-docstring-quotes for Python <= 3.7, because in these versions the line numbers for decorated functions and classes are not reliable which interferes with the checker.

    Closes #​3077

  • Fixed incorrect classification of Numpy-style docstring as Google-style docstring for docstrings with property setter documentation. Docstring classification is now based on the highest amount of matched sections instead of the order in which the docstring styles were tried.

  • Fixed detection of arguments-differ when superclass static methods lacked a @staticmethod decorator.

    Closes #​5371

  • TypingChecker

  • The testutils for unittests now accept end_lineno and end_column. Tests without these will trigger a DeprecationWarning.

  • arguments-differ will no longer complain about method redefinitions with extra parameters that have default values.

    Closes #​1556, #​5338

  • Fixed false positive unexpected-keyword-arg for decorators.

    Closes #​258

  • Importing the deprecated stdlib module xml.etree.cElementTree now emits deprecated_module.

    Closes #​5862

  • Disables for deprecated-module and similar warnings for stdlib features deprecated in newer versions of Python no longer raise useless-suppression when linting with older Python interpreters where those features are not yet deprecated.

  • Importing the deprecated stdlib module distutils now emits deprecated_module on Python 3.10+.

  • missing-raises-doc will now check the class hierarchy of the raised exceptions

    .. code-block:: python

    def my_function() """My function.

    Raises:
      Exception: if something fails
    """
    raise ValueError

    Closes #​4955

  • Allow disabling duplicate-code with a disable comment when running through pylint.

    Closes #​214

  • Improve invalid-name check for TypeVar names. The accepted pattern can be customized with --typevar-rgx.

    Closes #​3401

  • Added new checker typevar-name-missing-variance. Emitted when a covariant or contravariant TypeVar does not end with _co or _contra respectively or when a TypeVar is not either but has a suffix.

  • Allow usage of mccabe 0.7.x release

    Closes #​5878

  • Fix unused-private-member false positive when accessing private methods through property.

    Closes #​4756

Microsoft/pyright (pyright)

v1.1.361: Published 1.1.361

Compare Source

Bug Fixes:

  • Fixed a bug that results in a false negative when using bidirectional type inference to evaluate the type of a lambda expression if the expected type is a union of two or more callables.
  • Fixed bug caused by incorrect synthesis of item and keys attributes for named tuple classes.
  • Fixed bug that resulted in incorrect bidirectional type inference when calling a constructor for a generic class that defines no __new__ or __init__ method.
  • Fixed bug that results in a false positive error when a yield statement is used within a lambda following a function.
  • Fixed a bug that led to poor performance (effectively a hang) if an unannotated function is called through many (greater than 8) call expressions within a loop using different literal-value arguments each time.
  • Fixed a bug that results in a false positive error when using __extra_items__ (PEP 728) with a TypedDict imported from typing_extensions.
  • Fixed a bug that leads to an infinite loop when performing protocol matching under certain circumstances that involve recursive protocol definitions.
  • Fixed a bug that results in a false positive error when Callable() is used as a class pattern and the subject type is Any or Unknown.
  • Fixed a false negative that occurs when reassigning a Final variable within a class body.
  • Changed the tokenizer so it is bug-for-bug compatible with the CPython tokenizer in versions 3.10 and newer in the case where a backslash (continuation character) is located by itself on a line.
  • Fixed a bug that results in incorrect type evaluation when a global (module-scoped) variable is captured within an inner scope and the variable is not modified anywhere below the inner scope. It's possible in this case for the variable to be modified by code outside of the module.
  • Fixed bug that resulted in incorrect evaluation of an identifier used in a method parameter type annotation if it shadows a forward reference in a class scope when the method is using PEP 695 type parameters.
  • Fixed a bug that results in a false negative when an Unpack is used in a union. This isn't allowed.
  • Fixed bug that produces incorrect output when converting to a textual representation the type type[Foo] where Foo is a type alias.

Behavior Changes:

  • Changed logic that synthesizes the constructor methods for a NamedTuple subclass (using the class syntax) so the __new__ method contains parameters based on field names and the __init__ method contains a general *args: Any, **kwargs: Any parameter signature. Previously, this was swapped, but the new way is more faithful to the runtime.
  • Changed TypeIs to use the same logic as isinstance type narrowing logic for consistency.

v1.1.360: Published 1.1.360

Compare Source

Enhancements:

  • Added support for @deprecation messages for decorators that wrap a function in a callable object. The deprecated message is now propagated through the ParamSpec and the __call__ method.
  • Updated typeshed stubs to the latest version.

Behavior Changes:

  • Moved check for invalid use of class-scoped TypeVar within a self annotation in __init__. It was previously reported under reportGeneralTypeIssues, but it's now moved to reportInvalidTypeVarUse. This was done to help typeshed maintainers migrate away from this pattern.
  • Changed behavior to no longer exempt unguarded access to not-required TypedDict member within a try or with block. Previously, such errors were exempt, but this is inconsistent with other type checks in pyright which eschew the practice of using exception handling for normal code flow.

Bug Fixes:

  • Fixed recent regression that affected unannotated __call__ methods in a metaclass. This change aligns pyright's behavior to the typing spec.
  • Fixed recent regression that incorrectly narrowed the type of kwargs when used in a type guard of the form if "a" in kwargs.
  • Fixed bug in protocol matching that results in a false positive when the subject object is a dataclass that contains a callable. It should be considered an instance member in this case, so it should not be bound to the class.
  • Fixed a bug that results in a false positive error when bidirectional type inference is used for a dictionary comprehension when the expected type is a union.
  • Redesigned the handling of PEP 695-style type parameter scoping to better match the CPython runtime implementation. This fixes multiple bugs with type parameter symbol resolution. For example, if a type parameter is quoted as a forward reference.
  • Fixed bug that leads to false negative when binding an object to an overloaded method where all of the overloads have incompatible self parameter types.
  • Fixed bug that leads to incorrect metatype for a class object that is created by calling the metaclass with a two-argument form.

v1.1.359: Published 1.1.359

Compare Source

Enhancements:

  • Expanded support for len(x) == L type guard pattern (where x is a tuple) to support <, <=, > and >= comparisons as well.
  • Improved some diagnostic messages, moving away from the term "member" to prefer "attribute". Switched from "cannot assign to type" to "incompatible with type" for consistency and clarity.
  • Extended type narrowing logic for in and not in operators that target TypedDicts to also support constrained TypeVars that use TypedDicts as value constraints.
  • Added a check for the case where a frozen dataclass overrides a field from its parent class but doesn't provide a default value (where its parent does). This can result in a type violation if the parent's default value is not compatible with the child's (covariant) field type.

Behavior Changes:

  • Changed behavior when evaluating the upper bound expression, value constraints expression, or default expression for a PEP-695 type parameter. At runtime, these are always evaluated in a deferred manner even if they are not quoted. Pyright now follows the runtime behavior.
  • Modified handling of annotated self parameter in __init__ method when evaluating constructor call so pyright conforms to the latest typing spec.
  • Added missing check for the errant use of class-scoped type variables in a type annotation for the "self" parameter within an "init" method. The typing spec now clarifies that this is illegal and should generate an error.
  • Updated logic for converting a class constructor to a callable to conform to the newly-updated typing spec.
  • Changed the behavior when invoking constructor for type[T] where T is a TypeVar with no explicit upper bound (and therefore has an implicit upper bound of object). According to the newly-clarified typing spec, this should enforce the constructor signature of object.
  • Modified behavior in constructor call code that previously applied some (now non-compliant) heuristics to reconcile a metaclass __call__ method with a __new__ method. The new behavior is now compliant with the typing spec.
  • Changed behavior of conversion from class constructor to callable to conform with the typing spec in the case where the __new__ method of the class returns a value that indicates the __init__ method should be ignored.
  • Changed behavior of conversion from class constructor to callable to conform to honor the annotated type of self in the __init__ method.
  • Changed behavior of conversion from class constructor to callable to conform to honor return type of the __new__ method.

Bug Fixes:

  • Fixed a bug that leads to inconsistent behaviors when an assignment leads to a type violation. When assigning to a local variable, the target expression is not "narrowed" to include the assigned type in this case. The new behavior applies this same behavior when assigning to instance or class variables.
  • Fixed recent regression that results in a false positive error when applying a @property decorator to a method that has already had a decorator applied to it.
  • Fixed bug that results in a spurious reportAbstractUsage error when an abstract class is captured through a type[T].
  • Fixed bug that results in incorrect type evaluation when solving a ParamSpec type when there are multiple constraints provided.
  • Fixed a bug that results in incorrect type evaluation when assigning a function with a NoReturn return type to a Callable[..., T].
  • Fixed a bug that leads to a false negative when an unparenthesized assignment expression is used in a dictionary key within a dictionary expression or comprehension.
  • Fixed bug that results in false positive error under certain circumstances that involve unions of TypeVars in an invariant context.

v1.1.358: Published 1.1.358

Compare Source

Bug Fixes:

  • (from Pylance): Fixed a bug that caused a crash under certain circumstances when an import cannot be resolved.
  • Fixed non-compliance issue with TypeIs, which is documented to have an invariant type parameter.
  • Fixed a bug that results in incorrect type evaluation when a sequence pattern in a match statement includes a * element and the subject includes a tuple with an element with indeterminate length.
  • Fixed bug that results in an intermittent false positive "circular dependency" error for fields within a dataclass.
  • Fixed a bug that results in a false positive error under certain circumstances when a TypeVar or TypeVarTuple is being solved with literal values in both an invariant and non-invariant context.
  • Fixed bug that results in incorrect type evaluation in cases where a generic function returns a callable, and the function is called with a higher-order generic function as an argument.
  • Fixed a bug that results in a false negative when a generic function returns a Callable type that is specialized to include a live (in-scope) type variable.
  • Fixed bug that results in inconsistent type narrowing on assignment based on whether the assignment occurs within the same statement that includes the (declared) type annotation for the variable and whether the type annotation is provided as a type comment.

Enhancements:

  • Added optimization for TypedDict type assignments. Under certain circumstances (e.g. when comparing large unions of TypedDict types), this can save significant time.
  • Modified the handling of enum class attributes so those with private (mangled) names are exempted from being considered enum members. This reflects the runtime behavior.
  • Added support for narrowing of subject subexpression within a match statement for references to the subexpression after the completion of the match statement.
  • Updated typeshed stubs to the latest version.
  • Improved error handling for quoted annotations. Bytes, raw strings, and f-strings are not allowed according to the typing spec.
  • Added an error message for a Literal type annotation that includes a string with a named unicode escape sequence. These are not supported.

v1.1.357: Published 1.1.357

Compare Source

Bug Fixes:

  • Fixed bug that results in a false positive error when explicitly calling __new__ on a dataclass, namedtuple, or TypedDict. These classes all require synthesized __new__ methods.
  • Fixed bug that results in false negative when a __new__ or __init__ method cannot be bound without a type violation.
  • Fixed a bug that results in incorrect type narrowing of enums that derive from enum.Flag.
  • Fixed a type hole when a dictionary expression includes a dictionary expansion operator that acts on a non-closed TypedDict.
  • Fixed bug that results in a type not being narrowed when using the K in TD type guard pattern (where TD is a TypedDict and K is a literal key). Narrowing was skipped if the RHS operand was not a simple identifier.
  • Fixed inconsistent handling of literal values in a list comprehension.
  • Fixed a bug that results in a false positive error when an unpacked TypeVarTuple is used in a function defined with PEP-695 syntax.
  • (From Pylance) Improved heap usage tracking within language server to reduce the likelihood of crashes related to heap exhaustion.
  • Fixed a bug that results in incorrect inferred parameter types for an unannotated method in a subclass when the parent class method contains function-scoped TypeVars.

Enhancements:

  • Added support for negative (fall-through) type narrowing for subject subexpressions in match statement when subject consists of a tuple expression and patterns exhaustively match the tuple.
  • Enhanced dictionary type evaluation to support dictionary items that overwrite previous dictionary items. Only the last value type is now considered, so if previous values (which are overwritten) would otherwise violate typing rules, this no longer generates a type error.
  • Enhanced discriminated class support to include not only literal field values but also None.
  • Improved diagnostic message for access to unknown member in the case where the user probably meant to access an item in a TypedDict but used a member access expression rather than an index expression.
  • Improved return result for synthesized get method for closed TypedDict classes (as defined in PEP 728).
  • Refactored tokenizer and parser output to help reduce the amount of memory needed.

Behavior Changes:

  • Changed the handling of Final variables (that are not explicitly marked ClassVar) within dataclass class bodies. This is consistent with the runtime and this proposed change to the typing spec.

v1.1.356: Published 1.1.356

Compare Source

Bug Fixes:

  • Fixed bug that results in a false positive error when a class-scoped TypeVar with a default that references another class-scoped TypeVar is used in a method signature in that class.
  • Fixed bug that resulted in a false positive error if a PEP-695 type statement uses a type parameter and encloses the RHS in quotes.
  • Fixed bug that results in incorrect type narrowing in the negative (fall-through) case when a runtime-checkable protocol class is used as a class pattern with arguments within a match statement.
  • Fixed a bug that results in a false positive when a class-scoped TypeVar used within a method has a default that refers to another class-scoped TypeVar.
  • Fixed a bug that results in a false positive reportImplicitOverride diagnostic if the class derives from an Unknown or Any class.

Behavior Changes:

  • Tweaked bidirectional type inference behaviors for lists to improve certain inference cases.
  • Changed the logic for metaclass instance variable lookups to ignore the lookup if the metaclass MRO contains an unknown class.

Enhancements:

  • Update Unicode range tables to match Unicode 15.1.
  • Added check for the use of a non-runtime-checkable protocol class in a class pattern. This generates an exception at runtime.
  • Updated typeshed stubs to the latest version.

v1.1.355: Published 1.1.355

Compare Source

Bug Fixes:

  • Fixed a bug that results in incorrect type evaluation if a list expression includes a generator expression.
  • Fixed bug that results in a false negative when a TypeAliasType object is used in a class pattern.
  • Fixed bug that results in false positive when implicitly specializing a class parameterized by a TypeVarTuple when there is no default.
  • Fixed bug that results in false positive when a list or set expression is evaluated using bidirectional type inference when the expected type is MutableSet or MutableSequence.
  • Fixed bug that results in a false negative when overriding a method that has keyword parameters with a method that has a *args parameter.
  • Fixed a bug that results in a false positive error in certain circumstances involving a TypeVarTuple used within an overload.
  • Fixed bug that results in a false positive error when a base class defines a writable property and a subclass writes to the property.
  • Fixed bug that results in a false positive "overload implementation does not match overloads" diagnostic when positional-only and keyword-only parameters are involved.
  • Fixed a bug that results in a false positive in a complex situation that involves generic protocols, properties, and mix-in classes.
  • Fixed bug that results in false positive error when a __new__ method in a metaclass uses PEP 692 (unpacked TypeDict) to annotate its **kwargs parameter.

Enhancements:

  • Updated typeshed stubs to the latest. This version of typeshed replaces the older-style positional-only parameters with PEP 570 syntax.
  • Improved validation for except and except* statements to catch some previously-undetected invalid cases.
  • Expanded handling of python versions to handle more than just major/minor version numbers. Pyright now handles micro, releaseLevel, and serial numbers as well.

v1.1.354: Published 1.1.354

Compare Source

Bug Fixes:

  • Fixed a bug that resulted in an incorrect type evaluation when an augmented assignment is used within an inner-scoped function to add a constant to a variable. Literal math should not be used in this case.
  • Fixed two bugs that resulted in false negatives when redefining a constant variable with a non-variable symbol and when redefining a Final variable with a non-variable symbol.
  • Fixed bug that results in false positive when a generic class or type alias uses a TypeVarTuple followed by one or more ParamSpecs that have default values.
  • Fixed bug that resulted in false negative when narrowing a constrained or bound TypeVar with a complex() or float() class pattern.
  • Fixed bug that results in a false positive under certain circumstances when a constrained TypeVar is used as the default for another constrained TypeVar.
  • Fixed a bug that results in a false positive under certain circumstances when defining a type alias using the old typing.TypeAlias annotation.
  • Fixed a bug that results in a false negative when a class explicitly inherits from a protocol that defines an instance variable but the child re-declares as a ClassVar without an explicit type.
  • Fixed a bug that made locale overrides through environment variables no longer work on node 21.

Enhancements:

  • Enhanced handling of type function when it is passed a class. Pyright previously evaluated this as Any, but now it returns the class' metaclass.
  • Added check for generic classes and type aliases that include a TypeVarTuple followed by a TypeVar that has a default value. This is illegal according to PEP 696.
  • Changed the behavior when accessing a class attribute from a generic class that is not specialized. The class is now automatically specialized in the case using default type parameter values (from PEP 696) or Unknown. This change is required for conformance with PEP 696.
  • (From pylance) Added some optimizations to the tokenizer to reduce memory usage.
  • Added new reportUnhashable diagnostic rule.

v1.1.353: Published 1.1.353

Compare Source

Breaking Changes:

  • The CLI and language server versions of pyright now require a minimum node version of 14. Previously node 12 and 13 were supported.

Enhancements:

  • Enabled PEP 705 and PEP 696 functionality without the use of enableExperimentalFeatures now that these PEPs are officially accepted.
  • Improved support for instance variables whose type is declared in a metaclass. Pyright now honors this type and enforces type consistency in derived classes.

Bug Fixes:

  • Fixed a bug that results in a false negative when a dundered method overrides a base class method of the same name and uses different parameter names along with different types.
  • Fixed a bug that leads to a false positive error when a match statement is used in a loop and the subject expression is potentially narrowed as a result of the match statement.
  • Added check for inappropriate use of Annotated passed as second argument to NewType call.
  • Fixed a bug that results in a false positive error when expanding the type arguments to a TypeVarTuple under certain circumstances.
  • Fixed a bug that results in incorrect type evaluation when an index expression is assigned a value within a doubly-nested loop under certain circumstances.
  • Fixed a regression that caused the signature help provider to not display the __new__ method of a constructor if it is overloaded.
  • Fixed hard-coded type information for module attribute __package__. It should be str | None rather than str.
  • Fixed a bug in the isinstance type guard logic. It was not properly handling tuples that included unions.
  • Fixed bug in signature help provider so str method docstrings are showed when called on LiteralString.
  • Fixed a bug that results in incorrect type narrowing behavior for member access expressions under certain circumstances.
  • Fixed bug that resulted in a false negative when a possibly-unbound variable is captured by an inner scope under certain circumstances.

v1.1.352: Published 1.1.352

Compare Source

Enhancements:

  • Implemented provisional support for PEP 728 (support for extra items within TypedDicts). You must set enableExperimentalFeatures to true for now.
  • Added support for concatenated strings used in a @deprecated decorator.
  • Added support for call-site return type inference for class and instance methods.
  • Improved handling of enum.nonmember in cases where the attribute has a declared type.
  • Added missing check for inappropriate use of InitVar outside of a dataclass.

Behavior Changes:

  • Added special-case handling for 'typing_extensions' module whose stubs are part of typeshed's stdlib stubs even though it is not part of stdlib.
  • Refined the heuristic for when to use bidirectional type inference for the RHS of and and or operators.
  • Changed behavior of command-line "--pythonversion" and "--pythonplatform" options so they now override the same-named options in the config file.

Bug Fixes:

  • Fixed a bug that resulted in a false negative when attempting to use TypedDict or Protocol as an upper bound when using PEP 695 syntax.
  • Fixed a bug that resulted in "reportUnnecessaryTypeIgnoreComment" diagnostics to be generated even if the source file was in the "ignore" list.
  • Fixed a bug that leads to incorrect type inference for a lambda when passed to a constructor in certain circumstances.
  • Fixed a bug that leads to a false positive type violation when reassigning a value within a loop and the target variable has a declared type of a constrained type variable.
  • Fixed a bug that results in a false negative when passing an unpacked dict of the wrong type to a function that contains a positional-only parameter marker plus one or more keyword parameters.
  • Fixed a bug in the import resolver that resulted in an incorrect resolution when an import within a __init__.py file uses the form from .a import a.
  • Fixed a bug that results in a false positive error when an await expression is passed as an argument to an overloaded function.
  • Fixed a bug that results in an incorrect "Unbound" type evaluation for a variable assigned within a loop.

v1.1.351: Published 1.1.351

Compare Source

Bug Fixes:

  • Fixed bug that results in a false positive "no overload implementation" error if an overloaded function is passed through a decorator that uses a ParamSpec.
  • Fixed a recent regression that results in a false positive error when an Enum subclass overrides __new__ or __init__ and then a subclass of that class assigns tuple values when defining enum members
  • Fixed a bug that results in a false positive error when a method defined within a named tuple is overridden by a subclass
  • Fixed a bug that results in a false positive error when a enum.nonmember value is assigned to a class-scoped variable with a type annotation in an Enum class.
  • Fixed a bug in the type narrowing logic for class pattern matching that resulted in incorrect narrowing in the negative (fall-through) case.
  • Added missing check for inappropriate use of an unpacked TypeVarTuple within a TypeAliasType type parameter list.
  • Fixed a false positive reportUnknownArgumentType error when assigning an empty list or dict expression to an index expression subscripted with a slice.
  • Fixed bug that results in a false positive error when assigning a tuple value that includes an unpacked TypeVarTuple to another tuple that also includes an unpacked TypeVarTuple.
  • Fixed bug that results in a false positive error when calling update on a TypedDict with zero defined entries.
  • Fixed a bug that results in a false positive with the reportUnnecessaryCast check if the second argument is a special form.
  • Fixed a bug that led to incorrect type evaluation for a call that targets a generic function that uses a default argument for one of the generic parameters.

Behavior Changes:

  • Change the heuristic for determining whether a metaclass supports __or__. In the case where the metaclass derives from Any or Unknown, pyright now assumes that it doesn't override __or__.
  • Changed behavior of CLI's --watch mode. Previously, it reported diagnostic deltas when it detected a change, but it is more useful if it reports all remaining diagnostics even for files that it didn't reanalyze due to a file change.

Enhancements:

  • Updated typeshed stubs to the latest version.
  • Added provisional support for draft PEP 742 (TypeIs).
  • Added check for the use of an implicit position-only parameter (one that starts with a double underscore) that is located after a non-position-only parameter.

v1.1.350: Published 1.1.350

Compare Source

Bug Fixes:

  • Fixed a bug that resulted in an incorrect type evaluation when a TypeVar with a default (PEP 696) was used in an overload but was not solved.
  • Fixed a bug that results in a false negative when a None type is included in an unpacked argument within a function call.
  • Fixed a bug that results in a false positive error when a TypeVar bound to a union of literals is used in the specialization of a TypeAlias whose TypeVar is bound to a wider union of literals.
  • Fixed bug in isinstance type narrowing logic that leads to incorrect narrowed type when the filter type (the second argument) and the test type (the first argument) are both type variables.

Behavior Changes:

  • Changed behavior of super() method call when self is annotated as a protocol class. This pattern is used for annotating mix-ins. In this case, pyright should not generate an error if the protocol's method isn't implemented.
  • Added code to deduplicate references returned by the textDocument/references LSP call.

Enhancements:

  • [contributed by @​Seairth] Added multi-root workspaceFolder support in path variable expansion.
  • Improved logic for unpacked arguments that contain an "Unbound" type.
  • Improved handling of unreachability analysis for an "implied else" (an if/elif chain that is missing a final "else" clause).
  • Added check for an attempt to override a field in a named tuple within a subclass.
  • Added check for an attempt to delete a named tuple entry.
  • Added check for use of TypedDict or NamedTuple as second argument to isinstance call, which isn't allowed.
  • Added check for out-of-bound index accesses for named tuple instances.
  • Improved misleading diagnostic message when attempting to call a special type form.
  • Updated typeshed stubs to the latest version.

v1.1.349: Published 1.1.349

Compare Source

Bug Fixes:

  • Fixed default for reportImplicitStringConcatenation in schema file.
  • Fixed a bug that resulted in an incorrect type evaluation for a union type used as a runtime expression. The type should be UnionType, not type[UnionType].
  • Fixed regression that resulted in a false positive error when calling an abstract method on an abstract class that passes through the constraint solver (e.g. a generic decorator).
  • Fixed a bug that results in a false positive when using a TypeVarTuple to capture the parameters of a generic callable that includes one or more default argument values.
  • Fixed bug in tuple type compatibility logic that resulted in a false negative when dest type includes an upacked unbounded tuple plus additional entries.
  • Fixed bug in tuple type compatibility logic that resulted in a false positive when dest type is tuple[Any, ...].
  • Fixed a bug that results in a false negative when the literal typing.Any is passed to a function that accepts a type[T]. Any is a special form and should not be compatible with type.
  • Fixed bug that resulted in incorrect type evaluation when a TypeAliasType is used in a value expression.
  • Fixed a bug that resulted in incorrect type evaluation when calling a tuple constructor with bidirectional type inference and the value passed to the constructor is an Iterable[Any].
  • Fixed a bug that resulted in incorrect type narrowing for sequence patterns when the subject expression contains a tuple with an unbounded component.

Behavior Changes:

  • Removed name consistency match for functional form of Enum. After a discussion in the typing community, it was decided that name consistency checks in some cases were unnecessary and inappropriate for type checkers.
  • Changed the way pyright translates tuple[()] into a specialized Sequence. It used to translate it to Sequence[Any], but the typing spec now clarifies that it should be Sequence[Never].
  • Changed handling of tuple with multiple unpacked embedded tuples. Type spec now clarifies this is OK as long as there are not multiple unbounded embedded tuples.
  • Added special-case logic to handle __name__ and a few other instance variables defined in the type class so they are treated specially when accessed from a class instance.

Enhancements:

  • Added check for inappropriate use of Final in a value expression.
  • Added support for enum member aliases defined within an enum class.
  • Improved error messages for tuple type mismatches that involve tuples with indeterminate types.
  • Added check for the use of Annotated or a type alias defined with Annotated as the second argument to an isinstance or issubclass call. This produces an exception at runtime.
  • Added additional performance enhancements specifically for large unions of literal types.

v1.1.348: Published 1.1.348

Compare Source

Breaking Changes:

Many pyright users have requested finer-grained control over diagnostics — especially for diagnostics that were previously lumped under the catch-all rule reportGeneralTypeIssues. I was hesitant to do this because it is a breaking change and could be disruptive for some pyright users. However, the time has come to make this change.

The list of new diagnostic rules includes:

  • reportAbstractUsage
  • reportArgumentType
  • reportAssertTypeFailure
  • reportAssignmentType
  • reportAttributeAccessIssue
  • reportCallIssue
  • reportInconsistentOverload
  • reportIndexIssue
  • reportInvalidTypeArguments
  • reportInvalidTypeForm
  • reportNoOverloadImplementation
  • reportOperatorIssue
  • reportPossiblyUnboundVariable
  • reportRedeclaration
  • reportReturnType
  • reportUnusedExcept

Refer to the configuration documentation for more details about each of these.

This is a breaking change for code bases that were previously overriding the diagnostic severity for reportGeneralTypeIssues in the config file, in file-level pyright comments or in # type: ignore or # pyright: ignore comments. You will need to update your configuration settings and comments to use the new diagnostic rule names.

Bug Fixes:

  • Fixed bug in pyright's "type printer" that resulted in an incorrect output when printing a specialized type alias parameterized by a TypeVarTuple that has a value that contains a tuple with an indeterminate length.
  • Fixed a bug that resulted in an incorrect type evaluation when a generator uses an await operator within the left-most for. This shouldn't result in an AsyncGenerator despite what the Python documentation indicates.
  • Fixed a bug in the isinstance type narrowing logic when type is filtered using a metaclass instance.
  • Fixed recent regression that resulted in a crash when using certain language server features with an absolute extraPaths value.
  • Fixed spec conformance issue with TypeVarTuple constraint solving. The spec indicates that if a TypeVarTuple is used multiple times in a callee's signature, the tuple must "match exactly".
  • Addressed a bug that led to a false positive (missing error) when a "bare" TypeVar is used as a base class in a class statement.
  • Fixed a bug that masked an error (false negative) under certain circumstances when evaluating a lambda.
  • Fixed a bug that resulted in a false positive error and incorrect type evaluation when an assignment expression (walrus operator) is used in a comprehension.
  • Changed diagnostic rule for the case where Callable is missing a second type argument. It should use reportMissingTypeArgument.
  • Fixed a bug that led to a false negative when an illegal form of tuple was used: tuple[*tuple[str], ...].

Behavior Changes:

  • Changed handling of tuple[Any, ...] so it is treated as though it's bidirectionally type compatible with all tuples regardless of length. This change is made in response to a clarification in the typing spec. It brings pyright in alignment with mypy's behavior in this regard.

Enhancements:

  • Added check for name mismatch for enum classes defined using the functional syntax.
  • Improved handling of custom Enum classes (those that derive from Enum or use EnumMeta).
  • Added special-case logic for enum classes that are invoked as though they are being constructed.
  • Added type enforcement for the _value_ type in an Enum class. Also added enforcement for custom __new__ and __init__ method signatures.
  • Improved handling of Annotated and other special forms when they are used in runtime value expressions rather than annotations.
  • Added error reporting for the situation where a generic instance variable is accessed through a class object.
  • Updated typeshed stubs to the latest version.

v1.1.347: Published 1.1.347

Compare Source

This is a quick-turn release to fix a regression that affected 1.1.346.

Bug Fixes:

  • Fixed regression that caused JSON output of CLI to not follow the documented schema.

Enhancements:

  • Added support for Python 3.11 enum features: enum.member and enum.nonmember.
  • Added new language server setting pyright.disableTaggedHints to disable the use of diagnostics hints with tags. Some language server clients do not display these tagged hints in the intended manner and instead treat them as regular diagnostics.
  • Changed all diagnostics (other than syntax errors and a few special informations) to have an associated diagnostic rule. Previously, some diagnostics had no associated rule.
  • Added support for @​no_type_check decorator.

v1.1.346: Published 1.1.346

Compare Source

Bug Fixes:

  • Added code to properly print a f-string expression in pyright's "expression printer". This affected stub generation if an f-string was used (e.g. in call to a decorator).
  • Fixed a bug that resulted in a false positive error when using a bound TypeVar in an except statement.
  • Fixed a bug that led to a false negative when using a non-data protocol class in a tuple within an issubclass check.
  • Fixed a bug that resulted in incorrect inference of an async generator expression if an await keyword was used in a for iterator expression.
  • Fixed a bug that resulted in an incorrect type evaluation for a sliced tuple if the end of the slice is the same as the tuple length (off-by-one error).
  • Fixed recent regression that results in a false positive error when an unpack operator is used in an Annotated type annotation.
  • Fixed false negative when a special form is assigned to a value declared as type[T] or when instantiated.
  • Added support for generic type alias specialization when the type alias includes an unpacked TypeVarTuple and the specialization list includes an unpacked unbounded tuple.
  • Fixed bug that led to incorrect protocol matching for class objects.
  • Fixed recent regression whereby a type created with NewType was no longer allowed as an argument for another NewType.
  • Fixed a bug that resulted in an incorrect implied specialization of a generic type alias that is parameterized by a TypeVarTuple. The implied type argument should be *tuple[Unknown, ...] in this case.
  • Fixed a bug in class pattern matching logic that incorrectly narrows types when using a str() class pattern and a LiteralString subject.
  • Fixed bug that caused "final method override" diagnostic to have no associated diagnostic rule.
  • Fixed a bug that resulted in incorrect variance inference for protocols (and for PEP inferred-variance TypeVars in PEP 695) when a self or cls parameter is explicitly annotated with a type that includes the type parameter.
  • Fixed a bug that resulted in a false positive when a contravariant TypeVar was used in a return type in a non-method.

Behavior Changes:

  • Changed the way pyright identifies an "unimplemented protocol method" within a stub file. It now looks at whether the method is decorated with @abstractmethod. Previously, it assumed all such methods were potentially implemented.
  • Changed error reporting for non-protocol classes that derive from a protocol but don't implement all of the unimplemented symbols in the protocol. Previously, pyright reported the error on the class declaration. Now, it reports it at instantiation time. This is more consistent with what other type checkers do.

Enhancements:

  • Updated typeshed to the latest version.
  • Added provisional support for proposed extension to typeshed's VERSION mechanism (https://github.com/python/typeshed/issues/11260).
  • Added support for + unary operator in Literal int type annotations. The typing spec was recently amended to allow this.
  • Improved handling of special forms defined in the typing module so they are treated correctly when used as runtime objects.

v1.1.345: Published 1.1.345

Compare Source

Bug Fixes:

  • Fixed bug that led to false negative when a list expression was used within the first type argument of an Annotated type expression.
  • Added a missing error condition for a non-method function that is marked @final.
  • Fixed crash related to a regression introduced with recent internal URI tracking.
  • Fixed false negative for a TypeVarTuple constructor call that includes value constraints.
  • Fixed a bug that led to an incorrect type evaluation for an explicitly-specialized class parameterized with a ParamSpec.
  • Fixed bug that resulted in incorrect type evaluation when a PEP-695 TypeVar is shadowed by an identifier of the same name within an inner scope.
  • Added missing check for inconsistent use of @final in an overloaded function. Added missing check for override of an overloaded method marked @final.
  • Fixed bug in protocol matching logic to reject a protocol match if a variable is a ClassVar in the protocol but not in the concrete class (or vice versa).
  • Fixed bug that leads to a false positive when a generic property is defined within a protocol.
  • Fixed a bug that led to incorrect type evaluation when a constrained TypeVar includes literal types as constraints.
  • Added missing check for the specialization of a generic type alias that includes a TypeVarTuple plus two or more TypeVars.
  • Fixed a bug that resulted in a false negative when specializing a generic type alias parameterized by a regular TypeVar with an unpacked tuple.
  • Added missing error for an illegal unpacked argument in type argument list.
  • Fixed a bug that led to a duplicate error message when defining a class-scoped type alias.

Enhancements:

  • Improved error message for protocol classes that derive from non-protocol classes.
  • Improved error reporting for incompatible overrides.
  • Added code to report when the Concatentate special form is used in an illegal context.
  • Added support for constants for field names in NamedTuple call.
  • Improved evaluation logic for tuple slices. It now works in cases where the tuple includes unbounded entries or unpacked TypeVarTuples.
  • Improved type analysis performance in certain cases involving complex code flow graphs and "truthy" conditional statements.
  • Added check for a call to an unimplemented method in a protocol from a base class that explicitly calls it.
  • Implemented small performance improvement by not generating error messages during protocol TypeVar variance validation.
  • Added check for data protocols used in an issubclass call. PEP 544 indicates that this isn't allowed.
  • Added check for "unsafe overlaps" for a runtime-checkable protocol when used in an issubclass or isinstance check.

Behavior Changes:

  • Changed CLI to sort diagnostics by location within a file.
  • Removed support for Union[*Ts] and Union[*tuple[...]]. This functionality was included in an early draft of PEP 646 but was dropped in the final spec. The functionality can still be used in pyright if useExperimentalFeatures is set to true, but it will likely be removed entirely in the future.

v1.1.344: Published 1.1.344

Compare Source

Bug Fixes:

  • Fixed bug that caused "go to definition" and semantic rename to not work for forward-declared symbols referenced in a "type" type alias definition.
  • Fixed bug in parser that resulted in an incorrect syntax error when certain expression forms were used with the type statement to define a type alias.
  • Fixed a bug that resulted in a false negative when attempting to access valid attributes from a type alias created via a call to the TypeAliasType constructor.
  • Fixed a bug that led to an incorrect type evaluation when explicitly specializing a generic class or type alias with a ParamSpec.
  • Fixed a bug that led to a false positive "not awaitable" error if the __await__ method return type was Unknown.
  • Fixed a bug that results in a false negative when the TypeAliasType constructor is called with an expression that refers to a traditional TypeVar.
  • Fixed a bug that leads to a false negative when validating type compatibility between two callables and the source has a position-only parameter corresponding to a non-position-only parameter in the dest.
  • Fixed bug in code flow analysis that resulted in an incorrect type evaluation when a "NoReturn" call is made within a code block protected by an exception-suppressing context manager.

Behavior Changes:

  • Added LSP exemption for __post_init__ method.
  • Improved overload overlap logic to detect partial overlaps when parameter types include unions that intersect.

Enhancements:

  • Improved logic that determines whether the expression used for a type statement or a call to TypeAliasType is a valid type expression.
  • Added additional checks for invalid NewType calls.
  • Improved detection of invalid type alias expressions for implicit (traditional) type aliases.
  • Improved error reporting for with statement when __enter__ or __aenter__ is present but cannot be bound.

v1.1.343: Published 1.1.343

Compare Source

Bug Fixes:

  • Fixed bug that resulted in crash when using language server APIs in certain circumstances.
  • Fixed bug that resulted in incorrect type evaluation of a variable within a loop under certain conditions.
  • Fixed a bug in the function type assignment logic that leads to a false positive under certain circumstances involving a ParamSpec in an overload with a callback that includes a positional-only parameter separator.
  • Fixed a bug that leads to a false negative when Self is used within a class definition statement. PEP 637 explicitly rejects this usage of Self.
  • Fixed a bug that leads to a false negative when Self is used within a metaclass. PEP 637 explicitly rejects this usage of Self.

Enhancements:

  • Eliminated some unnecessary work when determining the effective type of a symbol that doesn't have a declared type. When evaluated in the context of a particular usage, it's unnecessary to evaluate any assignments within the same execution scope.
  • Add error checking for illegal use of unary, binary, or ternary operators within a type annotation.
  • Added detection of invalid keyword arguments in TypedDict class definition when using the normal class syntax.
  • Added detection of a call to TypedDict alternative syntax form that assigns the resulting class to a variable whose name doesn't match the name specified in the TypedDict call.
  • Added check for the use of a TypedDict class in an isinstance or issubclass call. These generate a runtime exception.

v1.1.342: Published 1.1.342

Compare Source

Bug Fixes:

  • Fixed @deprecated functionality that was broken by a recent change to the typeshed stubs (which replaced a function with a class).
  • Fixed bug that results in a false positive error under certain circumstances when calling an inner function that uses a ParamSpec defined scoped to an outer function.
  • Fixed a bug in the --verifytypes CLI feature that resulted in a false negative when docstrings are missing from a class or function that is defined in a private module but re-exported from a public module.
  • Fixed a bug that led to a combinatoric explosion and an infinite loop in certain edge cases involving a class with an untyped constructor and methods that return recursive types.
  • Fixed a bug that led to false negative errors when doing protocol matching with a method that uses Self in its signature.
  • Increased internal limit of the number of overload signatures that can be captured by a ParamSpec from 64 to 1024.
  • Fixed a bug that leads to infinite recursion (stack overflow) under certain circumstances.

Enhancements:

  • Added narrowing support for literal patterns in a match statement that are used to discriminate between tagged unions of objects that can be discriminated based on a field with a literal type.

v1.1.341: Published 1.1.341

Compare Source

Normally, new pyright releases are published each Tuesday. This is an out-of-cycle release that addresses several regressions introduced in 1.1.340. These were all related to a massive change (one that affected a majority of the source files in pyright) that changed the way that file paths were tracked internally. Pyright now uses URIs rather than simple paths — a change that's needed to support a number of language server features.

Bug Fixes:

  • Fixed regression introduced in 1.1.340 that caused a crash in the --verifytypes functionality.
  • Fixed regression introduced in 1.1.340 that resulted in an incorrect URI returned as part of a language server "rename" request.
  • Fixed regression introduced in 1.1.340 that resulted in an unintended schema change for the outputjson output.
  • Fixed regression introduced in 1.1.340 that resulted in a crash when using file watchers (--watch option).
  • Fixed regression introduced in 1.1.340 that resulted in incorrect import resolution for certain namespace packages.
  • Fixed bug that resulted in a false positive error when one ParamSpec was captured by another ParamSpec.
  • Fixed bug related to function type compatibility when the dest type contains an unpacked tuple followed by one or more positional-only parameters as in Callable[[*Ts, int], None].

Enhancements:

  • Improved signature help provider so it handles overloaded __init__ and __new__ methods when calling a constructor.
  • Updated typeshed stubs to the latest version.

v1.1.340: Published 1.1.340

Compare Source

Bug Fixes:

  • Fixed English text for position-only error. It contained an extraneous \" at the end.
  • Fixed a bug that resulted in a crash under certain circumstances when defining a type alias using a type statement when no type parameters are defined.
  • Fixed bug in narrowing logic for sequence pattern magic where special cases of str, bytes, and bytearray were not handled correctly.
  • Fixed bug that led to a false positive when a zero-argument form of super is called within an inner function or lambda.
  • Fixed a bug that led to a false positive error in certain cases involving a union of two callables.
  • Removed implicit __qualname__ attribute from the module namespace. It doesn't exist at runtime, so this was leading to a false negative.
  • Fixed bug that led to a false positive when a tuple of indeterminate length was used in a callback function.
  • Fixed a bug that led to an improper "unbound" type evaluation under certain circumstances in a finally clause.
  • Fixed bug that results in an extraneous } character in stub output.
  • Fixed bug that led to incorrect return type inference for a generator that always raises an exception rather than returning.
  • Fixed package manifest so default values of configurations are properly reflected.

Behavior Changes:

  • (From pylance) All paths are now internally tracked as URIs. This provides better support for files that are not stored within a file system. This should be transparent to most pyright users.
  • Previously, return type inference was disabled for all functions when analyzeUnannotatedFunctions was set to false regardless of whether the function had input type annotations. Return type inference is now enabled if the function is partially annotated.

Enhancements:

  • Improved error message for set invariance type violations.
  • Added support for the @warning.deprecated (PEP 702) functionality when an overloaded function implementation is marked deprecated and then used outside of a call expression.
  • Enhanced type narrowing logic for sequence pattern matching to support narrowing of tuple subject types based on sequence subpatterns.
  • Extended support for "partially unbound" variable detection to cases that involve comprehension and class scopes.
  • Eliminated the limitation that unpack operators, await operators, assignment expressions (walrus operators), f-strings, chained strings, and strings with escape characters cannot be used within Annotated expressions when using an alias of Annotated.

v1.1.339: Published 1.1.339

Compare Source

Bug Fixes:

  • Fixed a bug that resulted in a false positive error under certain circumstances involving inferred variance, decorators and generic type aliases.
  • Fixed a bug that resulted in a false positive when Self was used in a value expression outside of a class body.
  • Fixed bug that resulted in a false positive error when overriding a TypedDict field when the overridden type was Any or vice versa.
  • Fixed bug that resulted in a false negative when overriding a TypedDict field with an incompatible Required or NotRequired attribute.
  • Fixed recent regression that resulted in a false negative when type or type[Any] was used as a type annotation for a field in a dataclass.
  • Fixed a bug that results in a false positive when anext is passed a value of type AsyncIterator.
  • Fixed recent regression that results in false positive error where type or type[Any] is not considered type compatible with Callable.
  • Fixed bug that affected the case where a TypedDict class derived from two incompatible classes using multiple inheritance. The error was reported in the wrong location.
  • Fixed bug that results in incorrect type evaluation when a raise statement is used within a context manager that swallows exceptions.
  • Fixed bug that led to incorrect type evaluation with unary operator when used with a type alias defined with forward references.
  • Fixed bug that resulted in a crash within the function return type checking logic.
  • Fixed bug that resulted in incorrect type evaluation when del statement is applied to a class member implemented with a descriptor.
  • Fixed regression that resulted in a false negative for the reportUnknownMemberType check when the expression is a call argument and the member is a function with a partially-unknown signature.
  • Fixed a bug that resulted in incorrect type evaluation in certain cases involving generic protocols and bound TypeVars.
  • Fixed a bug in the code flow engine that resulted in a false negative for a variable whose type is narrowed within an inner loop.
  • Fixed bug that led to improper type narrowing for class patterns when Callable is used.
  • Fixed bug that resulted in incorrect narrowed type evaluation in certain circumstances involving certain code flow graph structures.

Enhancements:

  • Added support in dataclass_transform for custom field specifiers that have default arguments for their init or kw_only parameters.
  • Implemented check for inconsistent use of @staticmethod and @classmethod in overloads.
  • Added support for accessing members of a TypeAliasType object.
  • Added an error check for a PEP 695 type statement within a function body. Type alias definitions are not allowed within this scope.
  • Added support for *args: *Ts parameter that captures a callable with an indeterminate number of positional parameters because some of them have default arguments.
  • (Contribution from @​jbarrachinab) Improved a few error messages in the Spanish localization.
  • Enhanced support for TypeVarTuple capture of a callable to support literal arguments.
  • Added a few optimizations that help improve perf somewhat when large unions are involved.
  • Added support for doc strings when using the PEP 695 type statement.

Behavior Changes:

  • Added a new typeCheckingMode called "standard". It's a subset of "strict" but a superset of "basic". It is the new default mode, and it should cover all of the required checks for conformance with the Python typing standard.
  • Changed behavior of check for unimplemented methods in a class that explicitly derives from a protocol. If the class also explicitly derives from abc.ABC, it is exempted from this check. This is useful for mixin classes.
  • Changed behavior of reportUnknownMemberType (and other checks in the reportUnknown... family) to not report a partially-unknown type if it refers to an unspecialized class.
  • Moved checks for Required/NotRequired and ReadOnly overrides from reportGeneralTypeIssue to reportIncompatibleVariableOverride for consistency. Added checks for Required/NotRequired and Readonly incompatibilities in the multiple inheritance case.
  • Changed behavior of two-argument form of super when it is used outside of an attribute access expression. It now employs a heuristic whereby it evaluates to the next base class of the bound type.
  • Changed the type printer logic to avoid emitting truncated Literal string and bytes values when it is asked to enforce Python syntax. This mode is used for inlay hints and the stub generator (for inferred return type comments).

v1.1.338: Published 1.1.338

Compare Source

Bug Fixes:

  • Fixed a bug that results in a false positive error in the reportUnknownMemberType check when abc.Callable (without any type arguments) is used in the second argument to an isinstance call.
  • Fixed bug in literal pattern matching that resulted in incorrect narrowing when the subject was typed with a constrained TypeVar.
  • Fixed bug that led to incorrect conversion from a class constructor to a function when it involves a __new__ method that returns Self.
  • Fixed bug that resulted in crash under certain obscure circumstances where a class with multiple type parameters is explicitly specialized with only a subset of required type arguments.
  • Eliminated some differences between the treatment of type and Type. These should be treated the same under all circumstances.
  • Fixed recent regression that resulted in a false positive when accessing a class property from a class instance.
  • Fixed a bug that can result in spurious false positive errors when using deeply-nested or recursive type definitions such as _NestedSequence in numpy.
  • Fixed bug that led to a false negative when Never is used as an explicit type argument for a generic class or type alias if the corresponding type parameter is a constrained TypeVar.
  • Fixed bug that produces a false negative when attempting to assign a method to a Callable type where the first parameter of the method is typed as Self, but the callback requires the class itself.
  • (from Pylance) Fixed bug that led to false positive errors related to import resolution when a partial stub is used and its directory structure doesn't match that of the library.

Enhancements:

  • Improved error handling for failures when explicitly specializing a generic type alias. Improved diagnostic message for assert_type failures when printed types look the same when not using the full name of the type.
  • Added support for bidirectional type inference for chained assignment expressions.
  • Updated typeshed stubs to the latest version.
  • Added deprecation message for class properties, which were deprecated in Python 3.11 and are going away in Python 3.13.
  • Added support for parameter type inference for lambdas whose parameters include default arguments. This is analogous to the logic used for unannotated function parameters with default arguments.

Behavior Changes:

  • Changed the behavior for empty dict or list expressions. Previously, a variable initialized with {} or [] was not flagged as "partially unknown" by the reportUnknownArgument check when used as an argument to a call. This resulted in a small type hole.
  • Changed type evaluation logic for member access expressions for type[Any] where the target attribute is not explicitly declared in the type or object class. Previously, pyright emitted an error in this case.

v1.1.337: Published 1.1.337

Compare Source

Bug Fixes:

  • Fixed a bug that resulted in a false positive when applying a descriptor whose __get__ method whose owner parameter is annotated with type[T].
  • Fixed bug that affected the isinstance type narrowing logic when the pre-narrowed type is a type alias that refers to a union that includes a recursive type alias.
  • Fixed bug in completion provider that resulted in incorrect keyword parameter suggestions for positional-only parameters.
  • Fixed bug that led to a spurious "unknown argument type" when passing an unpacked tuple in a call expression.
  • Fixed regression that results in a false positive when using a value of type type[Protocol] as the second argument to isinstance or issubclass if the protocol isn't @runtime_checkable.
  • Fixed regression that resulted in false positive errors when a magic method (e.g. __lt__ or __add__) are implemented with a callable protocol object.
  • Fixed a bug that resulted in a false positive error when using a walrus operator in a call expression that targets an overloaded function.
  • Fixed bug that led to a hang (infinite loop) in the language server when opening a document whose URI wasn't a "file". This occurred in some language servers that used an "untitled" (or similar) URI type for new documents.
  • Modified recent bug fix in isinstance and issubclass type narrowing logic so it better handles type variables with bounds that are unions.
  • Fixed a bug that resulted in a false positive error when a higher-order generic function is passed another generic function as an argument along with another argument that dictates the type of the first argument's type variable(s). This shouldn't depend on the order in which the arguments are passed.
  • Fixed a bug that resulted in a false positive error when a higher-order generic function is passed another generic function as an argument along with another argument that dictates the type of the first argument's type variable(s). This shouldn't depend on the order in which the arguments are passed.
  • Fixed a recent regression that resulted in a false positive error when a parent class defines a property with a getter and a child class extends the property with a setter.
  • Fixed bug that led to an incorrect type evaluation when a list comprehension expression is used with bidirectional type inference and the expected type includes a type variable.
  • Fixed bug that led to a false positive error when a __getitem__ returns Self.
  • Fixed a bug that led to a false positive when determining the type compatibility of two TypedDict definitions whose keys were typed with unions that included two other (compatible) TypedDict definitions.
  • Fixed a bug that led to incorrect type evaluation when two lists with different types were concatenated using a + operator in a bidirectional inference context.
  • Fixed a bug that results in incorrect type evaluation of an index expression when the LHS is unbound. It should produce Unknown rather than Never.
  • Fixed bug that resulted in a false positive under certain circumstances where a recursive type alias was used and hit an internal recursion limit.

Enhancements:

  • Improved lambda inference logic to handle the case where the expected type is a callable that accepts a generic callable as a parameter.
  • Added error reporting for illegal use of TypedDict or Protocol within a TypeVar bound or within a type annotation.
  • Enhanced reportInvalidTypeVarUsage diagnostic message to include a recommended fix.
  • Added check for the use of a bare Literal (with no type arguments) in places where it's not allowed.

Behavior Change:

  • Adjusted heuristic for reportInvalidTypeVarUse so it doesn't emit a warning when an unbound TypeVar is used within a subscript.

v1.1.336: Published 1.1.336

Compare Source

Bug Fixes:

  • Fixed bug that results in an incorrect type evaluation when functools.partial is used with a constructor where type[Self] is passed as the first argument.
  • Fixed bug that resulted in a crash during type analysis.
  • Fixed bug that results in false positive when indexing an enum class.
  • Fixed a bug that led to a false positive error when calling the same generic function multiple times in a call expression. This bug specifically affected the case where the generic function used PEP 695 syntax.
  • Fixed a bug that led to a false negative when a subclass overrides a parent class with an overloaded method in an incompatible manner.
  • Fixed bug in the import resolver that allowed typeshed stubs and stub files within installed third-party libraries to take precedence over local modules.
  • Fixed a bug that leads an incorrect type evaluation when binding a magic method (like __add__) to self when the magic method returns Self.
  • Fixed a bug that resulted in an incorrect type evaluation when accessing a property that returns Self or type[Self].
  • Fixed bug that resulted in incorrect type evaluation of a symbol imported twice by two redundant wildcard imports.
  • Fixed a bug that leads to a false positive reportPrivateUsage diagnostic when importing a public symbol from a "py.typed" library if that symbol is imported from a private symbol (and re-exported publicly) within the library.
  • Fixed a bug that led to incorrect type evaluation when an inferred method return type includes a union where the subtypes are conditioned on constraints of a constrained TypeVar that parameterizes the class. In this case, one or more of these subtypes should be eliminated when a specialized class is bound to the method.
  • Add support non english works in docstring arguments.
  • Fix bug in the contravariant return type check where a contravariant used in a union was not reported.

Behavior Changes:

  • Changed behavior when converting a class to a callable. If the class has no __init__ or __new__ method in its class hierarchy (other than those provided by object), pyright previously converted the constructor to a signature of (*args: Any, **kwargs: Any). It now converts it to a signature of () (i.e. no params) unless it's a type[T] or a protocol class.
  • Modified the isinstance type narrowing logic to retain a TypeVar when narrowing in the positive case and the value is not a constrained TypeVar.

Enhancements:

  • Added "metacls" as an allowed name for the "cls" parameter in a metaclass __new__ method.
  • Improved pyright's enforcement of keyword arguments passed within a class statement when the class has no custom metaclass or __init_subclass__ in its hierarchy. In this case, the object.__init_subclass__ method applies, and it accepts no additional keyword arguments. Also improved the error reporting for __init_subclass__ in general.
  • Improved handling of + operator when both operands are tuples. It now produces a more accurate type when one (but not both) of the two tuples is of indeterminate length.
  • Updated typeshed stubs to the latest version.
  • Added code to CLI to verify file specs passed on the command line. If they don't exist, emit an error and a non-zero exit code.
  • Improved check for second argument to isinstance and issubclass so non-runtime-checkable protocol classes are rejected.
  • Added special-case handling x in y narrowing logic for the case where x is a dict or Mapping and y is an iterable of TypedDicts.
  • Added check for the use of contravariant TypeVars in an inferred return type.

v1.1.335: Published 1.1.335

Compare Source

Bug Fixes:

  • Fixed a bug that resulted in a false positive when validating type consistency between a metaclass instance and type[T].
  • Fixed bug that led to an inconsistency between the use of type and Type when applying isinstance type narrowing in some cases.
  • Fixed recent regression in the CLI that caused the --files command-line parameters to be overridden by the "include" setting in the config file.
  • Fixed bug that led to a false positive when assigning a lambda with *args to a callable type that doesn't contain *args.
  • Fixed a few places where union order resulted in different type evaluation behaviors.
  • Fixed a bug that led to a false positive error when specializing a type alias consisting of a callable parameterized by a TypeVarTuple.
  • Fixed bug that causes a false positive MRO error when creating a subclass of a generic TypedDict and another TypedDict.
  • Fixed a bug that results in incorrect type evaluation of a call expression when the callee is a function parameterized by a TypeVarTuple that has been specialized with a concatenation form.
  • Fixed several bugs in the signature help provider when handling **kwargs parameters typed with an unpacked TypeDict (PEP 692).
  • Added missing check described in PEP 692 where fields within an unpacked TypedDict used for **kwargs cannot overlap other keyword parameters in the same signature.
  • Fixed a false positive reportIncompatibleMethodOverride error under certain circumstances where an overloaded method overrides another overloaded method.
  • Fixed a bug that resulted in incorrect type evaluation when using a TypeVarTuple within a nested Callable type (i.e. a Callable that takes a Callable as a parameter).
  • Fixed bug that resulted in false positive reportIncompatibleMethodOverload error under certain circumstances.
  • Fixed a bug that causes a false positive reportUnnecessaryContains error when self is used on the LHS of the in operator within an enum class.
  • Fixed bug that led to a false negative when assigning type Class to Self@Class.
  • (Contribution by @​JelleZijlstra) Fix missing space after "not" unary operator for expressions printed in output of reveal_type.
  • Fixed bug in completion provider that resulted in an attempt to tokenize and parse a binary (native) library file. This led to a crash in some cases.
  • Fixed a bug that results in a false positive error when a __new__ method returns Self for a generic class and the type variable is invariant.
  • Fixed a bug that led to incorrect type narrowing for the x is None in the negative (else) case when x is a bound TypeVar (or Self).

Enhancements:

  • Improved error message for descriptor accesses where binding or type validation fails for the __get__, __set__ or __delete__ methods.
  • Added missing error check for zero-argument form of super() when used within a static method.
  • Improved error message for member accesses.
  • Improved diagnostic message for method overrides based on keyword/position-only parameter mismatch.
  • Enhanced the handling of zero-argument form of super() to support the case where the containing method's self or cls parameter is annotated using a protocol. This can be used to handle mixin methods that call super().
  • Added support for boolean values in diagnosticSeverityOverrides language server setting.

Other Changes:

  • Updated heuristics for constructor evaluation to accommodate a wider range of types returned by the __new__ method. Previously, if the __new__ return type was anything other than a class instance, the heuristics assumed it wasn't intended and assumed that __new__ returned an instance of its class, as is usually the case.
  • Restored previous behavior (prior to 1.1.334) where an instance of a class that derives from Any will not be considered type compatible with None.
  • Significant rewrite of code that handles member accesses on class objects and class instances. This should improve internal consistency and fix many edge-case bugs. Due to the extent of this change, some regressions may result.

v1.1.334: Published 1.1.334

Compare Source

Bug Fix: Fixed a bug that caused locale override to fail to take effect if passed via the LSP initialize message.

Bug Fix: Fixed issue that led to false positive error when calling a NoReturn function within a case block or within an if/elif chain.

Enhancement (contribution by pakrym-stripe): Support unpacked TypedDict in parameter hover.

Performance: Fixed a performance regression that affected symbol type inference in the presence of circular dependencies.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Improved support for runtime TypeVar, TypeVarTuple and ParamSpec objects, including when they are instantiated from typing_extensions classes.

Enhancement: Improved inference logic for lambdas so it handles a wider variety of cases including lambas with *args parameters and cases where the expected type is a union of multiple subtypes that might be matches.

Enhancement: Improved TypedDict update method error message when no overloads match.

Bug Fix: Fixed a bug that led to a false positive when using an unpacked iterable as an argument in a call expression after a keyword argument.

Enhancement: Added support for python.analysis.include, python.analysis.exclude and python.analysis.ignore settings. These have been implemented in pylance for a while now, but they were never implemented previously in pyright. Also fixed a bug in the original implementation that caused the config file not to override the language server settings for python.analysis.exclude and python.analysis.ignore as it should.

Bug Fix: Fixed bug that led to false negative when evaluating a call to a function with a recursive ParamSpec.

Bug Fix: Fixed a bug in the type guard logic for simple truthy/falsy checks. If the type is an instance of object or a TypeVar with no bound (which is treated like an object), the logic should not assume that it will always evaluate to truthy.

v1.1.333: Published 1.1.333

Compare Source

Bug Fix: Fixed a bug that resulted in a false negative when assigning one TypedDict to another TypedDict. Field types should be treated as invariant rather than covariant because they are mutable (unless marked readonly).

Enhancement: Improved the synthesized update method for TypedDict classes so it supports keyword arguments and iterables of tuples.

Bug Fix: Improved error message for protocol mismatch when a method in the source cannot be bound.

Performance: Added performance improvement that speeds up type checking for TypedDict classes that have a large number of entries.

Bug Fix: Fixed a bug that led to a false positive when doing protocol matching for a protocol that uses deeply nested recursion.

Bug Fix: Fixed a bug that resulted in incorrect narrowing on assignment when the assigned type is a tuple that includes one or more Any type arguments and the declared type is a tuple without an Any.

Bug Fix: Fixed a bug that led to a false positive error when doing protocol matching for a protocol and implementation that use a combination of class-scoped and function-scoped TypeVars.

Bug Fix: Fixed several bugs in ReadOnly TypedDict functionality based on the latest draft of the PEP 705.

Enhancement: Extended the len(x) == L type guard logic to support arbitrary expressions L that evaluate to a literal int type.

Behavior Change: Removed support for readonly keyword parameter for TypedDict to reflect latest changes in PEP 705.

Bug Fix: Fixed bug in protocol matching when source is a namedtuple or a frozen dataclass. Algorithm wasn't taking into account that attributes in these classes are immutable.

v1.1.332: Published 1.1.332

Compare Source

Bug Fix: Fixed crash that occurs when encountering a malformed system version check of the form sys.version_info[0] < 3.8.

Enhancement: Improved error message for yield statements when the yield type is a TypedDict or other type that requires bidirectional type inference.

Bug Fix: Fixed regression in type(x) is y type narrowing logic when y is of type type[Self].

Bug Fix: Fixed a bug in protocol matching logic that resulted in a false positive error when a class implementation used a callback protocol rather than a def statement to define an instance variable defined in a protocol.

Bug Fix: Fixed a bug that resulted in an unresolved Unknown type within a tuple constructed within a loop.

Bug Fix: Fixed several bugs in protocol matching that led to false positives when matching a protocol against a module.

Behavior Change: Changed type evaluation behavior for accesses to attributes on a class that derives from Any. Previously, these were evaluated as Unknown, but they are now evaluated as Any.

Bug Fix: Fixed a bug in the reportIncompatibleMethodOverride check that leads to a false negative if the base class uses a Self type and the override uses an incompatible specialized type.

Enhancement: Added logic to detect illegal use of the symbol Any.

Enhancement: Added logic to perform basic reformatting (especially dedenting) of deprecation messages used with @deprecated.

Bug Fix: Fixed a bug in the isinstance type guard logic when the specified filter class (the second argument) is a metaclass (a subclass of type).

Bug Fix: Fixed a bug in the issubclass type narrowing logic when the first argument is a metaclass (a subclass of type).

Enhancement: Updated typeshed stubs to the latest version.

Behavior Change: Changed override-related checks (reportIncompatibleMethodOverride, reportIncompatibleVariableOverride and reportImplicitOverride) so they apply to stub files. Previously, these were skipped for stubs.

Bug Fix: Fixed a bug that caused types captured by ParamSpecs to sometimes be printed with Unknown parameter types.

Bug Fix: Fixed a bug in ParamSpec type matching that resulted in an incorrect type evaluation under certain circumstances.

Bug Fix: Fixed a regression in overload matching that resulted in false positive errors in hydra-zen. This change involves removing a heuristic from overload matching that attempted to eliminate a false positive error for x: list[str] = "a,b".split(",").

Bug Fix: Fixed a bug that results in confusing error messages when converting a constructor (an __init__ method) to a function type. The resulting function should not be named __init__ but should be anonymous.

Bug Fix: Fixed a bug that led to a false positive error when a type alias created using PEP 695 syntax is used as a type argument for a generic type when used in the LHS of a call expression.

Bug Fix: Fixed a bug in the isinstance type narrowing logic when using a generic class whose type parameters include defaults (PEP 696).

Bug Fix: Fixed a false positive error "TypeVar bound cannot be generic" if the bound type is a generic class whose type parameters have default types (using PEP 696).

Bug Fix: Fixed bug in "type printer", the code that converts a type to text for error messages. It wasn't properly handling type(t) where t is defined using a type alias.

Enhancement: Improved the error message for metaclass conflicts so the conflicting metaclasses are specified.

Bug Fix: Fixed a bug in the type narrowing logic for sequence patterns, specifically when the subject is Any or Unknown and the sequence pattern is empty ([]).

Bug Fix: Fixed a bug with path normalization (in particular, drive letter) for symbolic links that resulted in false positive errors.

Bug Fix: Fixed a bug that led to a false positive error when attempting to instantiate a value of type type[Self] when Self refers to an abstract class.

Bug Fix: Fixed a bug that led to a false positive error when passing type(None) or NoneType as the second argument to issubclass.

Bug Fix: Fixed a bug in the issubclass type narrowing logic for type(None) and NoneType filters.

Bug Fix: Fixed a bug that led to a stack overflow crash under certain circumstances when evaluating a function call with a ParamSpec.

Bug Fix: Fixed bug that prevented ReadOnly experimental feature from being used in a file where a # pyright: enableExperimentalFeatures=True comment was used.

v1.1.331: Published 1.1.331

Compare Source

Bug Fix: Fixed a bug that led to a false positive error and incorrect type evaluation under certain circumstances when multiple symbols depend on each other in a loop.

Bug Fix: Fixed a recent regression that led to a false positive error when a class uses a custom metaclass that supplies a __setattr__ method.

Enhancement: Improved type narrowing in the negative case for isinstance when the filter type (the second argument) is type[T] (where T is a type variable) and the first argument is of type T. In this case, we can eliminate (filter) T in the negative case.

Bug Fix: Fixed a bug that led to a false positive error when using a zero-argument super() call within a class declaration within a method body.

Enhancement: Added support for @​deprecated when applied to property accessors and descriptor methods.

Bug Fix: Fixed a bug that led to a false positive error when doing protocol matching with a protocol class that has a method with method-scoped type variables.

Enhancement: Added missing check for the use of a subscripted Callable within an isinstance call.

Bug Fix: Fixed bug that led to incorrect type narrowing for isinstance when using Callable and the pre-narrowed type is object.

Bug Fix: Fixed a bug that led to incorrect type evaluation in a nested set of call expressions and a lambda.

Bug Fix: Fixed a bug that led to a confusing error message when assigning a value with an incompatible type to a class variable that has no explicit type declaration.

Bug Fix: Fixed bug in x is <Literal> and x == <Literal> type guard logic. It was not properly handling the case where x is Any or Unknown.

Bug Fix: Fixed a bug that led to incorrect type narrowing in the type(x) is T and type(x) == T type guards when T is a dynamic type rather than a specific class.

Enhancement: Improved completion provider logic for __getitem__ methods with literal types. The old logic didn't properly handle generics or overloads.

Enhancement: Don't show stubPath xxx is not a valid directory warning in logs when using config default.

v1.1.330: Published 1.1.330

Compare Source

Bug Fix: Fixed a bug in the diagnostic filtering logic that caused the grayed-out "unused symbol" treatment to be suppressed when using a # pyright: ignore comment. This comment is intended to apply only to real diagnostics (errors, warnings, infos), not hints with tags.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when accessing an attribute on a class whose metaclass defines a __getattr__ method and the target attribute is a descriptor object.

Bug Fix: Fixed a crash that can occur if a type annotation includes too many type arguments for a class.

Bug Fix: Fixed a regression that resulted in a false positive error when using float or complex literals or constructor calls and then accessing a member of the resulting object that is valid on that class but not on int.

Bug Fix: Fixed a recent regression in the overload matching behavior that broke two tests in the pandas-stubs test suite.

Bug Fix: Fixed a bug that resulted in a false positive in certain circumstances where a lambda included simple math operations with integer literals. The fix requires disabling literal math within lambdas, since they are often used as callbacks that are called repeatedly in a loop.

Bug Fix: Reverted a portion of the recent changes designed to differentiate between a float that is really a float or a float that can also be an int. This resulted in false positives when inferring types using float literals.

Bug Fix: Fixed a false positive due to incorrect type narrowing logic when a del statement targets a specific element within a list (e.g. del my_list[1]).

Bug Fix: Fixed a crash due to an invalid assert that occurs when a class or function that uses PEP 695 syntax is unreachable.

Bug Fix: Fixed a bug that led to incorrect type evaluation and false positives when constructing a specialized generic TypedDict.

Enhancement: Updated typeshed stubs to the latest version.

Enhancement: Improved the check for whether an object is "awaitable". Rather than hard-coding checks for __await__ and __init__ methods, use the typing.Awaitable protocol.

Bug Fix: Fixed a false positive reportInvalidStringEscapeSequence error if a string literal is over 32K in length and the 32768'th character is a backslash.

Enhancement: Added support for PEP 692 (unpacked TypedDict for **kwargs) when used with a ParamSpec.

Bug Fix: Fixed a bug that led to the loss of type narrowing for a captured variable used within an inner scope if used in a comprehension expression.

Behavior Change: Changed the default Python version (the version that is assumed by pyright if it has no other context) from 3.11 to 3.12 now that 3.12 is final.

Enhancement: Improved diagnostic for the situation where overload matching fails to find any applicable overloads.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when an async function with an inferred return type is decorated with a class or function that uses a ParamSpec (such as functools.wraps).

Bug Fix: Fixed a bug that led to a false positive error when using a single-quote form of a format string that uses a format specifier expression. This is also a bug in the Python 3.12 interpreter that is being fixed.

v1.1.329: Published 1.1.329

Compare Source

Behavior Change: Added new configuration switch disableBytesTypePromotions that is off by default except in strict mode, when it's on by default. When enabled, it eliminates the old (poorly-documented) behavior whereby bytes when used in a type annotation automatically implies the union bytes | bytearray | memoryview. For details, refer to PEP 688. The configuration switch allows code bases to retain the old behavior, but it's likely that the default value of this option will change to true in the future.

Behavior Change: Improved handling of types float and complex, which are special-cased in PEP 484 as "promotion types". The new logic now properly models the runtime behavior for isinstance and class pattern matching when used with these promotion types.

Behavior Change: Added check for the use of an ellipsis for a default argument value for a function that is not in a stub, not overloaded, and without a placeholder implementation.

Bug Fix: Fixed false positive error that occurs when a member of a frozen dataclass is overridden in a subclass. In this case, the type should not be considered invariant because the field isn't mutable.

Bug Fix (from pylance): Fixed recent regression that caused import resolution issues when using UNC paths and symlinks.

Bug Fix: Fixed several issues with logic that performs protocol matching against a module, including a false positive error when matching against a generic protocol.

Bug Fix: Fixed bug in type compatibility checks for LiteralString. It should not be considered compatible with str or a specific literal str in an invariant context.

Bug Fix: Fixed a false positive error with the reportUnnecessaryComparison check when a recursive type alias is used.

Bug Fix: Fixed a bug in the handling of __match_args__ in class pattern matching. Pyright was using the subject's class rather than the pattern's class to look up __match_args__.

Bug Fix: Fixed a bug in the handling of class pattern matching for subclasses of int, str or other stdlib classes that implicitly supply __match_args__ and return self for matches.

Enhancement: Added a check for class pattern matches where the number of positional patterns exceeds the number of positional fields supported by the class.

Enhancement: Improved error message for type compatibility for list and dict types, which enforce invariance. The new error message now suggest the use of Sequence and Mapping, respectively.

v1.1.328: Published 1.1.328

Compare Source

Behavior Change: Added code to enforce invariance of class-scoped variables in overrides when the reportIncompatibleVariableOverride rule is enabled.

Bug Fix: Fixed bug that results in import resolution errors when symlinks are used.

Bug Fix: Fixed a bug that caused a typing.deprecated decorator not to be marked as such.

Bug Fix: Fixed a bug that resulted in a false positive error when *args and **kwargs are passed as arguments to a function with a ParamSpec and the types of *args and **kwargs is Any.

Bug Fix: Fixed bug that caused @deprecated message not to be passed through a ParamSpec.

Bug Fix: Fixed a bug that results in incorrect type narrowing for a mapping pattern if the subject type is a superclass of Mapping, such as object.

Bug Fix: Fixed inconsistent behavior of @deprecated between overloaded and non-overloaded functions.

Bug Fix: Improved validation of generator return type. Previously, the check was performed only for yield statements, but it's possible to define a generator function that has no reachable yield statements.

Bug Fix: Fixed bug that led to a false positive error when checking for out-of-bounds tuple accesses if the indexed type is a union that includes both a bounded tuple and an unbounded tuple.

Behavior Change: Updated the synthesized pop method for TypedDict so its signature is consistent with the synthesized get method. This eliminates an Unknown in some cases.

Bug Fix: Fixed bug that led to incorrect generation of Unknown type evaluation when an overloaded function is called in a loop and one of the arguments to the call depends on the return value.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a regression that caused an Unknown to appear in a type evaluation when using nested constructor calls.

v1.1.327: Published 1.1.327

Compare Source

Bug Fix: Fixed a bug in the isinstance type narrowing logic that evaluated the incorrect type when two protocol classes are involved.

Bug Fix: Fixed a bug that led to a false positive error when enclosing ... in quotes when specifying a ParamSpec default value.

Bug Fix: Fixed bug that resulted in false positive error when using a Union[*Ts] value in a binary expression.

Bug Fix: Fixed a recent regression that caused the pythonPath received from the client to be corrupted resulting in import resolution errors.

Behavior Change: Updated class specialization logic to conform to latest draft of PEP 696 when a class type parameter has a default type and that class is bound to one of its methods.

Enhancement: Improved error message for type argument mismatch when in an invariant context.

Behavior Change: Changed behavior to allow a class variable within a protocol to be marked Final without assigning a value to it in the protocol definition.

Bug Fix: Fixed a bug that results in a spurious error under certain circumstances when evaluating the type of a parameter within a nested function whose type refers to an outer-scope type variable.

Enhancement: Added check for a conditional expression that evaluates to a coroutine, which always evaluates to True. This is likely indicative of a missing await keyword.

Enhancement: Improved the type narrowing logic for the len(x) == L type narrowing pattern for tuples. The new logic supports narrowing of tuples with an indeterminate length (a ... entry).

Behavior Change: Removed check for empty body of @overload function.

Bug Fix: Fixed a false positive error when a TypeVar with a default value (as specified in PEP 696) appears within a method after an outer-scoped TypeVar without a default value.

Bug Fix: Fixed a bug that led to a false positive error when a frozen dataclass has an explicit __eq__ method and is used in way that requires it to be Hashable.

Bug Fix: Improved error messages that include module names. Previously, there were inconsistencies in how module names were reported.

Bug Fix: Fixed false positive error when using a forward-declared reference inside of an inlined TypedDict when from __future__ import annotations is in effect.

Bug Fix: Fixed a bug that led to a false negative when using a non-TypedDict base class within a TypedDict class statement.

v1.1.326: Published 1.1.326

Compare Source

Bug Fix: Fixed a bug in the recently-introduced deprecateTypingAliases feature that resulted in false positives when Counter, OrderedDict and ChainMap were imported from collections.

Bug Fix: Fixed a bug that led to a false positive when an enum literal annotation is used within the enum class definition and from __future__ import annotations is in use.

Bug Fix: Added code to mark symbols as accessed if they're imported directly into a class scope using a from x import y statement.

Bug Fix: Fixed a bug that resulted in a false positive error when assigning an unpacked TypeVarTuple to an unpacked tuple[Any, ...] in an invariant context.

Bug Fix: Fixed bug that results in a false positive error during protocol matching when a NamedTuple is matched against a protocol using _fields or other attributes defined in the NamedTuple class.

Bug Fix: Fixed bug that led to a false positive error when determining whether the target of an awaited call is a NoReturn.

Behavior Change: Changed the default of useLibraryCodeForTypes from false to true in the LSP settings. (It was changed to true in all other places previously, but this case was missed.)

Bug Fix: Fixed a bug that led to an incorrect type evaluation in certain cases where a type argument for a function call argument type is left unspecified (and is therefore assumed to be Unknown).

Bug Fix: Fixed a bug that led to incorrect type narrowing for isinstance when the pre-narrowed type is a generic callable.

Bug Fix: Improved determinism of bidirectional type inference for dictionary, list, set and tuple expressions when the expected type is a union of types that includes more than one plausible candidate. The types in the union are now sorted so type evaluation doesn't depend on the order in which the union was defined.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed bug that led to a false negative when @typing.deprecated is used on an async function.

Bug Fix: Fixed a bug that led to the incorrect type evaluation of a constructor call when bidirectional type inference is used and the expected type is a union that includes more than one compatible instance type.

Bug Fix: Fixed a deviation from the PEP 702 spec which indicates that when @deprecated is applied to an overloaded function implementation, that deprecation is meant to apply to all overloads.

Enhancement: Improved error message for deprecated methods.

Enhancement: Improved "no matching overloads" error message in cases where an argument is unpacked.

Enhancement: Added support for custom metaclasses that inject instance variables into the classes they construct.

v1.1.325: Published 1.1.325

Compare Source

Bug Fix: Fixed a bug in the isinstance type guard logic that produced incorrect results when narrowing a generic class instance.

Bug Fix: Fixed a bug in the parser that led to a false positive syntax error when a match statement was followed by a - or ~ token.

Bug Fix: Improved logic that determines whether an object is callable. The __call__ attribute must be a class variable, not an instance variable.

Bug Fix: Improved isinstance and issubclass narrowing in the case where an intersection type is created and one of the two subclasses has a custom metaclass.

Behavior Change: Changed type evaluation behavior for a class variable that uses Self in its type definition. When accessed via a subclass (either through cls or self), the type is now assumed to be changed to Self of the child class. This makes pyright's behavior closer to mypy's in this case.

Bug Fix: Fixed regression that resulted in incorrect type evaluation and a spurious reportUnknownArgumentType error when calling the same constructor multiple times in a single call expression.

Bug Fix: Fixed a bug that caused a "py.typed" marker file to be ignored in a namespace package if the marker file is at the same directory level as the submodule being imported leading to a spurious reportMissingTypeStubs error.

Bug Fix: Fixed a bug that led to a false positive during overload matching when the arg type includes a union where one of the subtypes is a constrained TypeVar.

Enhancement: Added a new configuration option deprecateTypingAliases that enables deprecation detection and reporting for symbols imported from the typing module that are deprecated according to PEP 585 and 604. The option is currently disabled by default (even in strict mode) but can be enabled manually.

Behavior Change: Changed logic to exempt abstract overloaded methods within an ABC so an implementation is not required.

Bug Fix: Fixed check for illegal use of zero-argument super within an inner function located within a method.

Bug Fix: Fixed a bug that led to a false negative when a type annotation contains a stringified type on the LHS of an index expression.

Enhancement: Added support for @type_check_only decorator.

Enhancement: Improved error message for type incompatibility when type parameter is covariant or contravariant.

Enhancement: Updated typeshed stubs to the latest.

Bug Fix: Fixed a bug that led to incorrect type evaluation and false positive errors when a function with a ParamSpec was passed to another function with a ParamSpec.

Behavior Change: Changed interpretation of ... forms of tuples to improve consistency and match mypy's behavior. The type tuple[int, ...] is now interpreted as the union of all tuples of length zero or more that contain only int. Because this is a union, assigning a value of this type to a tuple type with a known (specified) length is now considered a type violation.

Bug Fix: Fixed several bugs in the logic for "strict type guard" positive and negative type narrowing.

Bug Fix: Fixed long-standing bug that caused various problems (including poor performance, incorrect type evaluations, and false negatives and false positives) when calling a constructor for a generic class within the class implementation.

Bug Fix: Fixed a bug that led to a false positive reportUnusedVariable error when a dynamic expression was used in a namedtuple call argument.

Bug Fix: Fixed a bug that led to a false positive reportIncompatibleMethodOverride error when a function-scoped type variable was used in a contravariant position.

Bug Fix: Fixed bug that led to the incorrect type evaluation when calling a generic function and a value of type P.args or P.kwargs is assigned to a type variable.

Bug Fix: Fixed a bug that led to a false negative error for an expression used within an f-string within a loop.

v1.1.324: Published 1.1.324

Compare Source

Bug Fix: Fixed a bug that led to a false positive error under certain circumstances when a callable using Concatenate is assigned to another callable using Concatenate.

Bug Fix: Fixed bug that can result in a false positive error when a wildcard import targets a module that doesn't contain a __all__ definition but includes dundered names in its module namespace.

Bug Fix: Fixed a false positive error when invoking a call of a variable that is annotated using a PEP 695 type alias.

Bug Fix: Fixed a bug that caused an incorrect application of a ParamSpec in certain cases where the signature bound to the ParamSpec was generic.

Enhancement: Improved validation of NamedTuple and namedtuple factory calls.

Enhancement: Improved detection of redundant pattern capture targets in case statements.

Bug Fix: Changed the type evaluation logic for the enum value member so a custom value type can be specified in the Enum subclass.

Bug Fix: Fixed a bug that led to a false positive in the reportIncompatibleMethodOverride check in certain circumstances where the method in both the base class and child class are overloaded.

Bug Fix: Fixed bug that resulted in a false positive error when an async function with no return type annotation was called recursively.

Bug Fix: Fixed a bug that led to a false positive in the reportIncompatibleMethodOverride check when overriding a method with a ParamSpec.

Bug Fix: Fixed a recent regression that resulted in a false positive during protocol matching if the protocol defines an __eq__ method but doesn't include a __hash__ definition.

Bug Fix: Fixed bug that sometimes led to false positives or false negative in call expressions that involve keyword arguments followed by an unpacked.

Bug Fix: Fixed a bug that resulted in the incorrect textual form (used in error messages) for a generic class with a ParamSpec that is parameterized with ....

Bug Fix: Fixed regression that caused a spurious error with the reportIncompatibleMethodOverride check when a method with a ParamSpec was overridden by a method with *args: Any, **kwargs: Any.

Bug Fix: Fixed a bug that led to incorrect type narrowing on assignment in certain cases.

Enhancement: Added check for classes that have mutually-incompatible base classes due to generic type argument mismatches.

Bug Fix: Fixed bug that led to a false positive reportIncompatibleVariableOverride error when overriding a synthesized __hash__ symbol.

Bug Fix: Added heuristic to constraint solver logic to better handle the case where a parameter is annotated with a union of multiple "bare" TypeVars (like S | T). In this case, it's not clear whether the corresponding argument type should constrain S or T or both. We now defer the constraint during the first pass of arg/param type validation so additional references to S or T can help establish the appropriate constraint.

Bug Fix: Fixed a bug that led to incorrect type evaluation of Union[*Ts] (where Ts is a TypeVarTuple) in certain situations

Bug Fix: Fixed bug that resulted in incorrect type evaluation when passing a generic class as a Callable parameter more than once in the same call.

Enhancement: Added logic to mirror the (rather surprising) runtime behavior when an attribute is accessed from a class object and the metaclass defines an attribute of the same name that happens to be a descriptor object. The runtime favors the metaclass attribute in this case.

Enhancement: Extended inlined TypedDict prototype to support TypedDict as well as dict so we can compare the two proposals.

Bug Fix: Changed logic for handling the __get__ method of a descriptor so pyright more accurately models the runtime behavior when the descriptor is accessed through an object (as opposed to a class). Previously, pyright was modeling this as an Any value to avoid problems with type stubs that are not accurately modeling the runtime behavior, but this caused other unintended side effects.

Bug Fix (from Pylance): Fixed bug that led to internally-corrupted type state if the language server canceled a type evaluation request at just the wrong time.

Enhancement: Added logic to handle the case where a declared return type of a function includes a constrained TypeVar and a return statement is guarded by a case statement using a class pattern that guarantees that the constraint is met on that code path.

v1.1.323: Published 1.1.323

Compare Source

Bug Fix: Fixed a condition in the code flow engine that corrupted internal state and led to a crash.

Bug Fix: Fixed bug that resulted in incorrect type evaluation for an async function that has no type annotations. It was using call-site return type inference but failing to wrap the result in a Coroutine.

Enhancement (from Pylance): Added support for ".jar" files for import targets.

Bug Fix: Fixed bug that led to false negative when assignment expression (walrus operator) is used in a yield or yield from statement without a parenthesis.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation (and a false positive error) when a binary operator overload method was annotated to return NoReturn.

Enhancement: Updated typeshed to the latest. This update includes some changes to the two-parameter form of the get method for dict and TypedDict that may result in visible type evaluation changes in some code bases.

Enhancement: Added a check for hashability for objects used as dict keys. Contribution from @​TheTripleV.

Bug Fix: Fixed a bug that resulted in a false positive reportUnnecessaryComparison error when the subject of a match statement was mutated in a loop.

Enhancement: Added special-case handling of enum fields that are callables, which are apparently not treated as enumerated types.

Enhancement: Added check to enforce a generator's "send type" in a yield from statement.

Enhancement: Added special-case logic for fields with the name __hash__ within a dataclass.

Enhancement: Added support for ... in the last type argument of Concatenate. After much discussion (see https://github.com/python/cpython/pull/30969), it has been decided to support this even though a strict reading of PEP 612 seems to exclude it.

Bug Fix: Fixed a bug that led to a false negative when assigning a dictionary literal expression to a TypeVar bound to a TypedDict.

Bug Fix: Fixed a bug that led to a false negative when a TypeVar was used inappropriately in certain cases.

Bug Fix: Fixed bug in protocol matching that led to an incorrect protocol match with a NamedTuple. Fields in a NamedTuple are implicitly read-only, so a writable protocol should not match.

Enhancement: Added type compatibility enforcement for symbols imported via a wildcard import.

Enhancement: Added support for indexing into tuples of indeterminate length as long as the index is positive and falls within a determinate portion.

Bug Fix: Fixed type narrowing bug that affected the A is B type narrowing pattern when A has the type type.

Bug Fix: Fixed false positive where an inner function within a method uses a TypeVar to annotate its parameter. The variance of the TypeVar shouldn't be checked in this case, whereas it should be for the method.

Bug Fix: Fixed a bug that led to a false positive when accessing a cached_property defined on an enum.

Bug Fix: Fixed a bug in import resolver that caused a site-packages module to be preferred over a local module if the site-packages package is "py.typed".

Bug Fix: Fixed bug that led to a false positive when a two-argument form of a super call used type as the first argument.

v1.1.322: Published 1.1.322

Compare Source

This is a hot fix release to address a regression in 1.1.321.

Bug Fix: Fixed recent regression that led to a false positive when assigning a union of types that use invariant type parameters to a protocol that uses a covariant type parameter. This fix was already incorporated into this week's preview release of pylance (v2023.8.21), so it shouldn't affect pylance users.

Bug Fix: Fixed a bug that led to a spurious "Unknown" type when an assignment to a variable with a type annotation was used within a loop.

Bug Fix: Fixed false positive error when an empty tuple was used in an except statement.

v1.1.321: Published 1.1.321

Compare Source

Behavior Change (from pylance): Import suggestions are filtered when py.typed is available based on whether the symbol is considered public or private.

Bug Fix: Fixed a bug that led to a false positive in certain cases where a ParamSpec captures an overloaded function signature.

Bug Fix: Fixed a bug that resulted in a type evaluation error when using bidirectional type inference with a non-generic protocol.

Bug Fix: Fixed a bug that resulted in an off-by-one error in an error message when reporting the index of a mismatched overload.

Bug Fix: Fixed a bug that resulted in a false positive reportIncompatibleMethodOverride diagnostic when the base method used a double underscore to indicate position-only parameters but the override used the newer / separator.

Bug Fix: Revert "Fixed a bug that led to a false negative when determining whether two base classes that are combined using multiple inheritance implement the same method in an incompatible way. The bug caused the check to be skipped if the child class also implemented the same method as the two base classes.

Bug Fix: Fixed a bug that resulted in an incorrect hover type (and inlay hint) for the inferred return type of an async function or method.

Performance: Addressed a performance regression introduced in 1.1.314 due to a switch from ts-loader to esbuild-loader in our build pipeline. This change resulted in a 7-9% performance degradation, so I'm reverting it for now.

Enhancement: Added check for improper use of a type alias defined using the type statement introduced in PEP 695.

Bug Fix: Fixed bug that led to a false positive error in certain cases when using bidirectional type inference when the expected type includes a protocol that is specialized with a literal type argument.

Bug Fix: Fixed a bug that led to incorrect type narrowing on assignment in certain cases where the declared type includes a type argument with an Any and the assigned type does not.

v1.1.320: Published 1.1.320

Compare Source

Bug Fix: Reverted new version of chalk library. The newer version is not compatible with node v12.

Bug Fix: Fixed a bug that resulted in a false positive error when attempting to assign a TypeVar T that has a bound of type to an expression type[S].

Enhancement: Added a new configuration options flag called enableExperimentalFeatures that controls whether certain experimental features are enabled. Currently there are three features under this flag: StrictTypeGuard, ReadOnly fields for typed dicts, and inlined TypedDict definitions.

Enhancement: Removed support for experimental StrictTypeGuard and replaced it with an experimental variant of TypeGuard that applies strict semantics if certain conditions are met.

Bug Fix: Fixed a bug that led to incorrect variance inference when a value annotated with a class-scoped TypeVar was assigned to an instance variable.

Behavior Change: Updated heuristics for how to handle custom metaclass __call__ methods based on feedback. Previously, if a metaclass __call__ method was present, pyright assumed that __new__ and __init__ may not be called, so it ignored them. The new heuristic assumes that if the metaclass __call__ returns a type that is consistent with the expected return type of type.__call__ that it is probably mirroring the behavior of type.__call__ and calling the class' __new__ and __init__ methods.

Behavior Change: Changed auto-variance algorithm to exempt class and instance variables that are named as protected or private.

Bug Fix: Fixed a regression that caused class decorators of generic classes to no longer be specializable.

Bug Fix: Fixed a bug that resulted in an apparent hang within the type printing logic. This was triggered by a pathological case involving a deeply recursive type.

Behavior Change: Modified type inference logic so methods that raise an exception whose type derives from NotImplementedError is not inferred to return NoReturn. Previously, only NotImplementedError was exempted, not subclasses.

Behavior Change: Removed old code that looks for a typeshed override in the standard python search paths. This works around an issue with the inject library, which installs a bogus typeshed directory into site-packages.

Bug Fix: Fixed a bug that results in unsolved type variables in a call return if the target function's return type is a callable that has type variables that are scoped to that callable.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when a generic function that returns a callable is passed itself as an argument and the resulting callable is then called and passed that same function as an argument.

Bug Fix: Fixed a bug in the command-line version of pyright where it did not enable "auto search paths", so it didn't automatically add "src" as an extra path.

Bug Fix: Fixed a bug that led to a false negative when determining whether two base classes that are combined using multiple inheritance implement the same method in an incompatible way. The bug caused the check to be skipped if the child class also implemented the same method as the two base classes.

Bug Fix: Fixed a bug that resulted in a false positive error when using an unpack operator within a call to an overloaded function.

Bug Fix: Fixed a bug that resulted in a false positive error when a captured variable within an inner scope (function or lambda) is imported from another module using an import statement that comes after the function or lambda.

Bug Fix: Fixed bug that led to incorrect type evaluation when accessing the name attribute on an enum.

v1.1.319: Published 1.1.319

Compare Source

Bug Fix: Fixed a bug that results in a crash when attempting to use a member access expression where the LHS is a TypeVarTuple.

Bug Fix: Fixed a bug that led to a false negative when analyzing code with an async context manager that swallows exceptions.

Enhancement: Improved error messages for situations where a call expression targets an overloaded function or method and there are no matches. Added some heuristics to pick the "best" overload function for the error message. Previously, pyright used the last overload, but this sometimes led to confusing errors.

Enhancement: Added support for the X is C and X is not C type guard pattern (where C is a class).

Bug Fix: Fixed an issue in type evaluation of call expressions where the callable subexpression evaluates to a union, and the callable subtypes have different signatures. Pyright was previously caching the types from the first subtype, so it didn't re-evaluate using the second subtype (which may require bidirectional type inference).

Bug Fix: Fixed bug in hover text where it was not producing the correct text output for an instantiable callable.

Enhancement: Added detection and reporting of illegal use of type[Callable] within a type annotation.

Bug Fix: Fixed a bug that resulted in a false positive error when bidirectional type inference was used with a class that defines a __new__ method within a generic class that returns an instance of the class whose type arguments do not match the type parameters.

Bug Fix: Fixed an inconsistency in reporting of unbound variables when the variable is captured by an inner scope. The new behavior correctly identifies unbound (or potentially unbound) variables in cases where the captured variable is narrowed. This happens when there are no assignments to the variable after it is captured.

Bug Fix: Fixed a bug that led to a false positive when a constrained type variable was used as a type argument in an annotation for an argument passed to a method that's bound to the same type variable.

Bug Fix: Improved robustness of handling of circular dependencies for class evaluations.

Enhancement: Enhanced support for functools.partial so it supports classes (constructors) when passed as the first argument.

Bug Fix: Fixed a bug that led to a false positive error when using bidirectional type inference for a dictionary expression when the expected type is a protocol.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that led to a hang and eventual crash (due to memory exhaustion) under certain circumstances where a function returns a generic Callable whose type parameters are not used in the input parameters for the function.

Bug Fix: Modified the heuristics used for narrowing on assignment when the assigned type contains an Any. If the target's declared type does not contain Any, the assignment shouldn't produce an Any within the resulting type.

Enhancement: Added support within the constraint solver for higher-order functions that accept a callable parameterized with a ParamSpec where the passed callable is generic.

Bug Fix: Fixed a bug that resulted in the incorrect inferred variance for a type variable used within a frozen dataclass.

Bug Fix: Fixed a theoretical bug in the code that detects unique type signatures. It wasn't correctly handling constructor methods.

Bug Fix: Added support for type narrowing of a class pattern when the specified class is type() or a subtype thereof and the subject contains a type[X] whose metaclass potentially matches the pattern.

v1.1.318: Published 1.1.318

Compare Source

Performance: Added code to handle pathological case in unannotated code that assigns values to the same variable hundreds of times with different types.

Bug Fix: Fixed a recent regression that resulted in unsolved type arguments when a "bare" generic class (like dict) is passed as an argument to a function that accepts a type[T].

Bug Fix: Fixed a bug in type narrowing for pattern matching in the negative (fall-through) case when the subject type contains an Any.

Enhancement: Added additional special-case handling for __init_subclass__ and __class_getitem__ to treat them as implicit class methods even if they are not declared using a def statement.

Bug Fix: Fixed bugs that resulted in incorrect or incomplete types when narrowing for sequence patterns in the negative case and the subject expression is a super-type of Sequence (such as object or Reversible).

Behavior Change: Modified is None type guard logic to eliminate Any or Unknown in the positive narrowing case.

Bug Fix: Fixed bug that resulted in a false positive reportOverlappingOverload error when overload contained the use of a constrained TypeVar.

Bug Fix (thanks to @​ adpauls for contribution): Add fsevents as optional dependency to public package. This should improve file watcher behavior for large projects on MacOS.

Enhancement: Improved the error message for incompatible type arguments. Many users are confused about variance (in particular invariant type parameters). This change should help eliminate some of that confusion.

Bug Fix: Fixed a bug that resulted in a false negative when assigning a T | None type to object | None in an invariant context. This same bug led to issues with the validation of TypeVar variance within a Protocol.

Bug Fix: Fixed recent regression that resulted in a false positive error when using bidirectional type inference for an assignment to a class-scoped variable where the annotated type is a descriptor.

Enhancement: Improved checks for illegal use of a variable within a type expression. Added enforcement of these same rules for the first argument to a cast call.

Behavior Change: Removed the requirement that a TypedDict be marked @final for it to be considered for type narrowing as part of a S in D type guard pattern. This requirement wasn't sound because TypedDict is a structural type (i.e. a protocol), so @final doesn't have any real meaning.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed bug that caused an error to go undetected when the LHS of a call expression is a union that includes an abstract static or class method.

Bug Fix: Fixed a bug that resulted in incorrect evaluation of a type alias defined with typing.TypeAlias and consisting of a single (naked) type variable.

Bug Fix: Fixed a bug that resulted in a false positive when an expression of type type[Self] was used as the base type for a member access expression that was then used to call an instance method on that class.

Bug Fix: Fixed a bug that led to a false negative when determining type compatibility between two unions in an invariant context.

Bug Fix: Fixed bug that resulted in the incorrect variance inference of an "auto variance" type parameter (as introduced in PEP 695).

v1.1.317: Published 1.1.317

Compare Source

Bug Fix: Fixed a regression that caused a false positive when comparing type compatibility between two Callable types that involve ParamSpecs.

Behavior Change: Changed '-' command-line feature to support multi-line input.

Enhancement: Added special-case support for enum fields that are assigned using an unpacked tuple operation.

Bug Fix: Fixed bug that resulted in false positive error when calling the same generic function with a ParamSpec multiple times as separate arguments within a call expression.

Bug Fix: Fixed another ParamSpec-related issue.

Enhancement: Extended support for TypedDict discrimination by literal field so it supports == and != with values that are unions of literal types.

Bug Fix: Fixed a bug that resulted in incorrect hover results for identifiers used as keys or values within a dictionary expression.

Bug Fix: Fixed recent regression in the synthesized TypedDict get method, which resulted in a false positive error when using strict mode.

Enhancement: Removed limitation that files specified on the command line or in "include" directives end in ".py" or ".pyi".

Bug Fix: Fixed a bug that results in incorrect type evaluation for a higher-order function involving a ParamSpec.

Behavior Change: Modified diagnostic checks for list, dictionary, and tuple literal expressions within annotation expressions so they are emitted as part of the reportGeneralTypeIssue diagnostic rule rather than unconditionally.

Bug Fix: Fixed bug that led to a confusing hover type for the return result of an async generator function.

Enhancement: Added support for deferred annotation evaluation for Annotated type arguments beyond the first one.

Bug Fix: Improved assignment mismatch errors to better handle the case where the two types have the same short name but different fully-qualified names. In this case, the types are now expanded to avoid confusion.

Bug Fix: Fixed incorrect type mismatch error messages within constraint solver logic. The source and destination types were swapped, which led to confusing messages.

Performance: Improved protocol type cache for improved type analysis performance in code bases that make heavy use of protocols.

Enhancement: Added detection of errors when a namedtuple definition includes a language keyword. Also added minimal support for the rename parameter to the namedtuple function.

Enhancement: Updated typeshed stubs to the latest version.

v1.1.316: Published 1.1.316

Compare Source

Note: This will be the last version of pyright published for the next couple of weeks. Responses to bug reports and questions may also be delayed over the next few weeks.

Bug Fix: Fixed a bug in the new - command-line feature. This addresses

Bug Fix: Fixed another instance of a false positive reportMissingTypeArgument error when a generic class is passed as the second argument to isinstance.

Enhancement: Added support for bidirectional type inference when using a dictionary expansion and a dictionary literal expression for an argument corresponding to an unpacked TypedDict **kwargs parameter.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when a generic callback protocol was invoked in a nested manner.

Bug Fix: Fixed a bug that resulted in a false positive when passing a class to the defaultdict constructor. If an unspecialized class type is used as a upper or lower constraint within the constraint solver, we now use default type arguments (typically Unknown) rather than leaving these type arguments unspecified.

Behavior Change: Modified the signature of the synthesized get method for TypedDict classes so it more closely matches the signature (and therefore the behavior) of the get method in dict.

Bug Fix: Fixed regression that caused crash within certain doubly-nested loops.

Bug Fix: Fixed a bug that results in a false positive error when attempting to assign a class to a Callable type when the class is generic and the constructor includes class-scoped type variables in its parameter annotations.

Bug Fix: Fixed a bug that led to a false negative when a generic class with called its own constructor using its own type parameters as type arguments.

v1.1.315: Published 1.1.315

Compare Source

Bug Fix: Fixed a regression that caused a false positive reportMissingTypeArgument diagnostic when using a generic type in conjunction with the | union operator in the second argument to an isinstance or issubclass call.

Bug Fix: Modified protocol matching and the constraint solver to handle an edge case where a partially-solved type variable with a solution of Any are provided by other argument types in a call.

Bug Fix: Fixed a bug that leads to a false positive error in the reportIncompatibleMethodOverride check when a child class is overriding an overloaded method in the base class and one or more of the overloads doesn't apply because the self or cls parameter is explicitly annotated in a way that's not applicable to the child class.

Bug Fix: Fixed a bug in type evaluation of the two-argument form of the super call. There were situations where the incorrect MRO class was used.

Bug Fix: Fixed bug that led to false positive errors when performing protocol matching in certain circumstances.

Bug Fix: Fixed a bug that led to a false positive when passing unpacked lists or dictionaries to a constructor for a class that doesn't provide its own constructor and falls back to the object constructor.

Bug Fix: Changed parameter type inference logic to avoid inferring the type of an unannotated parameter with a default value consisting of a lambda.

Bug Fix: Fixed a regression that caused an incorrect type evaluation of a function that returns a callable with a ParamSpec that does not appear outside of the return type annotation. A previous fix didn't correctly handle the case that involved a class parameterized with a ParamSpec.

Bug Fix: Fixed a false negative where an unpacked dictionary argument was not validated against the **kwargs parameter type.

Bug Fix: Fixed several subtle bugs in the overload matching algorithm in the case where Any or Unknown arguments are present.

Enhancement: Improved the heuristic used to determine which subtypes of a union within an "expected type" should be used for bidirectional type inference.

Bug Fix: Fixed bug that led to an incorrect type evaluation for nested call expressions where an inner call expression used a ParamSpec.

Bug Fix: Fixed false negative when a literal and non-literal are assigned to the same TypeVar in an invariant context.

Behavior Change: Changed auto-variance algorithm to ignore __new__ and __init__ methods for purposes of calculating the variance of a TypeVar. This mirrors the behavior of mypy.

Bug Fix: Fixed a bug that led to incorrect type evaluation when passing a generic class (with a constructor that includes class-scoped TypeVars) as an argument for a callable parameter. The class was being specialized prematurely (with type arguments set to Unknown) before the constraint solver was able to solve the higher-order function's type variables.

Bug Fix: Fixed a false positive error arising from the use of a binary expression for a base class in a class declaration statement.

Enhancement: Improved hover text to display the calculated variance for a PEP 695-style class-scoped type variable when the user hovers over the type parameter in the type param list.

Bug Fix: Fixed a bug that led to a false positive error under certain circumstances when a literal type argument was used in conjunction with a protocol that used a covariant type parameter and an implementation of that protocol that used an invariant type parameter.

Behavior Change: Changed type printer (the component that renders types into text) to use the lowercase type[x] instead of Type[x]. It has now been four years since PEP 585 deprecated the use of the upper-case version, so most developers should be getting comfortable with the lowercase version at this point.

Enhancement: Improved reportUnnecessaryCast so it works with types other than class instances.

Enhancement: Improved type inference for lambdas in the case where a parameter includes a default value and the expected type doesn't include that parameter.

Bug Fix: Fixed bug in code flow engine that led to incorrect type evaluation of a variable in a nested loop.

Bug Fix: Fixed bug that resulted in a false positive error when defining a new type alias using the TypeAliasType constructor that defines no new type parameters but references an outer-scoped type parameter in the type alias definition.

Enhancement: Enhanced command-line version of pyright to allow file or directory names to be passed via stdin if - option is used in the command line.

Behavior Change: Changed behavior of non-ClassVar variables within a protocol definition. Previously, an error was reported when such variables were accessed from the class (as opposed to an instance of the class). Mypy (which was the reference implementation for PEP 544) does not report an error here.

Bug Fix: Fixed a bug that caused incorrect type inference for parameters in unannotated methods within child classes who derive from a generic parent class.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that caused an incorrect false positive error for an assert_type call involving a Callable[[], X] type. Pyright was generating a signature with a positional-only separator in this case.

Enhancement (contributed by debonte): Added support for PEP 712's new attribute assignment conversion.

Performance: Fixed a bug in type caching mechanism that could have resulted in poor performance in certain circumstances.

Performance: Added low-level caching mechanism for converting between instance and instantiation types. This should reduce memory usage in some circumstances.

Enhancement: Enhanced the isinstance type narrowing logic so it filters types based on the number of entries in a tuple if the type derives from a tuple.

v1.1.314: Published 1.1.314

Compare Source

Enhancement: Updated typeshed stubs to the latest version. This update includes some substantive changes to stdlib protocols and classes related to buffers. These changes will result in some compatibility issues for some libraries. For more details about the motivation for these changes, refer to PEP 688.

Regression Tests: Upgraded pyright’s CI process to include the execution of mypy_primer, a tool that was written by @​hauntsaninja for mypy and typeshed to catch regressions. He extended the tool to support pyright. If you are a repo owner who uses pyright in your CI and would like us to include your project in pyright’s CI (to understand and prevent regressions that could affect your project), let us know.

Bug Fix: Fixed bug that resulted in a false negative when using the reportMissingTypeArgument check when defining an old-style type alias. This same bug resulted in inconsistent behavior between Union and |, which should be equivalent.

Bug Fix: Fixed a bug in the typeshed VERSIONS exclusions. It was falling back on the VERSIONS file in the packaged typeshed rather than using the custom typeshed path specified in the configuration or command line.

Bug Fix: Fixed a bug that led to a false negative when passing an unpacked tuple of length one to a function that requires more (or fewer) than one positional argument.

Performance: Reverted a recent internal refactoring because it resulted in increased peak memory usage in some cases.

Bug Fix: Fixed false positive error when using a *args: P.args as the first parameter in a method.

Bug Fix: Improved the protocol matching logic so it honors partially-solved type variables whose values are provided by other argument types in a call.

Bug Fix: Fixed a bug that led to infinite analysis time and heap exhaustion when analyzing an overloaded function that includes a ParamSpec that uses itself as an argument.

Bug Fix: Fixed a bug that led to a false positive reportIncompatibleMethodOverride error for overloaded method overrides in cases where the overloads are differentiated based on explicit types for the self or cls parameter.

Bug Fix: Fixed a regression that caused an incorrect type evaluation of a function that returns a callable with a ParamSpec that does not appear outside of the return type annotation.

v1.1.313: Published 1.1.313

Compare Source

This is a hot-fix release aiming to address a specific regression in pyright 1.1.312 reported here.

Bug Fix: Reverted latest typeshed updates that caused a regression related to buffer types.

v1.1.312: Published 1.1.312

Compare Source

Bug Fix: Fixed a bug that results in a false positive when calling a generic function that has a declared return type of a tuple and the call has an expected type (bidirectional type inference).

Enhancement: Enhanced reportIncompatibleMethodOverride diagnostic check to support cases where the overridden function is overloaded. Attempted to duplicate the same logic that's in mypy for compatibility.

Bug Fix: Fixed a bug that resulted in a false positive in certain obscure cases involving callables with parameters that are typed using TypeVarTuples.

Bug Fix: Fixed a bug that led to false positive errors when a generic function was called in a nested manner (i.e. invoked as in an argument expression).

Bug Fix: Fixed a bug that resulted in the incorrect return type inference for an async function that has no type annotations.

Bug Fix: Fixed bug that resulted in a false positive error when using a nested Literal that includes None.

Bug Fix: Fixed a bug that led to extremely long (effectively infinite) evaluation times when a generic function was passed as an argument to itself.

Behavior Change: Changed the matching of an unpacked dictionary passed as an argument to a callable when keyword arguments are present and have default values. Previously, the types of all such parameters were not checked against the unpacked dict type (under the assumption that the default argument would satisfy the parameter in this case). The new behavior matches that of mypy and assumes that the unpacked dict may supply arguments for all otherwise-unmatched keyword parameters even if they have default argument values.

Enhancement: Added auto-exclude logic specifically for typeshed so stdlib stubs that are not "in scope" for the current python version are auto-excluded from the project. This applies only if the typeshedPath is set to ..

Bug Fix: Fixed issue that caused a false positive error in typeshed CI due to nondeterministic handling of circular dependency in ReprEnum class.

Bug Fix: Fixed a bug that led to a false positive error when validating the consistency of the return type of a generator function if the return type declaration was not specifically Generator or Iterable (or their async counterparts).

Bug Fix: Fixed a false negative type error involving a recursive type alias that includes a Sequence and a str (which is itself a recursive type involving Sequence).

Bug Fix: Fixed a bug that led to a false positive error when a call expression was used on the RHS of an "or" or "and" operator and the target callable involved an overload with a function-scoped TypeVar in the return type.

Bug Fix: Fixed a bug in the tokenizer that led to an incorrect error for an f-string that ends in a double backslash.

Bug Fix: Improved evaluation of nested calls that involve the same generic function or multiple uses of the same generic function as arguments to the same call. In these cases, the generic signatures need to be made unique so the type variables of each are treated as though they are independent.

Enhancement: Updated typeshed stubs to the latest version.

v1.1.311: Published 1.1.311

Compare Source

Bug Fix: Fixed regression in f-string tokenization that led to a false positive error when an escape character (backslash) is used with a carriage return or line feed within the non-expression part of an f-string.

Bug Fix: Fixed a bug that resulted in a crash in certain cases within the argument/parameter matching logic.

Bug Fix: Fixed recent regression that led to a false negative when using functools.partial with bidirectional type inference.

Bug Fix: Fixed a bug that led to (temporary) sporadic reportUnnecessaryTypeIgnoreComment errors.

Bug Fix: Fixed a recent regression that affected a function that returned a generic Callable that used type[T] rather than T in the type annotation.

Bug Fix: Fixed a recent regression that resulted in the incorrect evaluation of the value field for an Enum.

Bug Fix: Fixed a bug that led to an unsolved type variable within a union producing an Unknown type in some cases. This triggers false positive errors in strict mode.

Bug Fix: Fixed a bug that allowed unsolved type parameters to "leak" from a __new__ call in some cases.

Bug Fix: Fixed a bug that led to a false positive when a function-scoped ParamSpec was used within a constructor, and a lambda with no parameters is passed to the constructor as an argument.

Bug Fix: Fixed a bug that led to false positive errors for a constructor call used in conjunction with bidirectional type inference for a generic class that includes both a __new__ and an __init__ method.

Bug Fix: Fixed a bug that led to incorrect handling of # type: ignore comments if a file is type checked but then pyright runs low on memory and is forced to dispose of cached parse information. We now precompute the accumulated diagnostics while the cached parse information is available.

Bug Fix: Fixed a bug that led to a crash when running pyright --verifytypes numpy. A pathological case in the numpy code was causing an exponential explosion in the number of type variable signature contexts.

v1.1.310: Published 1.1.310

Compare Source

Enhancement: Reimplemented handling of f-strings in accordance with PEP 701, which is included in Python 3.12.0b1. This is a significant change with potential for regressions.

Enhancement: Implemented ReadOnly TypedDict fields to explore proposed PEP 705 variant as discussed in this discussion thread. This prototype will help inform which direction to take with PEP 705.

Bug Fix: Fixed regression that caused an internal assertion (and therefore a crash) when type checking a constructor whose arguments are not type compatible.

Bug Fix: Fixed bug that led to a "leaked" unsolved type variable if a __new__ method used a function-scoped type variable and there was no __init__ method for the class.

Enhancement: A class created with "NewType" should be treated as though it is implicitly @final. The runtime enforces this. Pyright now correctly generates an error if such a class is used as a base class.

Bug Fix: Fixed a false positive error with the reportImplicitOverride check that occurs when the @override decorator is applied to a method that is decorated with a wrapper function that completely replaces the original function with another.

Bug Fix: Fixed places in the pyright code where lists were being expanded on the stack, resulting in a stack overflow (and therefore a crash) if the list is too large.

Enhancement: Added special-case synthesis of the update method for a TypedDict class. For TypedDicts that include at least one read-only field, no updates are allowed. For TypedDicts that are writable, a "partial" type is synthesized that allows for any subset of keys (required or not required) to be passed to the update method.

Behavior Change: Changed protocol matching behavior for protocols that include a variable annotated as ClassVar. A class that defines this same variable as a "regular class variable" (one that is declared at the class level but can be overwritten on a per-instance basis) is now considered compatible with such a protocol.

Behavior Change: Changed type narrowing on assignment for member access expressions that involve an asymmetric __getattr__ and __setattr__ method. As with asymmetric descriptors, it is not safe in this case to assume that the written value will be the same as the read value.

Bug Fix: Fixed a bug that led to a false positive error in certain circumstances with nested call expressions where the expected type of the parameter was a union.

Behavior Change: Changed the behavior when a parameter whose type is a "naked" TypeVar has a default argument value. Mypy doesn't allow this case. Pyright allows it but previously modified the parameter type to be a union of the TypeVar and the type of the default argument. This behavior closed some type validation holes, but it created other problems and was very unintuitive for users. See https://github.com/microsoft/pyright/issues/3130. See https://github.com/microsoft/pyright/issues/2507 for a discussion that led to this original change. This change reverses this behavior. It potentially allows for some unsafe "creative" uses that will go unreported.

Bug Fix: Fixed recent regression that caused useLibraryCodeForTypes setting not to be applied if it was specified in the language server settings (as opposed to the config file).

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed bug that resulted in a false positive error when the "expected type" for a lambda is a function that includes a ParamSpec.

Bug Fix (thanks to @​LyricLy for the contribution!): Preserve parentheses around unary operators for printing.

Bug Fix: Fixed a couple of bugs in the method override consistency check that resulted in false positives when ParamSpecs were involved.

Bug Fix: Fixed bug that led to the incorrect type evaluation of an async generator when an await operator was used within a nested expression.

Performance: Addressed a performance issue that occurs when analyzing complex functions with deeply nested lambdas. This change adds a more sophisticated type caching mechanism that avoids emptying the cache when analyzing lambdas.

Performance: Added perf optimization to stripLiteralValue method to handle large unions comprised only of literal values.

Performance: Modified constraint solver to limit the number of subtypes in a union for the narrow bound of a type variable. Under certain rare circumstances, this can grow to a very large number and cause perf issues and hangs.

Bug Fix: Fixed a bug that caused an internal cache to be corrupted leading to a false positive error in specific circumstances.

v1.1.309: Published 1.1.309

Compare Source

Behavior Change: Reworked the logic for constructor type analysis to better mirror runtime behaviors of the type.__call__ method. This is a big change with a potential for regressions.

Bug Fix: Fixed bug that led to a false positive under certain circumstances when assigning a value to a variable with a type annotation that evaluates to a descriptor type.

Bug Fix: Fixed a regression that resulted in incorrect type evaluation when passing an argument to a generic class constructor when the argument expression includes an "or" or "and" operator.

Enhancement: Extended the reportUninitializedInstanceVariable check to detect the case where a @final class derives from an abstract base class (or hierarchy thereof) and does not implement one or more variables defined (but not assigned) in an ABC.

Enhancement: Implemented a check for an attempt to invoke a static or class method that is marked abstract.

Behavior Change: Deprecated command-line options 'typeshed-path' and 'venv-path' in favor of 'typeshedpath' and 'venvpath'. The hyphenated options were inconsistent with the conventions used for other options.

Enhancement: Added command-line option pythonpath that allows the path to the python interpreter to be specified.

Behavior Change: Updated support for type statement to conform with the latest updates to PEP 695. It now supports forward declarations, not just self references.

Enhancement: Added support for explicit calls to TypeAliasType constructor, as defined in PEP 695.

Behavior Change: Since PEP 696 won't make it for Python 3.12, pyright now enforces the Python 3.13 requirement for this capability (unless it's in a stub file or TypeVar, TypeVarTuple, and ParamSpec are imported from typing_extensions).

Performance: Changed import resolver to use sets and maps rather than arrays for tracking implicit imports. Arrays are fine if there are a few dozen implicit imports, but if there are thousands, they become a performance issue.

Performance: Added caching in import resolver for relative imports. Previously, we cached only absolute imports.

Performance: Added optimization to alias resolution that avoids the need to parse and bind a file in some cases.

Bug Fix: Fixed a bug that led to a false positive error in an edge case condition that involves an unpacked TypeVarTuple.

Enhancement: Added a check for f-strings that use nested braces in the "format specifier" portion (the section after a colon). This condition generates a syntax error at runtime, so it's useful for pyright to detect and report the error.

Bug Fix: Fixed a bug that results in a false positive error when using a dynamic base class in a class statement where the dynamic base class is based on a bound type variable.

Behavior Change: Changed pyright to reflect a recent decision about PEP 649 (deferred type annotations). The steering council tentatively approved PEP 649 for Python 3.12, but they recently decided to defer it until 3.13.

v1.1.308: Published 1.1.308

Compare Source

Behavior Change: Changed type inference logic that infers the type of the value attribute in an enum. If the enum class has a custom metaclass (one that is not part of the stdlib), pyright now assumes that the custom metaclass may perform some runtime magic that modifies the value. This occurs, for example, in django's TextChoices class.

Bug Fix: Fixed a bug that led to incorrect import resolution in cases where multiple import resolution paths have partial overlapping paths and some include namespace packages and others do not.

Bug Fix: Reworked the logic for bidirectional type inference to address several systemic issues with the previous mechanism when nested calls were used. This is a significant change, and it has the potential for regressions.

Bug Fix: Fixed a bug that led to the incorrect type evaluation of a generic function call if the return result included a type variable that evaluated to Unknown.

Bug Fix: Fixed bug that resulted in a bogus "fully-qualified name" of a symbol if used within a file that is located outside of the project and is not imported by a file in the project.

Bug Fix: Fixed a bug that resulted in incorrect fully-qualified names of type aliases that are nested within classes.

Enhancement: Added code to the "type printer" module that detects overlapping class and type alias names used within the same type. When these are detected, they are printed in their fully-qualified forms to help the user disambiguate.

Behavior Change: Added code to exempt the synthesized __hash__ symbol in dataclass classes from override checks (such as reportIncompatibleVariableOverride).

Bug Fix: Fixed a bug in protocol matching that resulted in a false positive if Self was used in a method within a protocol base class used for another protocol.

v1.1.307: Published 1.1.307

Compare Source

Enhancement: Added support for type narrowing of TypedDicts with NotRequired entries with map patterns that use a literal str key pattern.

Behavior Change: Adjusted heuristic for dealing with ambiguous overloads due to unknown argument types. If one or both overloads include an Any in its return type, it now produces an Unknown result.

Bug Fix: Added support for constructors to PEP 712 mechanism.

Enhancement: Expanded special-case handling of .value and .name properties of Enum instance. It now handles non-literal cases by evaluating a union of all possible names or values defined in the enum.

Behavior Change: Changed behavior of logic that infers the type of the value and _value_ members of an enum instance. If the Enum class defines a __new__ method, these are evaluated as Any rather than a type based on their assigned value because the __new__ method can transform the value in ways that cannot be determined statically.

Behavior Change: Modified the logic (and associated behavior) for constructor validation in cases where a metaclass has a custom __call__ method. This is part of a larger effort to clean up constructor validation and make it more consistent with runtime behaviors.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that resulted in a false positive error when binding a classmethod within a metaclass (i.e. a subclass of type).

Bug Fix: Fixed bug that caused any function or method named deprecated to be treated as though it behaved like typing.deprecated (introduced in PEP 702).

Behavior Change: Improved handling of NewType when Any is passed as a second argument.

Behavior Change: Made "Pyproject file has no pyright section" log message an "Info" message rather than an error to reduce noise.

v1.1.306: Published 1.1.306

Compare Source

Enhancement: Improved type evaluation of yield from expression so it handles operands that are unions.

Bug Fix: Added code to handle the case where a module uses an from A.B.C import X statement within the A/B/C/__init__.py module.

Bug Fix: Fixed a type evaluation bug that produces a false positive when using bidirectional type inference for nested call expressions when the target callables are generic.

Behavior Change: Reduced the default output of the CLI.

Bug Fix: Fixed a bug in the isinstance and issubclass type narrowing when the types have no overlap and one or both is @final. In this case, the narrowing should result in a Never rather than an intersection type.

Bug Fix: Fixed a bug that resulted in a false positive error when constructing a tuple of classes in the second argument of an isinstance or issubclass call.

Bug Fix: Fixed a bug that resulted in false positive errors when overlapping roots were used in a multi-root workspace and new workspaces are added after one of these shared files was already open in the editor.

Bug Fix: Fixed a bug that resulted in a false positive error when doing protocol matching when there are multiple levels of protocol inheritance and a method that uses Self in its signature.

Bug Fix: Fixed inconsistent evaluation of a class type when calling a generic constructor that accepts a type[T] parameter and a union of classes is passed as an argument.

Behavior Change: Changed the behavior of the reportIncompatibleMethodOverride check to exempt the case where the base class or override has a type that is defined by Callable[..., X]. The ... means that it's compatible with any signature. Also fixed a false negative in this check where the base method contains a **kwargs parameter but the override does not.

Bug Fix: Fixed bug that caused useLibraryCodeForTypes to default to false in the CLI if it was not overridden in the config file. Version 1.1.305 was intended to change the default to true, but it didn't.

Bug Fix: Fixed a confusing and inappropriate diagnostic addendum when a function with positional-only parameters is assigned to another function with positional-only parameters but has a parameter count mismatch. The old logic output an inappropriate message about a keyword-only parameter.

Bug Fix: Fixed a bug in the --verifytypes command-line tool that affected the case where a submodule was specified (e.g. --verifytypes a.b.c) and the final nested module was a single file (e.g. c.py) rather than an __init__.py within a folder.

Enhancement: Added support for a generic NamedTuple class — i.e. a class that uses NamedTuple as a base class along with type parameters defined in a Generic[...] base class and then uses these type parameters in type definitions for the NamedTuple entries.

Enhancement: Implemented check for conditional statement operands. Such operands must support a __bool__ method that returns a bool return type. Any other type is treated as an error by the runtime.

Enhancement: Added special-case handling for methods within generic classes parameterized by a ParamSpec when those methods use *args: P.args, **kwargs: P.kwargs in their signature and the callable signature captured by the ParamSpec is from a generic function. In this case, the TypeVar scope of the captured function is retained so its type variables can be solved when the method is solved. This is useful for generic callback protocol classes that implement a __call__ method.

Enhancement (by debonte): Added provisional support for draft PEP 712, which introduces support for a converter parameter in a field descriptor for dataclass and dataclass_transform.

Bug Fix: Eliminated the code that treats unions within value expressions as a UnionType object. This behavior caused various problems including a false positive in some cases.

v1.1.305: Published 1.1.305

Compare Source

Bug Fix: Fixed a bug that resulted in incorrect type comparison results (which led to incorrect type narrowing) when Annotated was used in some circumstances.

Bug Fix: Fixed bug that led to a false positive error when a ParamSpec captures a signature that includes an *args or **kwargs and then is called using an unpacked iterable (for *args) or an unpacked Mapping (for **kwargs).

Enhancement: Added diagnostic for # pyright comment that controls file-level settings that is not on its own line (i.e. doesn't start in column 1).

Bug Fix: Fixed bug that resulted in a false positive error when importing a type alias via a wildcard import.

Bug Fix: Fixed bug in inference of generator function return type that led to false positive error. The "send" type (the second of three type arguments for a Generator) cannot be inferred precisely, so it should be Unknown rather than None. Modified the "send type" type inference logic for generators. Instead of always inferring Unknown, pyright now infers Any if the send type is provably never used within the generator. This is a common case and allows the generator function return type to be inferred without an Unknown partial type in most cases.

Bug Fix: Fixed a bug that led to a false positive error when a partially-specialized generic function with a ParamSpec is further specialized such that the ParamSpec is bound to ... (i.e. the ParamSpec equivalent of Any).

Enhancement: Improved handling of bidirectional type inference for call expressions in the case where the target call returns a callable and the expected type is a union that includes some non-callables. The logic now filters out the non-callables to enable bidirectional type inference to succeed in cases where it previously didn't.

Bug Fix: Fixed a type evaluation bug involving the tuple constructor call when used with bidirectional type inference, specifically when the expected type is a union of tuples.

Enhancement: Updated typeshed stubs to the latest version.

Enhancement: Improved error message for binary operators that don't use union expansion.

Bug Fix: Fixed a bug that resulted in a false positive "is partially unknown" error when using an overloaded function whose implementation was partially unknown. Only the overloads should be considered in this case.

Behavior Change: Changed reportUninitializedInstanceVariable check to exempt subclasses of ABC that are not marked @final. It already exempted Protocol classes.

Bug Fix: Fixed type evaluation bug that led to a false positive in cases involving bidirectional type inference of a constructor whose type variable is invariant and the argument is a dictionary, set, or list expression.

v1.1.304: Published 1.1.304

Compare Source

Bug Fix: Fixed recent regression that led to a false positive error when useLibraryCodeForTypes was false and an import of the form from a.b import c targeted a namespace package a.b that contains a traditional package c.

Bug Fix: Fixed bug that resulted in incorrect type narrowing for case statements that involved sequence patterns when the subject included a recursive type alias.

Enhancement: Added support for functools.partial when the provided function is overloaded.

Bug Fix: Fixed bug that resulted in a false positive when evaluating the types of nested generic function calls when bidirectional type inference is required.

Bug Fix: Fixed bug that resulted in an unresolved Unknown type in a doubly-nested loop when the value comes from a call to an overloaded function or magic method.

Enhancement: Improved type inference for enum values in an enum class created with the one-line form x = Enum("x", "a b c").

Bug Fix: Improved error handling for enum classes created with the one-line form x = Enum("x", "a b c"). The code now handles other whitespaces and commas and properly checks for format strings.

Enhancement: Added support for other functional Enum calls including a list of strings, a tuple of strings, a list of tuples, a tuple of tuples, and a map.

Enhancement: Added support for type evaluation of lambdas that are immediately called. The inferred types of the lambda's parameters must be inferred from the argument types in this case.

Bug Fix: Fixed recent regression that causes a false positive when a variable is assigned an expression of ... within a type stub file and strict type checking is enabled.

Bug Fix: Fixed a bug that leads to a false positive error when evaluating the type of a method that contains a function-scoped ParamSpec when the method is partially specialized through a binding operation.

Enhancement: Improved overload filtering for constructor calls when the class defines no __init__ but does define an overloaded __new__.

Enhancement: Added limited support for type narrowing of subexpressions of the subject expression for match statements. In particular, added support for discriminated TypedDicts and tuples that are discriminated on literals.

Enhancement: Enhanced type narrowing in the negative (not matched) case for sequence pattern matching when the subject is a tuple of known length. In cases where the pattern narrows one tuple entry in the positive case, we can eliminate that subtype in the negative case.

Enhancement: Enhanced type narrowing for pattern matching in cases where the subject is a tuple expression and one of the entries is a subexpression that is later used in a case statement block.

v1.1.303: Published 1.1.303

Compare Source

Behavior Change: This change may require changes to your configuration. Changed the default of the useLibraryCodeForTypes from false to true to bring pylance and pyright into alignment. Also deprecated the "--lib" command-line option, which was previously used to enable useLibraryCodeForTypes from the command line. If your project relies on the old default value, you will need to explicitly set useLibraryCodeForTypes to false in your project’s configuration file.

Behavior Change: Changed reportImportCycles so it is not on by default in "strict" type checking mode. It is highly opinionated and should be used only in cases where the developer opts into it.

Enhancement: Improved the synthesized __init__ method of a TypedDict class so it accepts another instance of the same TypedDict (or another TypedDict that is type compatible) as an argument. This makes pyright compatible with mypy in this regard.

Bug Fix: Added the ability for any callable to conform to a protocol that includes attributes and methods defined in the pseudo-class builtins.function.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when a partially-specialized generic method (with method-scoped type variables) is passed multiple times to a function that accepts generic callables.

Behavior Change: Reverted recent change that validated that explicitly-annotated self and cls in overloaded methods was a subtype of the class that contains them. This change made pyright consistent with mypy, but feedback from pyright users indicated that it was not desired. There are legitimate use cases for this in the overload case.

Bug Fix: Fixed bug that led to incorrect type narrowing for mapping patters in a case statement if the type included a recursive type alias.

Bug Fix: Fixed bug that potentially resulted in internally corrupted state when a class or def statement appears within a conditional block that is determined by the binder to be unreachable.

Bug Fix: Fixed a bug that resulted in a false positive error when assigning a function that has one or more tuple parameters to a generic callable that also accepts tuple parameters.

Bug Fix: Fixed a bug that led to a false positive error when combining a generic callback argument with a second argument that is an empty dict expression.

Bug Fix: Fixed bug in typePrinter that caused syntactically-incorrect output when using the "PythonSyntax" flag and passing a callable type that has a ParamSpec but no additional concatenated parameters.

Performance: Improved internal type caching mechanism used in cases where evaluation needs to be done speculatively (e.g. when evaluating argument expressions for an overloaded function). The previous code consumed significant memory and CPU cycles in certain circumstances.

v1.1.302: Published 1.1.302

Compare Source

Bug Fix: Fixed bug that resulted in a false positive "partially unknown" error when using an augmented assignment targeting a subscripted expression within a loop.

Bug Fix: Fixed regression in CLI version that caused the default stubsPath value to stop working. This regression didn't affect the language server code paths.

Bug Fix: Fixed a bug that caused an overload function with a missing return type annotation (and a placeholder body) to have an inferred return type of None when it should be Unknown.

Enhancement: Added support for negative (fall-through) type narrowing for mapping patterns used in a case statement when the subject type includes a TypedDict with a discriminated field type (i.e. a field whose value is limited to a particular literal value).

Bug Fix: Fixed bug in constraint solver that results in incorrect code being emitted when overriding a method that includes multiple keyword-only parameters.

Bug Fix: Fixed bug that led to inconsistent behaviors when attempting to assign callable with a tuple parameter where the tuple was of indeterminate length. Previously, this generated an error if the source type parameter was a tuple with zero elements.

Enhancement: Added support for type guards of the form x[I] is B and x[I] is not B where x is a tuple and B is a boolean literal True or False or an enum literal.

Enhancement: Implemented PEP 698 (@​override) support for methods decorated with @property decorator.

Bug Fix: Fixed a bug that resulted in a false negative when a self or cls parameter has an incorrect type annotation (not a subtype of the containing class) in an overloaded method.

Bug Fix: Fixed a bug that led to a false positive error when evaluating a call expression that accepts multiple generic callables, at least one of which is parameterized by a ParamSpec, where the generic types of the callables interact when being solved.

Performance: Fixed an issue that resulted in an unnecessary use of memory when transforming certain types that include TypeVars.

Bug Fix: Fixed a bug that led to a false positive when a generic function was passed as an argument to another generic function multiple times. In such a case, the second (and subsequent) instances of the function must be given unique type parameters so they are distinguished from other instances of the same function.

Bug Fix: Changed the evaluated type of an exception group from ExceptionGroup to BaseExceptionGroup.

Bug Fix: Improved type inference for unpacking of tuples that include unpacked tuples whose lengths are unknown.

Bug Fix: Fixed a bug that led to a false positive error when calling a constructor using bidirectional type inference on a generic class that defines a __new__ method but no __init__ method.

Bug Fix: Fixed bug that resulted in a false negative when Never is used as a type argument for an invariant type parameter.

Bug Fix: Fixed a bug that led to a false positive error when applying bidirectional type inference to a call expression that invokes a generic function where the return type includes a generic class with multiple type arguments, some of which are supplied by the expected type and some of which are not.

Bug Fix: Fixed bug that resulted in incorrect type narrowing in the negative (fall-through) case for certain value patterns in a match statement.

Enhancement: Updated typeshed stubs to the latest version.

v1.1.301: Published 1.1.301

Compare Source

Bug Fix: Fixed bug that caused diagnostic for implicit override to be reported as part of reportGeneralTypeIssue rather than `reportImplicitOverride.

Bug Fix: Fixed recent regression that caused a crash in the signature help provider.

Bug Fix: Fixed bug that resulted in false positive "incompatible variance" error when covariant and contravariant type variables were used in certain combinations when defining a generic class.

Enhancement: Added support for argument dictionary unpacking when the type of the unpacked object supports the SupportsKeysAndGetItem protocol. Previously, the object needed to be an explicit subclass of Mapping.

Bug Fix: Fixed a bug that led to the incorrect evaluation of a symbol imported through a from a.b import c statement if a.b is a non-py.typed library, useLibraryCodeForTypes is false and c was also the name of a submodule of a.b. In this case, the evaluated type of c should be Unknown, but it was incorrectly evaluated as a module type.

Behavior Change: Reduced verbosity of CLI output for non-error conditions.

Enhancement: Added support for a TypeGuard function where the first argument is a TypeVar. In this case, the resulting (narrowed) type should be a conditional type that references the TypeVar.

Bug Fix: Added support for "naked" ClassVar used to annotate a class variable that is assigned a descriptor object but is later set through an object member access. This previously resulted in a false positive error.

Enhancement: Added support for synthesized __slots__ symbol in dataclasses that are constructed using the slots=True argument.

Bug Fix: Fixed bug that resulted in an false positive error when using a class (and by implication, its constructor) as an input to a generic function (e.g. a decorator) that is parameterized with a ParamSpec.

Bug Fix: Fixed a bug that resulted in a false negative when using a type variable with an incompatible variance to specialize a generic class that uses a TypeVarTuple.

Bug Fix: Fixed bug that resulted in a false positive error when doing protocol matching where the object type (i.e. the self value) is a literal value.

Behavior Change: Tweaked the type constraint solver's "scoring" mechanism to ensure that functions and function overloads are always scored as "more complex" than classes, objects and unions thereof.

Performance: Fixed issue that resulted in unnecessary caching (and therefore unnecessary memory usage) for instances of types that are already considered instances, such as Any and Unknown.

Bug Fix: Fixed a bug that resulted in spurious type evaluation errors when dealing with classes that have synthesized symbols such as dataclasses, namedtuples and TypedDicts.

Bug Fix: Fixed bug that led to a false positive error when a TypeVar was bound to StringLiteral and conditionally narrowed.

v1.1.300: Published 1.1.300

Compare Source

Bug Fix: Fixed regression that resulted in a false positive error when using an index expression form with a class whose metaclass supplies a __getitem__ method when the expression is used as a runtime expression, as opposed to a type expression.

Performance: sped up type analyzer by 5-25% by caching types that have been converted to or from an instance. This drops the analysis time of pydantic from 17s to 12s.

Performance: Further improved perf when determining type compatibility of unions with many subtypes. This further reduces the analysis time of pydantic from 12s to 4s.

Enhancement: Added new diagnostic check reportImplicitOverride.

Bug Fix: Fixed bug that resulted in a false positive error relating to variance incompatibility.

Bug Fix: Fixed regression that caused a crash in the presence of the illegal statement import ..

Behavior Change: Changed the logic in the code flow engine so it never attempts to infer a NoReturn return type for a function that lacks a return type annotation. This results in a big speed improvement for some (unannotated) code bases, but it also produces somewhat inconsistent type evaluation results because a function whose type is inferred to be NoReturn by the type checker will not be treated as such if it is called elsewhere in the program.

Bug Fix: Fixed bug that resulted in a crash when user types import without a follow-on module name. This can happen in due corse of typing an import statement.

Bug Fix: Added support for clear and popitem methods on TypedDict instance that is marked @final and has no required entries.

Bug Fix: Improved hover text for methods that are synthesized (e.g. the get method for TypedDict).

Behavior Change: When stub generator encounters an import statement within a try block, it now emits it rather than ignoring it.

Bug Fix: Fixed a bug that can result in infinite recursion (and a subsequent crash) when a class instance is called and the class defines a __getattr__ method.

Enhancement: Added support for @deprecated in an __init__ method when constructing a class.

Bug Fix: Fixed a couple of bugs in the type narrowing logic for class pattern matching. In particular, added better support for NoneType() patterns and cases where the subject type is a union that includes subtypes of the class pattern.

Behavior Change: Improved consistency of type narrowing on assignment when the target is a variable with a declared type and the assigned value is an unknown or partially-unknown type. Previously, if the assigned value was Unknown, the declared type was assumed, but if the assigned value was a union that included Unknown, the narrowed type (including the Unknown) was assumed. We now always include an Unknown in the assigned type so the reportUnknownVariableType diagnostic is reported.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that led to the incorrect type resolution for unsupported function Enum class construction. The resulting type should be Unknown, but it was evaluated as Never.

Enhancement: Extended support for reportUnnecessaryComparison check to handle dataclass types that use a synthesized __eq__ method.

Bug Fix: Fixed regression that resulted in internal corrupt state and odd behaviors like builtin symbols being marked as "not found" in some circumstances.

Bug Fix: Fixed a recent regression that resulted in a false positive error when a multi-part import statement was used and useLibraryCodeForTypes was disabled.

v1.1.299: Published 1.1.299

Compare Source

Bug Fix: Fixed bug that caused incorrect evaluation of numeric literals expressed as binary, octal, or hex. These literals were incorrectly represented as "big integers" in some cases, which caused some operations to fail during type checking.

Bug Fix: Fixed display issue with name of module when it is imported implicitly as part of a multi-part import.

Behavior Change: Changed # pyright: basic file-level comment so it overrides "strict" settings specified in the config file or language server settings. This allows an individual file to be "downgraded" from strict to basic.

Bug Fix: Fixed a recent regression that resulted in multi-part imports being evaluated as unknown if a namespace package was used for an intermediate part of the module path and useLibraryCodeForTypes was set to false.

Bug Fix: Fixed regression that led to a false positive error in some cases where when a wildcard pattern is used in a case statement within a loop.

Enhancement: Updated logic for PEP 696 (TypeVarLike "defaults") to change the syntax for ParamSpec default expressions.

Bug Fix: Fixed bug that caused incorrect results with --verifytypes when NewType was used to define a type prior to Python 3.9.

Bug Fix: Fixed a bug that led to a false negative when a non-Generic class has a metaclass that defines a __getitem__ method.

Bug Fix: Fixed a bug that led to incorrect "circular reference" error for a type alias declaration in certain circumstances when that type alias was used in a parameter or return type annotation.

v1.1.298: Published 1.1.298

Compare Source

This is a hot-fix release to correct a regression introduced in 1.1.297.

Bug Fix: Fixed a regression that resulted in a false positive in some rare cases when attempting to assign a value to a property with a defined setter.

Enhancement: Updated typeshed to the latest stubs.

v1.1.297: Published 1.1.297

Compare Source

Enhancement: Extended logic that searches for site-packages directory within a venv to handle the case where multiple /lib/python3.X/site-packages are present. The new logic prefers the configured Python version rather than picking the first one returned by the file system.

Enhancement: Added support for bidirectional type inference for dictionary expressions with dictionary expansion entries.

Bug Fix: Fixed a bug that led to a false positive error when using the | operator with two dicts whose keys or values are defined as literals.

Bug Fix: Fixed a recent regression that resulted in an incorrect type evaluation when using a __new__ method whose return type annotation is Self.

Enhancement: Implemented missing check for generic type alias specialization when too few type arguments are provided.

Bug Fix: Fixed a bug that resulted in a false negative when defining a generic class that derives from another generic class and the type parameter isn't compatible with the variance of the base class.

Bug Fix: Added logic to detect when a type alias is used in a generic class declaration's base class list and a type parameter used with the type alias is incompatible with the variance required for the type alias.

Bug Fix (contribution by Michael Davis): Declare workspaceFolders support in LSP server capabilities.

Performance: Performance optimization: reduced formatting of error messages in cases where it can be determined that they are not needed (e.g. in speculative evaluation code paths).

Bug Fix: Fixed a bug that caused the variance for type parameters to be incorrectly inferred when an auto-variance class derived from a non-auto-variance class.

Enhancement: Added support for type guard patterns type(x) == T and type(x) != T.

Enhancement: Improved error handling for dictionary expressions that use bidirectional type inference when the key type doesn't match the expected type.

Enhancement: Improved handling of typing.TypeAlias so it can be aliased and re-exported from other files.

Bug Fix: If no files are found and no errors are detected but the --outputjson command-line option is used, a json report should still be issued.

Bug Fix: Made JSON parsing stricter for the pyrightconfig.json file. Previously, a JSON syntax error was not detected or reported.

Enhancement: Removed the need for the binder to understand typing.Required and typing.NotRequired special forms. This allows these forms to be imported, re-exported, and aliased.

Bug Fix: Fixed a bug that resulted in an incorrect reporting of "unreachable code" after a call to a generator function that contains an unreachable yield statement.

Performance: Fixed performance issue that affected long if/elif chains.

Bug Fix: Fixed bug that resulted in incorrect type evaluation of arguments to functools.partial call along with false positive errors. The problem is that the special-case logic for functools.partial was not applying bidirectional type inference when evaluating the arg type.

Behavior Change: Changed import modeling behavior for import statements with multi-part module names. The statement import a.b.c now implies import a; import a.b; import a.b.c. This also affects import cycle detection because these implicit imports are now part of the import graph.

Bug Fix: Fixed a bug that led to a false positive error when using a subclass of type as a base class in a class declaration.

Behavior Change: Changed reportSelfClsParameterName check to accept mcs and mcls for first parameter in an instance method within a metaclass (i.e. a subclass of type).

Bug Fix: Fixed bug that resulted in the incorrect type evaluation for a function or method that returns Union[*Ts] where Ts is a TypeVarTuple bound to *tuple[()].

Bug Fix: Fixed regression in --verifytypes where variables assigned from calls to TypeVar, ParamSpec, TypeVarTuple, NewType, TypedDict, and NamedTuple were marked as ambiguous.

Enhancement: Added an error message for Concatenate if a TypeVarTuple is used in the concatenated list of types.

Bug Fix: Fixed a bug whereby the signature help and hover text for an overloaded method would adopt its class docstring rather than the docstring for its own implementation.

Enhancement: Added check and corresponding error for use of an unpacked tuple in a Concatenate.

Bug Fix: Fixed several bugs relating to types of callables (functions, methods, lambdas). There were bugs in the type printer, call expression evaluator, and param spec specialization logic.

Enhancement: Added experimental support for inlined TypedDict definitions using the dict[{'a': int}] syntax.

v1.1.296: Published 1.1.296

Compare Source

Bug Fix: Fixed a bug that resulted in a false positive when determining the correct variance of a TypeVar used within a class.

Bug Fix: Improved type inference of method calls on super() so Self is generated rather than the concrete class.

Bug Fix: Fixed regression in import resolver that resulted in spurious "stub not found" diagnostics.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation of augmented assignments used in loops in some cases.

Bug Fix: Addressed a performance issue that resulted in long evaluation times when a variable was used in a loop but was not initialized prior to the loop.

Enhancement: Improved support for ternary expressions that use a statically-evaluatable condition expression.

Enhancement: Enhanced the reportUnnecessaryComparison to check for unused patterns in a match statement.

Bug Fix: Fixed bug that caused a false positive when a variable of type type is used as an argument to a class declaration.

Bug Fix: Changed logic to treat self and cls parameters as positional-only for purposes of protocol matching.

Bug Fix: Fixed bug that resulted in a false positive error with assert_type when the evaluated type involved a pseudo-generic class.

Enhancement: Updated typeshed stubs to the latest version.

Enhancement: Added diagnostic check for when unknown or partially-unknown type is captured by a wildcard pattern in a match statement.

Enhancement (from pylance): Added module name to moduleUnknownMember diagnostic.

Performance: Improved performance by not inferring return type of overloaded implementation when binding an overloaded method to an object.

v1.1.295: Published 1.1.295

Compare Source

Behavior Change: Updated the handling of type narrowing for class pattern matching in cases where a class subclasses from one of the special built-in types listed in PEP 634 as treating a single positional argument as matching the entire subject. The behavior of the CPython implementation deviates from the PEP in this manner, but the implementation takes precedent over the spec in this case.

Bug Fix: Fixed a bug that led to false positive errors when evaluating comparison operator overrides (e.g. __eq__ or __lt__) in cases where the LHS type didn't support the comparison but the RHS type did.

Enhancement: Added logic to exempt a self with annotated type Never from the check that verifies the self type is a subtype of the class.

Bug Fix: Fixed a bug that resulted in an incorrect inferred function return type when one or more of the return statements returned an expression based on an empty container ({} or []).

Bug Fix: Fixed a bug that caused a Final variable to lose its literal value when imported from another file.

Bug Fix: Fixed a bug that resulted in a false positive "overlapping overload" diagnostic in certain cases.

Bug Fix: Fixed a bug that resulted in a false positive diagnostic when using a TypeVarLike with a default value by itself in a function signature.

Bug Fix: Fixed issue that caused the type of None.__class__ to be evaluated incorrectly with new typeshed definition of object.__class__.

Enhancement: Updated typeshed stubs to the latest.

Enhancement (contribution by Declan Brady): Added parameter documentation on hover from function docString.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when a __new__ is called and is bound to a class that is different from the cls argument passed to it.

v1.1.294: Published 1.1.294

Compare Source

Bug Fix: Fixed a bug that led to a false positive error when using a type alias within an __init__ or __hash__ method in a dataclass.

Bug Fix: Fixed a false negative where a variable used within a TypeAlias definition was not flagged as an error.

Bug Fix: Fixed false negative error where an attempt to assign a value of type type[T] to type T was not flagged as an error.

Bug Fix: Fixed a bug that results in a false positive error when using Self in a type annotation for a parameter with a default value.

Behavior Change: Removed typeshed tensorflow stubs because they're too incomplete at this time.

Enhancement (from pylance): Added completions and signature help for unpacked kwargs (PEP 692).

Behavior Change: Change dataClassFieldWithDefault from error to reportGeneralTypeIssue diagnostic so it can be disabled.

Bug Fix: Fixed bug that resulted in a false positive error when calling type(None)().

Enhancement: Improved error handling for constructor call to NoneType.

Bug Fix: Fixed bug that led to incorrect type evaluation when a yield statement was used in conjunction with a declared Iterator return type.

Enhancement: Added error reporting for malformed # pyright comments.

Bug Fix (from pylance): Fixed recent regression in hover text for variable whose type is Unknown.

Bug Fix: Fixed a bug that resulted in a false positive when accessing an instance method from a metaclass (i.e. a class that derives from type) if the self parameter of that instance method is annotated with a type[T] annotation.

v1.1.293: Published 1.1.293

Compare Source

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when accessing instance methods directly from a None instance.

Bug Fix: Fixed a regression that resulted in a crash when resolving overloads with different numbers of parameters and with with arguments that evaluate to Any.

Bug Fix: Fixed a bug that resulted in an inconsistent "import not accessed" diagnostic based on evaluation ordering.

Bug Fix: Tweaked the "type complexity" heuristic to produce more intuitive results in the constraint solver.

Enhancement: Added specialized logic to better handle imports of the form from .x import x where x is later referenced from an inner scope within the module.

Enhancement (from pylance): Modified class and function signatures to make them more textmate compatible.

Enhancement: Improved handling of a class declaration that uses a dynamic unpacked argument type to define its base classes.

Bug Fix: Fixed a bug that resulted in a false positive error and incorrect type evaluation when a lambda is evaluated with an incomplete "expected" type.

Bug Fix: Fixed false negative bug when checking for valid use of identifiers within a type annotation. Variables used within a type annotation should always generate an error, even if the variable is imported from another file.

Bug Fix: Fixed a bug that led to a false positive error when a magic method (such as in a binary operation) was used with bidirectional type inference.

Enhancement: Added error for a dataclass that uses a private attribute name that appears within a synthesized __init__ method.

Enhancement: Implemented support for overloaded functions captured by a ParamSpec.

Enhancement: Updated typeshed stubs to the latest.

Bug Fix: Fixed bug in signature help that resulted in incorrect or misleading signature for a constructor call when the __init__ method accepts no arguments.

v1.1.292: Published 1.1.292

Compare Source

Bug Fix: Fixed a bug that results in a false positive error in certain circumstances when a match statement is used within a loop.

Bug Fix: Fixed a bug that caused a hang when a function that accepted a Callable with a ParamSpec was fed to itself as an argument.

Enhancement: Improved formatting of function signatures in hover text.

Enhancement: 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.

Enhancement: Added filtering in hover provider for overloaded constructors. Filtering for other overloaded functions and methods was previously added, but constructors were overlooked.

Bug Fix: Fixed a bug that resulted in an infinite loop in some cases where list lists, sets or dicts were inferred loop construct.

Enhancement: Extended the reportUnnecessaryComparison check to also handle conditions of the form x is None and x is not None.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that resulted in incorrect type narrowing for discriminated TypedDict types when the narrowed expression includes a member access subexpression.

Bug Fix: 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.

Enhancement: 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''].

Bug Fix: Fixed bug that resulted in a false positive when trying to assign a value of type NoneType to type[object].

Bug Fix: Fixed a bug that led to a false negative when a backslash character was used within an expression segment of an f-string.

Behavior Change: 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.

Bug Fix: Fixed a bug in the handling of file specs (globs) used for the "include" configuration option. A directory wildcard pattern (**) was not handled correctly.

Behavior Change: Disabled type narrowing for expressions of the form " == X" and != 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.

Performance: 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.

Bug Fix: 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.

v1.1.291: Published 1.1.291

Compare Source

Bug Fix (from Pylance): Allow non-identifier characters immediately after #region.

Bug Fix: Fixed a bug that led to a crash in certain circumstances where a TypedDict field annotation contained a circular reference to the TypedDict.

Bug Fix: Fixed a bug that led to a crash under certain circumstances when a dictionary expansion subexpression (**val) was used.

Bug Fix: 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.

Bug Fix: Fixed inconsistency within isinstance type guard logic when handling the narrowing of a type that contains a union with Any or Unknown.

Bug Fix: 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.

Performance: Improved type analysis performance in some cases that involve protocol matching where the protocol incorporates an overloaded method.

Bug Fix (contribution by André Fontenele): Fixed a bug that caused "go to definition" to go to a bogus position within a file in cases where the identifier refers to a module.

Performance: Added optimization to handle unions that contain large numbers of union literals.

v1.1.290: Published 1.1.290

Compare Source

Bug Fix: Fixed regression that resulted in an incorrect Unknown type when evaluating a list comprehension in a loop.

Bug Fix: Fixed bug that resulted in incorrect contextual evaluation of certain sub-expressions.

Bug Fix: Improved bidirectional type inference logic to handle cases where an expected type includes a TypeVar that is bound to a type that influences the type inference.

Bug Fix: Fixed a recent regression with the truthy/falsy type guard logic when a constrained TypeVar is involved.

Enhancement: Improved error message for implied return type mismatch.

Bug Fix: Fixed bug that resulted in a false positive error when using the | operator for two sets of str values within a join call.

Bug Fix: Moved __init_subclass__ argument validation from the checker to the type evaluator so types of keyword arguments used in the class declaration are evaluated consistently. Prior to this, hovering over a keyword argument sometimes displayed an Unknown type.

Bug Fix: Fixed a bug that resulted in a false negative when binding an object to an overloaded method where all of the overloads have an annotated self type and none of them match the type of the object.

Bug Fix: Fixed a bug that led to infinite recursion in certain circumstances when using a recursive type alias with a type variable.

Bug Fix: Fixed a bug in the type printer that generated incorrect output for bytes literal types that include non-printable characters.

Bug Fix: Fixed a bug that resulted in false positive errors when an f-string uses an escape character sequence within the format string section.

Enhancement: Extended user-defined TypeGuard functions to support objects with __call__ method.

v1.1.289: Published 1.1.289

Compare Source

Bug Fix: Fixed a bug that resulted in incorrect type evaluation for a callable attribute within a TypedDict or dataclass. If the attribute has no type annotation, it should be treated as a class variable, not an instance variable.

Bug Fix: Fixed a bug that causes incorrect interpretation of a large integer literal value — one that doesn't fit within a 53-bit mantissa.

Bug Fix: Fixed a bug in the truthy/falsy type guard logic when using self (or another bound TypeVar) where the bound class implements a __bool__ method.

Bug Fix (from pylance): Fixed a bug in vscode-languageserver client that caused bogus cancellation assertion.

Bug Fix: Fixed bug in dataclass_transform logic for frozen_default. If the frozen_default is set to True, it wasn't possible to override it with False explicitly.

Bug Fix: Fixed bug that resulted in a false positive error when using the | operator to combine two set objects.

Bug Fix: Fixed a bug that resulted in an infinite loop when tuple addition was used within a loop construct.

Bug Fix: Fixed bug that led to a false positive when using method-scoped type variables in a type annotation for a cls parameter in a classmethod.

Enhancement: Added a new check for a TypeGuard or StrictTypeGuard function that does not have at least one input parameter.

Bug Fix: Fixed a bug that resulted in a false negative when bidirectional type inference was used for a list expression and a list entry with an incompatible type is present.

Enhancement: Updated typeshed stubs to the latest version.

Enhancement: Added support for x[K] is V and x[K] is not V type narrowing forms.

Enhancement: Added support for the tentatively-accepted PEP 649 (deferred evaluation of annotations) in Python 3.12.

Bug Fix: Fixed a bug that resulted in a crash within the document symbol provider when a "naked" decorator is present.

Enhancement: Added provisional support for draft PEP 702 (marking deprecations using the type system).

v1.1.288: Published 1.1.288

Compare Source

Bug Fix: Fixed a bug that resulted in a false positive error when accessing __required_keys__ and __optional_keys__ class variables from a TypedDict class.

Enhancement: Added support for type guard forms x is ..., x is not ..., x == ... and x != .... Support for these were recently added to mypy.

Enhancement: Added support for NoneType to be used in an isinstance type guard or match statement.

Bug Fix: Fixed a bug that resulted in a false positive when using heavily-nested call expressions that target overloads. The speculative type cache was not storing information about whether the type evaluation resulted in errors, so incorrect overloads were being chosen in the cached path.

Bug Fix: Fixed a recent regression that led to a false positive in certain cases when a call to a generic function was made within a loop.

Bug Fix: Fixed a bug that resulted in a false positive error in certain cases when using PEP 695 type parameter syntax.

Bug Fix: Fixed a bug that resulted in an incorrect type evaluation when calling a constructor on a class that uses new PEP 696 TypeVar defaults and provides an __init__ but no __new__.

Bug Fix: Fixed a bug that led to a false negative when comparing a function without a *args to a callable type with a *args.

Bug Fix: Fixed a bug in PEP 696 (TypeVar defaults) logic that resulted in a false positive error when a Self type was used within a generic method that also used a TypeVar with a default type.

Bug Fix: Fixed a bug that resulted in incorrect isinstance type narrowing in certain cases when found within a loop construct.

Bug Fix: Fixed a bug that resulted in a false positive error when a generic class used a contravariant type variable and defined a __new__ method that uses cls: type[Self] as a parameter.

v1.1.287: Published 1.1.287

Compare Source

Bug Fix: Fixed false positive error in parser when an assignment expression (walrus operator) is used in a subscript list without parentheses. This was a syntax error in Python 3.8 and 3.9 but is allowed in 3.10 and newer.

Bug Fix: Fixed regression that caused an incorrect type evaluation in the presence of a doubly-nested loop.

Bug Fix: Fixed bug that sometimes resulted in incorrect type evaluation of tuple expressions used within a loop.

Bug Fix: Fixed a bug in the import cycle detection logic that led to some false negatives.

Enhancement: Addressed type evaluation performance issue by eliminating separate "incomplete type cache" and combining it with the primary type cache.

Enhancement: Improved error reporting for type mismatch involving a return type that is a TypedDict.

Bug Fix: Fixed a bug that resulted in a false positive error when resolving nested overloaded function calls where the correct overload match depends on bidirectional type inference.

v1.1.286: Published 1.1.286

Compare Source

Bug Fix: Reverted a recent update to the TOML parser that resulted in a regression. This reversion means that some TOML 1.0 features will not be handled correctly.

Bug Fix: Fixed a bug that resulted in incorrect handling of literals in the TypeVar constraint solver. This involved a pretty significant change to the constraint solver logic — one that eliminated some heuristics and special cases.

Bug Fix: Fixed a bug that caused target expressions within a chained assignment to be evaluated in the wrong order (right to left instead of left to right). This resulted in false positives and negatives in some cases where one target referred to another target. This change also makes it illegal to use a Python 2-style type comment on a line containing a chained assignment statement, reflecting the fact that Python 3-style variable type annotations are not legal here either.

Enhancement: Improved handling of TypeVarTuple constraint solving. Previously, if a TypeVarTuple appeared more than once, the corresponding tuple types needed to be identical. The constraint solver now supports the same sort of narrowing/widening within the tuple entries to find the best solution.

Bug Fix: Fixed a bug that led to a false negative during protocol matching if the protocol class refers to itself within an invariant type argument.

Enhancement: Improved handling of generic functions passed as arguments to generic higher-order functions. Pyright is now able to solve the type variables for both the generic callback and the called function.

Enhancement: Updated typeshed stubs to the latest version.

Enhancement: Improved handling of generic functions passed as arguments to generic higher-order functions that use a ParamSpec. Pyright is now able to solve the type variables for both the generic callback and the called function.

Bug Fix: Fixed a bug in the code flow engine that resulted in incorrect type evaluation in some cases involving double nested loops.

Bug Fix: Improved the method override consistency checks to detect the case where an override uses an *args parameter that is not type compatible with the overridden method's parameter types. Thanks to @​mehdigmira for this contribution.

Enhancement: Improved handling of TypeVars that appear only within a Callable within a return type annotation for a function. By a strict reading of PEP 484, these should be bound to the function's scope, but practically, they are bound to the Callable. This allows a function to return a generic callable type. When TypeVars are rescoped in this manner, the TypeVar cannot be referenced within the function body because it is no longer in scope in that context.

Enhancement: Improved error handling for NewType calls

Enhancement: Completed initial implementation of PEP 696. Added support for default TypeVar types that refer to other TypeVars.

v1.1.285: Published 1.1.285

Compare Source

Enhancement: Implemented a new --level command-line option that allows filtering of 'information' and 'warning' diagnostics.

Enhancement: Updated TOML parser to one that is compliant with the TOML 1.0 spec.

Enhancement: Added logic to detect uses of PEP 604 | syntax that generate exceptions due to runtime limitations. In particular, if one of the operands is a string (i.e. a forward reference) and the other is also a string or a class that is not explicitly specialized, this will result in an exception.

Bug Fix: Fixed recent regression in completion provider that resulted in garbled type information for a symbol that is declared as a function (using a def statement) but transformed into a non-function type using a decorator.

Bug Fix: Fixed a bug that resulted in a false positive error when an index expression with a numeric literal subscript was used in a loop that included a del statement targeting the same index expression.

Behavior Change: Modified the overload matching algorithm to match the behavior of mypy when the overload match is ambiguous because an argument evaluates to Any or Unknown. In this case, the call expression evaluates to Unknown. Previously, pyright used the first of the matching overloads in this case.

Bug Fix: Fixed a bug that led to extremely long type analysis times when determining type compatibility between an recursive type alias and a recursive protocol.

Bug Fix (contribution from @​parched): Fixed recent regression that caused reportImportCycles diagnostic reporting to no longer work.

Bug Fix: Fixed a bug that resulted in a false positive error when a property setter or deleter contained function-scoped type variables.

v1.1.284: Published 1.1.284

Compare Source

Bug Fix: Fixed a bug that resulted in an incorrect type evaluation when using a literal integer index into a tuple that includes an unpacked TypeVarTuple element.

Behavior Change: Removed diagnostic check that detects a non-ellipsis default value in a stub file. This check was based on a now-outdated best practice. We now recommend that stubs include default values for better usability in language servers.

Bug Fix: Fixed recent regression that caused the hover text for a function symbol to be improperly formatted if its type was evaluated to something other than a function.

Enhancement: Exposed new configuration setting analyzeUnannotatedFunctions which corresponds to the --skipunannotated command-line option. Added an information diagnostic for skipped functions.

Bug Fix: Fixed bug that resulted in an incorrect target range when resolving the declaration of an import. There were cases where "Go To Declaration" would take you to a location within the target file that corresponded to the offset of the import statement within the importing file.

Bug Fix: Fixed bugs that resulted in false positive errors when assigning a type to a Callable and when accessing members from a type[T] or a T that is bound to type.

Enhancement: Improved bidirectional type inference for list, set and dictionary expressions when the "expected type" is a union that contains multiple potentially-compatible subtypes.

Bug Fix: Fixed a bug that led to a false positive error when evaluating a recursive type alias definition that uses a generic type that is parameterized using a bound or constrained type variable.

Bug Fix: Added missing diagnostic rule in diagnostics reported as part of the reportImportCycles check. Thanks for @​parched for this fix.

Bug Fix: Fixed false positive error in multi-inheritance override check in cases where the override symbol was provided by one of the base classes.

Enhancement: Updated typeshed stubs to the latest version.

Behavior Change: Added check for disallowed expression forms used with TypeAlias and with PEP 695 type statement.

Bug Fix (from pylance): Fixed exclude/include to work with '.' prefixed directories.

Bug Fix: Fixed a bug that led to a false positive when a NoReturn or Never type argument was used for a covariant type parameter.

Bug Fix: Fixed regression that resulted in inconsistent behavior when useLibraryCodeForTypes is false and a symbol is imported from a non-py.typed library.

v1.1.283: Published 1.1.283

Compare Source

Enhancement: Added support for # pyright: ignore and # type: ignore comments that are not at the start of a comment.

Enhancement: Improved parse recovery for common indent/dedent conditions.

Bug Fix: Fixed recent regression that resulted in a false positive when a type[T] was assigned to a Callable[..., T].

Bug Fix: Fixed a regression related to a recent change in typeshed that caused imports from google.cloud namespace packages to fail.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when assigning an unpacked TypeVarTuple to a regular (non-variadic) TypeVar during constraint solving. This should result in a union of the TypeVarTuple types.

Bug Fix: Fixed a bug that resulted in a false positive diagnostic when importing a symbol from a "py.typed" library that was imported (and re-exported) from a non-"py.typed" library.

Bug Fix: Changed ParamSpec capture logic to track the expression used for a default argument value.

Bug Fix: Fixed a recent regression that led to a false negative when evaluating the type of an unannotated variable in a loop.

Enhancement: Added support for frozen_default for dataclass_transform.

Bug Fix: Fixed recent regression that caused a false positive reportShadowedStdlibModules for relative imports and imports starting with _.

Enhancement: Show doc strings on hover over module names within import statements.

Enhancement: Updated typeshed stubs to the latest version.

Enhancement: Added small perf optimization for determining type compatibility between two unions, especially in cases where the number of items in the union is large.

Bug Fix: Added logic to limit recursion when handling type compatibility checks between two different recursive type aliases that have the same definition.

Bug Fix: Fixed bug that resulted in a false positive when passing an unpacked dict or unpacked iterable argument to the constructor of a class that has no __init__ and therefore uses object.__init__.

Bug Fix: Fixed bug that led to a false positive error when using an unpacked argument that has a declared type that is a tuple with an unpacked TypeVarTuple.

Bug Fix: Fixed bug that resulted in a false positive reportPrivateImportUsage diagnostic when importing from a py.typed library under certain circumstances.

v1.1.282: Published 1.1.282

Compare Source

Bug Fix: Fixed bug that resulted in false positive error when a recursive type alias involving a union was used in certain circumstances.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when assigning a tuple with an unpacked TypeVarTuple to a tuple with a normal TypeVar.

Bug Fix: Fixed a bug that resulted in a false negative (a missing error) when assigning a union that contains a TypeVar to another union with the same TypeVar.

Bug Fix: Fixed bug that resulted in incorrect type inference for an instance variable that is assigned different types in different places.

Bug Fix: Fixed bug in tokenizer that resulted in false positive error when a floating point literal started with one or more leading zeros.

Bug Fix: Added logic to deal with conflicting namespace packages when one has no __init__.py(i) file and the other does.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that results in a false positive error when a dataclass field in a child class overrides a non-init dataclass field in a parent class.

Enhancement: Added code to report an error if a from __future__ import x statement is not found at the beginning of a file. This results in a syntax error.

Behavior Change: Changed reportUnnecessaryTypeIgnoreComment to to ignore # type: ignore comments if enableTypeIgnoreComments is set to false.

Bug Fix: Fixed a bug that led to an incorrect type evaluation when an empty list or dict literal is included in a list expression with an "expected type" (i.e. bidirectional type inference is being attempted).

Bug Fix (from Pylance): Fixed recent regression that caused false positive errors to appear when using a multi-root workspace.

v1.1.281: Published 1.1.281

Compare Source

Enhancement: Improved parse recovery for ternary expressions that are missing an else or a post-else expression.

Enhancement: Changed the implicit declared type of a module-scoped doc to be str instead of str | None when a docstring is present at the top of the module.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when dealing with a union of an unpacked TypeVarTuple.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when dealing with a union of an unpacked TypeVarTuple.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when applying a solved unpacked TypeVarTuple in a Union.

Bug Fix: Fixed a bug that resulted in a false positive during protocol matching for a protocol that includes a property with a getter whose self parameter is annotated with a TypeVar.

Bug Fix: Fixed a bug that resulted in sporadic type evaluation errors when a quoted (forward-declared) type was used in a statement with an explicit PEP-613 TypeAlias annotation.

Bug Fix: Fixed bug that resulted in false positive errors when doing protocol matching for a recursive protocol definition. I needed to increase an internal recursion limit to support this.

Enhancement: Updated typeshed stubs to the latest.

Bug Fix: Fixed regression that resulted in errant reportMissingImports diagnostics within stub files.

Enhancement: Improved parse recovery when a suite contains an unexpected indent followed by a dedent that restores the indentation to that of the suite's body.

Bug Fix: Fixed a bug in the evaluation of the "with" statement that resulted in a false positive error when a class implements a context manager via its metaclass.

Bug Fix: Fixed a bug that led to a false positive error when validating the variance of type parameters for a protocol class when a covariant type parameter is used in a return type in the form type[T_co].

Bug Fix: Fixed a bug that resulted in a false positive error when using a cast to a TypeVar.

Bug Fix: Fixed a bug in the type evaluator that could lead to unsolved TypeVars if used in a Callable parameter.

Bug Fix: Fixed recent regression that led to false positive reportUnnecessaryCast diagnostics.

v1.1.280: Published 1.1.280

Compare Source

Bug Fix: Fixed bug that led to an incorrect type evaluation (and potential false negative) when an iterable iterates over an unpacked TypeVarTuple.

Bug Fix: Enabled the Never type to be used as an explicit type argument for a contravariant parameter.

Bug Fix: Fixed a bug in the type printing logic where it omitted a Union when an unpacked TypeVarTuple is used within a Union.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when the type arguments for a tuple included an unpacked TypeVarTuple. In this case, the type argument should be treated as a Union[*Ts] rather than *Ts.

Bug Fix: Fixed a bug that resulted in a false positive for the reportIncompatibleMethodOverride check when the base method used an unpacked tuple for the *args parameter and the override used specific parameters.

Bug Fix: Fixed a bug that resulted in a false negative when a non-frozen dataclass subclasses from a frozen dataclass. This generates a runtime error, so it should be flagged by the type checker.

Bug Fix: Fixed a bug that resulted in a false positive error related to type narrowing in a match statement when matching against an enum with only one value.

v1.1.279: Published 1.1.279

Compare Source

Behavior Change: Changed the way pyright handles the case where a dataclass or dataclass-like class handles a synthesized __init__ if one or more base classes are unknown.

Bug Fix: Fixed bug in type printer logic that resulted in a triple * before an unpacked TypedDict when it was used with a **kwargs parameter and the TypedDict was generic.

Bug Fix: Fixed a bug that resulted in a false positive when invoking the constructor for a generic class that uses an unpacked TypedDict with an **args parameter.

Bug Fix: Fixed regression that caused non-JSON output to be emitted when --verifytypes is used in conjunction with --outputjson.

Behavior Change: Changed the reportUninitializedInstanceVariable so it doesn't run on stub files.

Enhancement: Added new diagnostic rule reportShadowedImport that emits a diagnostic if a local module shadows a stdlib module.

Bug Fix: Fixed a bug that resulted in a false positive when a call expression includes an unpacked argument that is a tuple with a known length.

Bug Fix: Reverted recent change to the reportUnnecessaryComparison check that introduced a regression.

Bug Fix: Fixed a bug that resulted in a false negative when a *args parameter with an unpacked tuple is followed by additional keyword-only parameters that are not supplied by a caller.

Bug Fix: Added code to clean up the temp directory that pyright creates when determining whether the file system is case sensitive.

Bug Fix: Fixed bug that resulted in false positive error when evaluating an unpacked tuple or TypeVarTuple in an *args parameter annotation.

Bug Fix: Improved argument/parameter matching for unpacked tuple arguments.

Bug Fix: Fixed a bug in detection of variance inconsistency with base classes in a class definition.

Enhancement: Added support for detecting unhashable types within set and dict expressions. These result in a TypeError at runtime.

Bug Fix: Fixed bug that resulted in poor hover text message for keyword arguments passed to a TypedDict constructor.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when a generic class implicitly referenced one of its own magic methods (e.g. __iter__).

Enhancement: Added support for recursive type references when using the functional "alternative syntax" for TypedDict.

Behavior Change: Changed the synthesized __dataclass_fields__ variable in dataclass to be a ClassVar so it cannot be overridden by an instance variable.

Behavior Change: Changed protocol matching logic to enforce that a protocol with a ClassVar requires that any compatible class also declare the corresponding field as a ClassVar. Previously, any class-scoped variable satisfied the protocol in this case. This change brings pyright and mypy into agreement.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation involving a recursive type alias that is defined as the union of other types, one of which introduces the recursion.

v1.1.278: Published 1.1.278

Compare Source

Behavior Change: Changed the reportUnusedImport check to not report an error for "from y import x as x" since x is considered to be re-exported in this case. Previously, this case was exempted only for type stubs.

Enhancement: Expand enums in negative narrowing of x in y.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when an f-string uses expressions that are unions of literal strings. The result should be LiteralString, not str.

Enhancement: Improved the reportUnnecessaryComparison diagnostic check to detect (and properly report) cases where a comparison if literals is always true or always false.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when creating a union from two generic functions that are parameterized by different ParamSpecs but are otherwise identical.

Behavior Change: Updated the default Python version from 3.10 to 3.11 now that 3.11 has been released in its final form. Pyright assumes the default version if it is not otherwise told which version to use (explicitly as a setting or command-line argument or implicitly via the selected Python environment).

Enhancement: Enhanced --verifytypes so it honors the --pythonversion and --pythonplatform command-line arguments and falls back to the selected Python environment to get these values if they are unspecified.

Bug Fix: Fixed a bug in the type evaluator related to TypeVarTuple that caused it to incorrectly report a type incompatibility between *Ts and *tuple[*Ts]. These are the same type, so they should be compatible.

Bug Fix: Fixed a bug that results in incorrect specialization of a function or method that uses a TypeVarTuple parameter. The internal flags were being lost including the tracking of class methods and static methods.

Bug Fix: Added support for unpacked tuple arguments passed to an *args parameter declared with a TypeVarTuple.

v1.1.277: Published 1.1.277

Compare Source

Enhancement: Added support for falsy type guard expressions when the evaluated type is a NamedTuples with at least one element. These always evaluate to True.

Bug Fix: Fixed bug that resulted in a false positive "possibly unbound" error when a builtin symbol is overridden in the global scope within a conditional block.

Enhancement: Improved error message for TypeVar constraints that contain generics. Fixed a bug that prevented an error message when keyword argument was duplicated in a call to TypeVar.

Enhancement: Added support for infer_variance parameter to TypeVar as specified in draft PEP 695.

Bug Fix: Improved consistency of assignment-based type narrowing when the type of the assigned value includes an Any or Unknown type argument that is nested more than one level deep and the expected (declared) value contains a type argument that is not Any.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed bug that results in a false positive error when a protocol class implements an overloaded method.

Bug Fix: Added a workaround for a recent change to the typeshed stub dataclasses.pyi relating to the InitVar class. For Python 3.8, the stub indicates that the InitVar class has a metaclass called _InitVarMeta that has a __getitem__ method that returns a value of type InitVar[Any], but this creates a circularity because the evaluation of the expression InitVar[Any] depends on the return type of _InitVarMeta.__getitem__.

v1.1.276: Published 1.1.276

Compare Source

Enhancement: Updated typeshed stubs to the latest version. This includes the removal of stubs for freezegun.

Enhancement: Added support for draft PEP 698 and the @override decorator.

Enhancement: Enhanced reportSelfClsParameterName so it applies to overload signatures. In the general case, this check is not applied to functions with decorators because decorators can change the semantics of parameters for the decorated function. But @overload is a special case, and its semantics are well known.

Enhancement: Extended the defineConstant mechanism to work with conditional statements that contain member access expressions that reference a defined member name.

v1.1.275: Published 1.1.275

Compare Source

Bug Fix: Fixed a bug that resulted in an incorrect type evaluation when a TypeVar bound to an Enum class is instantiated.

Bug Fix: Added a global "cache manager" to track heap usage for all type analyzer service instances. This prevents out-of-memory conditions when many roots are used in a multi-root workspace.

Behavior Change (from Pylance): Don't treat classes decorated with dataclass_transform as dataclasses for purposes of determining which fields should be represented in the synthesized __init__ method. This was an ambiguity in PEP 681, which was recently clarified.

Bug Fix: Fixed a bug that resulted in a false negative when using illegal annotation expression forms within a TypedDict inlined (call-based) definition.

Bug Fix: Fixed a bug in the code flow engine that resulted in incorrect type evaluation in certain cases involving nested loops.

Bug Fix: Fixed a bug that resulted in a false positive error when a call targets an object with a __call__ that is itself an object with a __call__ method.

Bug Fix: Added a check for a return statement with an explicit return value within an async generator function. This is considered a syntax error by the Python compiler, so it should be flagged at static analysis time.

Bug Fix: Fixed a bug that resulted in incorrect handling of binary files (e.g. ".so" or ".pyd" files) within a library when creating stub files.

Behavior Change: Enhanced the heuristics used to infer the type of an unannotated function parameter with a default value. If that value evaluates to an instance of a class with a private name (i.e. it starts with an underscore), pyright will now assume that the value is potentially a singleton sentinel value similar to None and will infer the type to be a union of that type and Unknown.

v1.1.274: Published 1.1.274

Compare Source

Bug Fix: Fixed a bug that resulted in incorrect type evaluation for members of a StrEnum subclass under certain circumstances. This was caused by a circular dependency in ReprEnum caused by pyright's validation of __init_subclass__ as part of class type evaluation. This change moves this validation step from the type evaluator to the checker, eliminating the potential for circular dependencies and improving performance.

Bug Fix: Fixed a bug that resulted in a false positive error indicating that a type definition relies on itself in a circular manner.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation for constructor calls using bidirectional type inference where the expected type includes TypeVars that are not in scope for the constructor call.

Bug Fix: Fixed a bug that resulted in incorrect type narrowing based on literal field discrimination (<a>.field == <literal>) where the expression <a> is a member access expression.

Bug Fix: Fixed a bug in the "--verifytypes" CLI option that resulted in incorrect calculation of the type completeness core in cases where a private symbol with an incomplete type was imported and re-exported from a public module.

Bug Fix: Fixed a bug that resulted in incorrect analysis when a ClassVar annotation was enclosed in quotes (i.e. a forward reference).

Bug Fix: Fixed a bug that resulted in a false positive error when a contravariant generic class was specialized with a union type argument used with bidirectional type inference.

Enhancement: Updated typeshed stubs to the latest.

v1.1.273: Published 1.1.273

Compare Source

Bug Fix: Fixed recent regression that resulted in a false positive error related to argument-to-parameter matching.

Enhancement: Added a missing check for class-scoped covariant or contravariant TypeVars that are used in a base class where the base class defines the corresponding type parameter to be invariant. This leads to a typing hole, so it should be considered an error.

Bug Fix: Fixed a bug that led to the incorrect inferred type for a parameter in an unannotated __init__ method in the case where the method overrides a method in a base class.

v1.1.272: Published 1.1.272

Compare Source

Enhancement: Added bidirectional type inference support for comprehension statements that create generators. This addresses https://github.com/microsoft/pyright/issues/3948.

Bug Fix: Improved handling of circular dependencies in a generic class hierarchy — in particular, where a class is parameterized by a constrained TypeVar where one of the constraints includes the class or its ancestors. This addresses https://github.com/microsoft/pyright/issues/3955.

Bug Fix: Fixed false positive reportInvalidTypeVarUse diagnostic in an overload implementation. This addresses https://github.com/microsoft/pyright/issues/3958.

Bug Fix: Fixed confusing error message when a value is written to a class attribute that is not defined on the class but is defined on the metaclass but with an incompatible type. This addresses https://github.com/microsoft/pyright/issues/3960.

Enhancement: Updated typeshed stubs to the latest version.

Enhancement: Improved error message readability for generic class type incompatibilities.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when calling a generic class constructor from within that class implementation. This addresses https://github.com/microsoft/pyright/issues/3927.

Bug Fix: Fixed recent regression. Default includes/excludes should be used when pyproject.toml is present. This addresses #​3965.

Enhancement: Extended support for method override completions that use member access expression forms in a parameter's default value expression. This addresses https://github.com/microsoft/pylance-release/issues/3374.

Bug Fix: Fixed false positive error when a call expression provides zero arguments for an unpacked tuple of indeterminate length within a Callable. This addresses #​3972.

Bug Fix: Improved error message for positional parameter count mismatch when the signature contains an unpacked tuple with either a definite or indefinite length.

v1.1.271: Published 1.1.271

Compare Source

Bug Fix: Fixed a bug in assertNever internal function that resulted in a crash when attempting to stringify a recursive data structure. This shows up occasionally in the crash telemetry.

Bug Fix: Fixed an infinite recursion bug in the type printer that shows up occasionally in the crash telemetry.

Bug Fix: Fixed a bug that resulted in infinite recursion when a global statement is used within the global scope of a module.

Enhancement: Added new check for an attempt to instantiate Dict, Set, List, or Tuple from typing module. This generates a runtime exception.

Bug Fix: Fixed recent regression that resulted in a false positive error when defining a variable in a class body and using its own field name as a type annotation.

Bug Fix: Fixed bug that results in incorrect narrowing for sequence patterns in a match statement in the negative (fall-through) case when the subject type is a tuple of known length but with elements of type Any.

Enhancement: Added support for quoted TypeAlias type annotation.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when narrowing types for class patterns in a match statement when the matched class is a generic subclass of the subject type.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when an isinstance type guard results in an intersection type and one of the sources of the intersection is a conditional type.

Bug Fix: Fixed a bug that resulted in a transient false positive error in certain cases where a member access expression was used within a quoted type annotation.

v1.1.270: Published 1.1.270

Compare Source

Enhancement: Improved precision of error handling for tuple, list and set expressions.

Bug Fix: Fixed a bug that resulted in incorrect type narrowing for literal patterns in a match statement when the target expression type includes an instance of a class that derives from the literal's class (e.g. a subclass of str).

Bug Fix: Fixed a bug that led to the incorrect inferred return type for a super().__new__(cls) call.

Bug Fix: Added support for TypeVarTuple to capture an unpacked tuple with unbounded length.

Bug Fix: Fixed a bug that resulted in unpacked arguments to a class definition going unevaluated, which means that any symbols they referenced were not marked accessed.

Enhancement: Expanded reportUnusedExpression check to detect unused tuple, dictionary, list and set expressions if they don't contain comprehensions.

Bug Fix: Fixed a bug that resulted in a false positive when passing a generic function to an overloaded function that requires union expansion to resolve.

Bug Fix: Fixed type evaluation bug that led to a false positive error when assigning a type conditioned on a bound TypeVar to that same TypeVar in an invariant context.

Bug Fix (contribution by @​timsu92): Fixed incorrect description of reportUndefinedVariable.

Bug Fix: Fixed bug in type evaluator that caused a false negative in some circumstances when constructing an instance of a generic class within that class implementation.

Bug Fix: Fixed a bug that resulted in a false negative when an annotated variable was assigned an expression that included the variable's name and the variable was undefined prior to the assignment.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug in the type checker that led it to conclude that two types were the same even though they were declared in separate modules. This occurred when the types had the same (local) name and both modules were located within project directories that contained characters that are invalid for module paths in an import statement (e.g. "-").

Enhancement: Updated PEP 695 functionality to reflect the latest changes in the spec.

v1.1.269: Published 1.1.269

Compare Source

Bug Fix: Fixed a bug that resulted in the reportImportCycles check to sometimes fail to detect and report some import cycles.

Bug Fix: Fixed bug that resulted in a false positive error when specifying a metaclass that contains an __init__ method with unannotated parameters.

Bug Fix: Fixed a bug that led to a false negative when assigning a concrete type to an instance variable with a generic (class-scoped) type.

Enhancement: Enhanced the type(x) is y type guard logic to support the case where x is typed with a TypeVar bound to a class.

Bug Fix: Fixed a bug that resulted in a false positive error when determining type compatibility of a generic type with an invariant type parameter and a type argument that is a union which includes an instance of a class and an instance of a subclass.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when solving for a contravariant type variable when a union of callables is passed as an argument.

v1.1.268: Published 1.1.268

Compare Source

Behavior Change: Exempted __new__ from parameter covariance check. This is consistent with __init__, which is already exempted from this check.

Bug Fix: Fixed a bug that resulted in a false negative when using an unparenthesized assignment expression in an assert statement. Also improved the error messages and parser recovery for incorrect use of a unparenthesized assignment expressions.

Bug Fix: Fixed a bug that resulted in a false positive when analyzing a call to an instance method that omits a self parameter and instead uses *args.

Enhancement: Improved error reporting for dict literal expressions that are assigned to TypedDict types. Previously, the entire dict literal was included in the error range. Now the range is limited to a specific dictionary entry if there is only one error.

Enhancement: Extended type narrowing support for x in y pattern where y is a tuple of known length that includes literal types. In this case, negative ("else") type narrowing can be applied if x is a union that includes literals.

Behavior Change: Increased the code complexity limit that controls whether pyright performs return type inference for functions that have no parameter type annotations. This can be quite expensive, and without parameter types, the results are often low quality. Beyond a certain point, we just skip the expensive analysis and infer a return type of Unknown. The previous limit was quite low. This increases the limit in an attempt to handle return type inference in more of these cases.

Enhancement: Added a missing check for a **kwargs parameter immediately after a keyword-only separator * parameter. This generates a compiler error in Python.

Enhancement: Updated typeshed stubs to the latest version.

v1.1.267: Published 1.1.267

Compare Source

Bug Fix: Fixed bug that caused error to be suppressed when calling assert_never with bad arguments (incorrect number, etc).

Enhancement: Added support for dictionary expansion of a TypedDict within a dictionary literal expression.

Enhancement: Extended support for union expansion of constrained type variables when performing overload matching.

Bug Fix: Fixed a bug that resulted in different type evaluation behaviors depending on the order of callable types within a union.

Bug Fix: Fixed bug that resulted in a false positive error when the second argument to a type constructor call includes a tuple that includes a type class.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation when a generic type alias consists solely of a type variable or a type variable wrapped in Annotated.

Bug Fix: Fixed bug in parser that resulted in crash when a soft keyword was used as a class pattern keyword argument name.

Bug Fix: Fixed a bug in the special-case logic that handles __all__.extend(<submodule>.__all__) so it better handles the case where <module> is imported using an import statement of the form from x import submodule.

v1.1.266: Published 1.1.266

Compare Source

Bug Fix: Fixed a bug that caused a false positive error when using a list comprehension within a method that is overloaded to accept either a LiteralString or a str. The incorrect overload was chosen in some cases, picking the LiteralString variant rather than the str variant even though LiteralString variant generated type errors.

Bug Fix: Fixed a bug that caused incorrect type evaluation because of stale module paths that are cached for specific source files. Module paths are dependent on the list of configured import resolution paths, so when the import resolution paths change, we may need to recompute the module path for a source file.

Bug Fix: Fixed a bug that resulted in a false negative when a del statement targeted a symbol that was unbound (i.e. referenced before assigned) within a function.

Behavior Change: Changed behavior of assert_type to treat Any the same as Unknown for purposes of type comparison. There is no way to express an Any type explicitly in the Python type system because it is, by definition, an "implicit" Any.

Bug Fix: Fixed a bug that resulted in a false negative when evaluating binary operations that involve unions for either the LHS or RHS or both.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when bidirectional type inference was used along with a type alias that was involved in a circular declaration.

Bug Fix: Fixed a bug that resulted in a false positive error when LiteralString was used as the base type in an index expression.

Behavior Change: Changed the --verifytypes command to skip docstring checks for overloads and for property setters and deleters.

Bug Fix: Fixed a bug that resulted in a false positive when evaluating type compatibility of a type that includes an invariant type argument consisting of a union that contains a generic callable.

Enhancement: Enhanced support for handling of functions that return NoReturn to include support for overloaded functions where some of the overloads return NoReturn and others do not.

Enhancement: Updated typeshed stubs to the latest version.

Enhancement: Added better verbose logging for the case where an import cannot resolve the source file leading to a reportMissingModuleSource diagnostic.

v1.1.265: Published 1.1.265

Compare Source

Bug Fix: Fixed two type evaluation bugs that caused false positive errors when using join method with LiteralString and when a format string is interpreted as a LiteralString.

Bug Fix: Fixed false positive errors that resulted from the previous change to format string type inference.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that led to sporadic false positive errors for expressions that involve a call to super().

Bug Fix: Fixed a bug that resulted in a false positive error when assigning a property created through the @property decorator to a variable or parameter annotated with the type property.

Bug Fix: Fixed a bug that resulted in incorrect bidirectional type inference for constructor calls for generic classes when the expected type was Self.

Bug Fix: Fixed a bug that resulted in a false positive error when using an unpack operator (*) in a quoted type annotation with versions of Python prior to 3.11.

Performance: Improved performance of code flow engine in cases where two variables have significant strong interdependencies and are modified within a loop.

v1.1.264: Published 1.1.264

Compare Source

Bug Fix: Fixed bug in reportUnnecessaryContains check that resulted in a false positive when the container element type is a TypeVar. The same logic error was present (and fixed) in the type narrowing logic for in expressions.

Bug Fix: Fixed bug in reportUnnecessaryComparison check that results in a false positive error when comparison chaining is used.

Bug Fix: Fixed bug that resulted in a false positive error when using a TypedDict that has been narrowed via an assignment to a not-required key.

Bug Fix: Fixed a bug that resulted in incorrect type inference for unannotated parameters with a default argument value in an __init__ method.

Enhancement: Added support for _generate_next_value_ override for Enum class.

Bug Fix: Fixed a bug in the type printer code that resulted in an infinite recursion and crash.

Behavior Change: Changed reportUninitializedInstanceVariable check to exempt protocol classes.

Bug Fix: Fixed a bug that resulted in infinite recursion and a crash when inferring return types for functions that returned another function that also has an inferred return type, etc. in a cycle.

v1.1.263: Published 1.1.263

Compare Source

Bug Fix: Fixed bug that resulted in inconsistent behavior for types inferred from tuple expressions containing literal entries.

Bug Fix: Fixed recent regression that resulted in incorrect type evaluation when a forward-referenced recursive type alias was used as an iterable type.

Bug Fix: Fixed bug that resulted in incorrect type evaluation within case statement in some situations.

Bug Fix: Fixed bug that resulted in sporadic errors when evaluating index expressions within a loop.

Performance: Simplified some internal types, which results in less memory usage and better performance.

Performance: ixed a performance issue (combinatoric explosion) related to TypedDict classes that were narrowed based on a series of in type guard tests.

v1.1.262: Published 1.1.262

Compare Source

Performance: Added a faster code path for testing the type compatibility of a non-union type to a union type when the union type contains no unsolved TypeVars.

Performance: Added optimization in overload path that eliminates one extra validation of arguments in the common case.

Enhancement: Updated typeshed stubs to latest version.

Performance: Implemented tighter scoping for contextual evaluation. This improves performance of type evaluation in various use cases including semantic tokens.

Bug Fix: Fixed bug in type narrowing logic for "in" operator. It was not properly handling the case where the reference (LHS) type was a subtype of the container's element type.

Enhancement: Added support for new reportUnnecessaryContains diagnostic rule to catch potential bugs in in and not in containment checks.

Bug Fix: Changed the validation logic for type argument lists when found outside of a type annotation. The normal type annotation restrictions (such as no dynamic variable usage) should not apply in this case.

Bug Fix: Fixed a bug that caused defineConstants configuration setting not to work with the pyright and pylance VS Code extensions.

Bug Fix: Fixed a bug in the dataclass logic that resulted in incorrect handling of a dataclass field that is annotated both in the class body and (redundantly) in a method within the same class.

v1.1.261: Published 1.1.261

Compare Source

Behavior Change: Reduced the max code complexity constant to lower the cyclomatic complexity threshold for code analysis to prevent crashes with certain highly-complex code.

Bug Fix: Fixed regression that caused an internal assertion (and therefore a crash) when using an expression that includes two index expressions, one with a string literal and one without, like a[n].b.c['x'].

Enhancement: Added support for overloaded __getitem__ in iterables for for statements.

Enhancement: Enhanced the reportIncompatibleVariableOverride check to catch cases where a Final variable overrides a non-Final variable.

Bug Fix: Fixed bug that resulted in sporadic errors during type evaluation based on evaluation order.

Bug Fix: Fixed bug in constraint solver that led to a false positive error in some situations where the solution to a TypeVar involved the union of two other TypeVars.

Bug Fix: Fixed a bug that resulted in an incorrect type evaluation when a generic callable class variable was specialized recursively with type variables for the same class.

Bug Fix: Improved handling of type consistency checks for unions so the results are less dependent on the order of subtypes within the union.

Enhancement: Enhanced reportUnnecessaryTypeIgnoreComment to ignore lines that are unreachable.

v1.1.260: Published 1.1.260

Compare Source

Bug Fix: Fixed regression that caused an internal assertion to fire, leading to a crash when certain forms of nested index expressions are used.

v1.1.259: Published 1.1.259

Compare Source

Enhancement: Enhanced the reportIncompatibleMethodOverride check to handle the case where a method is overridden by an overload and one of the overloads matches the base method.

Performance: Improved analysis performance in cases where variables within a loop have mutual dependencies.

Performance: Added performance optimization for a special case that can occur in code without type annotations. It affects "pseudo-generic" classes that are parameterized recursively.

Performance: Improved analysis performance in some cases by caching return types inferred through call-site inference.

Enhancement: Updated typeshed stubs to the latest version, which eliminates support for Python 3.6.

Enhancement: Added support for type narrowing of TypedDict instances based on assignments to a not-required key.

v1.1.258: Published 1.1.258

Compare Source

Bug Fix: Fixed a bug that resulted in incorrect type narrowing when using an in expression and the LHS operand is of type type. This situation requires some special casing.

Bug Fix: Fixed a bug in the handling of generic type aliases that are parameterized by ParamSpecs in the case where an explicit type argument is not provided. The type argument should default to ... in this case.

Bug Fix: Fixed bug in the expression printer. It was not properly handling a minimal slice (:). This affected certain logging output.

Performance: Added optimization for slice expression evaluation. It can be skipped in cases where the we are speculatively evaluating the type.

Performance: Implemented optimization for type evaluation for index expressions. In cases where there are multiple subexpressions separated by commas, we can skip the check for the __index__ magic method.

Bug Fix: Fixed a bug that resulted in incorrect isinstance type narrowing when one or more of the filter classes was decorated with a class decorator.

Enhancement: Added support for context managers whose __exit__ method is declared to return "Literal[False]". This is now treated the same as if it is declared to return "None".

Performance: Improved performance of type evaluations in certain cases where a union contains multiple types whose class hierarchy contains one or more unknown types.

Bug Fix: Fixed recent regression that resulted in attribution of a type var to the wrong scope when it was used in an __init__ method of a class with a class decorator.

Bug Fix: Fixed bug that results in incorrect type evaluation when a function with a **kwargs parameter is captured by a ParamSpec in certain circumstances.

Bug Fix: Fixed bug that resulted in incorrect type evaluation for values within a TypedDict that derives from a TypedDict that has been specialized.

Bug Fix: Fixed a bug that results in a spurious "argument type is unknown" diagnostic when an unannotated variable used within a loop is also used as the subscript for an index expression.

Bug Fix: Improved handling of incomplete types passed as arguments to magic methods.

Bug Fix: Fixed a bug that resulted in infinite recursion when using auto variance inference with certain recursive types.

Enhancement: Added more complete type validation for __getattr__, setattranddelattr` methods.

Bug Fix: Fixed a bug that resulted in a false positive when resolving a symbol from a multi-part import when a short form of that same multi-part import was also imported.

v1.1.257: Published 1.1.257

Compare Source

Behavior Change: Reverted recent change that resulted in false positive errors when using _ as a placeholder name for methods that are used with @register and similar decorators.

Bug Fix: Fixed regression in isinstance type narrowing when the filter type is a type[x] rather than x.

Performance: Implemented performance optimization related to overload evaluation.

Behavior Change: Changed type_assert diagnostics to fall under reportGeneralTypeIssues diagnostic rule rather than be emitted unconditionally.

Bug Fix: Fixed regression in completion provider by eliminating the recently-added commit characters.

Performance: Improved performance of semantic highlights, hover, and completion suggestions for member access expressions.

Performance: Improved performance in type guard logic by not evaluating a call expression base type until after verifying that the call potentially narrows the reference expression.

Bug Fix: Fixed a bug in the handling of for loops that resulted in incorrect type inference for the target expression.

Bug Fix: Fixed several bugs that resulted in incorrect type evaluations when a property getter or method has an inferred return type that contains a type variable.

Bug Fix: Fixed a bug that resulted in incorrect type evaluation of NewType for versions of python older than 3.8. (In 3.8, NewType was changed from a function to a class.)

Enhancement: Implemented provisional support for proposed PEP 695: Improved Syntax for Type Parameters. The new functionality is available only if you manually configure pyright to assume Python 3.12. It supports the new type parameter syntax, support for "type" statements (for type alias declarations) and support for autovariance.

Enhancement: Updated typeshed stubs to the latest version.

v1.1.256: Published 1.1.256

Compare Source

Enhancement: Improved error message generated when comparing two functions that return TypeGuard return types with incompatible types.

Bug Fix: Fixed false positive that occurs when overriding an abstract method (e.g. a property) with a field from a named tuple when both are used as base classes.

Behavior Change: Moved annotationNotSupported diagnostics under the reportGeneralTypeIssues diagnostic rule so they can be disabled.

Bug Fix: Fixed bug in isinstance type guard logic that resulted in incorrect narrowing when using a dynamic type or types for the second argument.

Bug Fix: Fixed a bug that resulted in a false positive when applying issubclass type narrowing from a type to an abstract class.

Bug Fix: Fixed a few inconsistent behaviors with incompatible redeclaration reporting. In particular, it's now OK to reassign a function if the assigned value is a compatible function. Also tightened up the special-casing for the symbol _, which is allowed to be redeclared only in the case where both declarations are functions (def statements). This exemption is provided for the single dispatch use case.

Bug Fix: Fixed a bug in the handling of dataclass where an existing __eq__ method was being overwritten by a synthesized variant. The same was true for other comparison operators.

Bug Fix: Fixed bug that resulted in a false positive error when handling a generic TypedDict with a literal type argument.

v1.1.255: Published 1.1.255

Compare Source

Bug Fix: Fixed bug that results in a false positive error when evaluating type compatibility of a callable with a *args: Any and **kwargs: Any parameter with a callable that contains a ParamSpec.

Behavior Change: Exempted class members named _ from the "reportIncompatibleMethodOverride" diagnostic check.

Bug Fix: Fixed bug that resulted in missing docstrings on an overloaded method when accessed through a member access expression.

Bug Fix (from Pylance): Auto-import should include import aliases from libraries.

Bug Fix: Fixed a bug that resulted in a false negative when performing protocol matching for a class instance when invariance is enforced.

Enhancement: Added support for overloaded functions that return a TypeGuard or StrictTypeGuard for some overloads.

Bug Fix: Changed heuristics in TypeVar constraint solver to handle a TypeVar bound to LiteralString and allow literal types to be retained when solving for this TypeVar.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that resulted in a false negative when assigning a union of tuple[Any] | tuple[int] to an incompatible type.

v1.1.254: Published 1.1.254

Compare Source

Enhancement (from Pylance): Use new detail description feature added in 3.17 LSP to show full module path for auto import.

Bug Fix (from Pylance): Make sure file watcher treats a zip file as a file not folder.

Enhancement: Added code to detect and flag usage of # type: xxx comments for for and with statements.

Enhancement: 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.

Bug Fix: Fixed bug that resulted in a false negative when attempting to call pop on a TypedDict with a key that is required.

Enhancement: 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.

Bug Fix: Fixed a bug that resulted in a false negative when a variable with a declared type is overwritten by an incompatible type by an import statement.

Enhancement: Added code to print the pyright version as part of the CLI output. This is useful for diagnosis.

Bug Fix: Undid previous fix related to circular class dependency detection because it introduced a regression with sqlalchemy stubs. Implemented a different solution to detect circular class dependencies and handle them correctly.

Bug Fix: Changed the handling of partial stub packages to conform with PEP 561. They should always overlay the original package even if that package is marked "py.typed".

Bug Fix: Fixed bug in tokenizer that results in incorrect tokenization when a hex numeric literal is followed by a newline followed by either a 'b' or 'o' character.

v1.1.253: Published 1.1.253

Compare Source

Bug Fix: 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.

Bug Fix: Fixed bug in "--dependencies" command-line option. When used with partial stub files, it was not emitting the correct paths.

Bug Fix: 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.

Bug Fix: 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.

Enhancement: 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.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: 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.

Bug Fix: 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.

Bug Fix: 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.

Bug Fix: 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.

Bug Fix: 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.

v1.1.252: Published 1.1.252

Compare Source

Bug Fix: Fixed a false positive error when the special form Unpack is used in a context other than a type annotation.

Bug Fix: Fixed bug that resulted in a crash (due to infinite recursion) in reference provider under certain circumstances involving symbol renames.

Enhancement: 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.

Behavior Change: 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.

Bug Fix: Fixed bug in lambda type evaluation so it properly detects and reports when its type is incomplete due to recursion.

Bug Fix: Fixed regression in code flow analysis that depends on NoReturn call evaluation.

Bug Fix: Improved handling of calls to overloads that return NoReturn. If all overloads are annotated with NoReturn, the call is now evaluated as NoReturn. Previously, only the last overload was considered.

Bug Fix: 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.

Bug Fix: 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.

v1.1.251: Published 1.1.251

Compare Source

Bug Fix: Fixed a bug that results in a false positive when the return type annotation of a function requires code flow analysis to evaluate and a call expression is located on a code path between the function and the declared type referenced by the return type annotation. The fix is to skip "NoReturn" analysis in the code flow engine in this case (and several other similar cases) because it's not necessary. This has the added benefit of improving performance.

Bug Fix: Fixed misleading diagnostic message associated with reportUnnecessaryComparison check when != operator is used in the expression.

Bug Fix: 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.

Enhancement: Improved type verifier so it can target submodules that are installed using an editable install mechanism.

Performance: 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.

Performance: 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.

Bug Fix: Fixed bug in type narrowing logic for expressions of the form "X not in Y".

Bug Fix: Fixed a bug in the isinstance and issubclass type narrowing code paths. They were not handling nested tuples for the second argument.

Enhancement: Extended the "X in Y" type narrowing to support dict, defaultdict and OrderedDict classes.

Bug Fix: Fixed bug that resulted in a false positive error when using == or != operator with type(None).

Bug Fix: Fixed a bug that led to a false negative in some instances when assigning an inappropriate type to a TypedDict key.

Bug Fix: 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.

Bug Fix: Fixed a bug in completion provider that resulted in incomplete member suggestions when a LiteralString type is used.

Bug Fix: 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.

v1.1.250: Published 1.1.250

Compare Source

Behavior Change: Removed the assumption that deferred evaluation of annotations is enabled by default in Python 3.11. It looks like this won't be the case.

Bug Fix: Fixed bug that resulted in false negative when using a variable in a type annotation if the type of that variable evaluated to Unknown.

Bug Fix: Fixed bug in code flow engine that caused type narrowing to fail in some cases where a conditional check was nested at least two loops deep.

Enhancement: Enhanced TypedDict support in completion provider to support unions that contain TypedDicts.

Bug Fix: Fixed bug that resulted in false negative when dunder methods are assigned as instance variables rather than class variables.

Bug Fix: Fixed bug that caused __slots__ entries to be treated as instance variables rather than class variables when looking up dundered methods.

Bug Fix: Fixed a bug that led to a false positive error when using a variable or parameter of type type[T] in a class pattern for a case statement.

Bug Fix: Fixed bug that resulted in a false negative when assigning a union that included an Unknown or Any to another type when invariance was enforced (e.g. list[Any | str] was considered assignable to list[int]).

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed bug that resulted in incorrect type evaluation for a recursive call to a generic function.

v1.1.249: Published 1.1.249

Compare Source

Bug Fix: Fixed bug that resulted in incorrect type evaluation of a specialized type alias when the type argument contained a literal type. The literal was incorrectly widened to its non-literal form.

Bug Fix: Fixed bug that resulted in the incorrect type evaluation of member access expressions where the base type is type(None) (i.e. the NoneType class).

Enhancement: Enhanced the reportInvalidTypeVarUse check to report cases where a TypeVar found within a return type may go unsolved because it appears only within input parameters that have default argument values specified as .... In this situation, it is recommended that an overload is provided that specifies the return type when the default argument value is used by a caller.

Bug Fix: Fixed bug that resulted in a false positive when assigning a function or callable containing position-only parameters to a callable with a TypeVarTuple.

Bug Fix: Fixed bug that caused docstrings to be truncated to 32 characters when generating stubs.

Enhancement: Enhanced reportInvalidTypeVarUse to detect cases where a constructor (__init__ method) includes class-scoped TypeVars that may go unsolved because they are associated only with parameters that have default argument values.

v1.1.248: Published 1.1.248

Compare Source

Enhancement: Added more complete validation of types used within a PEP 604-style union. Previously, the use of a P.args or P.kwargs type was not flagged as an error as it should be.

Bug Fix: Fixed bug that resulted in a false positive error when an await keyword was used with an operand that evaluated to a bound type variable.

Bug Fix: Fixed a bug that resulted in a false positive when using *args or **kwargs within a class argument list.

Enhancement: Improved special-case code for functools.totalordering so it enforces the operand type in the provided __lt__ method.

Bug Fix (from pylance): Honor the "hasWatchFileRelativePathCapabilities" of the client and don't use this facility if it's unsupported.

Bug Fix: Fixed a bug that caused dataclass_transform to fail when used on an overloaded function if it was not applied to the first overload.

Enhancement: Improved parse recovery for member access expressions that are missing the member name. This allows completion suggestions to work when a member access expression is used within a list comprehension.

Behavior Change: Changed reportInvalidStubStatement rule so it doesn't complain about call and augmented assignment expressions that perform allowed manipulations of the __all__ symbol.

Bug Fix: Fixed false positive type error that occurred when evaluating a call to a generic function parameterized with a ParamSpec and called within a loop construct.

Bug Fix: Fixed a bug that resulted in inconsistent type evaluation for a captured variable within a lambda or inner function when found within a loop.

Behavior Change: Updated dataclass_transform to support parameter name field_specifiers, which replaces the older parameter named field_descriptors. For now, we'll support both to retain backward compatibility with libraries that shipped with the older form.

Bug Fix: Fixed a bug that affected type evaluation of member access expressions when the LHS was a dataclass (or dataclass-like) class and the member was a field declared as a descriptor type.

Bug Fix: Fixed regression that resulted in a false positive error when checking for incompatible method overrides when the method contained local TypeVars.

Bug Fix: Fixed false positive "code too complex" error caused by a recent regression.

Bug Fix: Fixed bug in completion provider where it was emitting four spaces rather than using the predominant tab sequence when generating a multi-line completion suggestion for a method override.

Bug Fix: Fixed bug that resulted in a false positive error when using a super() call to invoke a constructor with a default argument value and a parameter that is annotated with a TypeVar.

Bug Fix: Fixed bug that resulted in incorrect type evaluation for a property access within a class when that property's getter has a generic return type.

Enhancement: Updated typeshed stubs to the latest version.

v1.1.247: Published 1.1.247

Compare Source

Bug Fix: Fixed bug in symbol resolution when a symbol is associated with a class scope but not yet assigned a value. In this case, the runtime looks in the global (module) scope for the symbol rather than following the normal scope hierarchy.

Bug Fix: Fixed a bug that led to a false negative when calling a Callable callback with a generic parameter and passing a non-generic argument.

Bug Fix: Changed the behavior of the type evaluator for generic functions and constructors where a TypeVar is unsolved. Previously, the TypeVar was "leaked". Now it is transformed into an "Unknown" type.

Performance: Added small performance and memory optimization in binder that avoids some extra work related to member access expressions.

Performance: Added code to detect execution flows with long straight-line code flow graph segments. This is not captured in the cyclical code complexity calculations that we normally use to determine if code is too complex to analyze.

Enhancement: Improved handling of context managers that swallow exceptions. The type of the context manager is now evaluated using the full type analyzer. The previous technique used some special-case handling which covered about 95% of the cases but left some cases unhandled.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Adjusted heuristics for TypeVar constraint solver to better handle the case where a union is assigned to a union of TypeVars and the number of subtypes in these two unions is the same.

Bug Fix: Fixed a bug that resulted in a false negative when doing protocol matching with a generic class that calls its own constructor.

v1.1.246: Published 1.1.246

Compare Source

Bug Fix: Fixed a bug in the reportUninitializedInstanceVariable check that results in a false positive error with TypedDict classes.

Bug Fix: Fixed a bug in the logic for synthesizing __init__ methods within a dataclass when a __slots__ definition is present. It was using the order of the slots entries rather than the order of the field declarations.

Enhancement: Added new verbose output for CLI when combined with '--stats' that outputs the total analysis time of each source file. This will help us narrow down performance problems.

Enhancement: Added check for an attempt to overwrite a method that is marked @final.

Bug Fix: Fixed a bug that resulted in a false positive reportUnknownVariableType diagnostic when using from .A import B statement. The symbol A was flagged as an "unknown" type even though it is not a symbol within the module's symbol table (unless the file is an __init__.py[i]).

Enhancement: Updated typeshed stubs to the latest.

v1.1.245: Published 1.1.245

Compare Source

Enhancement (from pylance): Added completion support for class variables inherited from a parent class.

Bug Fix: Fixed a bug that resulted in a stack overflow in rare cases where an unannotated decorator was used on hundreds of functions or methods within the same file.

Enhancement (from pylance): Improved completion suggestions for dict key names within an fstring expression. Double or single quotes are now chosen to avoid conflicting with the outer fstring quote type.

Bug Fix: Fixed bug that resulted in false positive error when using a member access expression within a list of base classes in a class declaration statement.

Behavior Change: Changed the heuristics in the TypeVar constraint solver to preserve literals when solving for a TypeVar in a Callable return type in cases where the source function has a declared return type with a literal annotation in it. It doesn't apply in cases involving an inferred return type or generic types that are specialized with literals.

Bug Fix: Fixed a bug in the reportUninitializedInstanceVariable check that results in a false positive when used with a dataclass or dataclass-like class. Seemingly-uninitialized class variables are implicitly overwritten by the synthesized __init__ method in a dataclass.

Performance: Fixed performance issue that occurred in certain situations involving deeply nested loops and many unannotated variables that are dependent on each other.

Enhancement: Added support for generic TypedDict classes.

v1.1.244: Published 1.1.244

Compare Source

Bug Fix: Fixed bug that resulted in a false positive when a callback protocol used a method-scoped ParamSpec in its __call__ method.

Enhancement: Improved error message for a call expression that uses a named argument when the target callable has no such named parameter.

Enhancement: Enhanced the reportUninitializedInstanceVariable check to detect cases where a class variable is declared but not initialized in the class body and no instance variable of the same name is assigned in the __init__ method.

Bug Fix: Fixed bug that resulted in the incorrect inferred type for an exception group that results when using a Python 3.11 except* statement.

Bug Fix: Fixed a bug that resulted in a crash when overflowing the type cache. It is implemented with a Map, which has a limit of 2^24 entries. The fix is to empty the cache if we approach this limit.

Bug Fix: Changed heuristic for type matching when source is a concrete type and destination is a union of that type and a TypeVar. The old heuristic attempted to solve the TypeVar, but the new heuristic leaves it unsolved. This eliminates a false positive error in certain edge cases and more closely matches the behavior of mypy in this case.

Bug Fix: Fixed bug that resulted in incorrect type analysis for dataclasses when a field declaration was within a conditional block.

Enhancement: Added support for generic NamedTuple classes, which are now supported in Python 3.11.

Bug Fix: Fixed bug that resulted in incorrect type evaluation of a dictionary key when assigning a dictionary expression to a dict with a generic key type.

Enhancement: Improved error message for incompatible field types in a TypedDict.

Enhancement: Added basic support for generic TypedDict classes, which are supported in Python 3.11. Assignment to a specialized generic TypedDict is now supported, but support for TypeVar solving is not yet in place.

v1.1.243: Published 1.1.243

Compare Source

Bug Fix: Fixed bug that resulted in incorrect type evaluation when referencing a descriptor object that is stored as an instance variable.

Bug Fix: Fixed a bug that resulted in incorrect import resolution in a library that you are debugging locally if that library is also installed in the current Python environment and the library includes stub (".pyi") files.

Bug Fix: Fixed a bug that resulted in false positive errors during protocol matching when a generic protocol derives from another generic protocol.

Bug Fix: Fixed a long-standing bug in protocol matching where results were evaluation-order-dependent in cases where a generic source class included a method with an inferred return type that was dependent on one or more TypeVars. If the return type was not inferred and cached prior to protocol matching, it was improperly specialized.

Enhancement: Added check for illegal use of ClassVar within a TypeAlias declaration.

Bug Fix: Fixed a bug that resulted in a false positive error when performing protocol matching with a property whose getter included a custom type annotation for its self parameter.

Bug Fix: Fixed a recent regression that broke list and dictionary inference in cases where bidirectional type inference was used with an expected type that included a TypeVar that was bound to a literal type or a union of literals.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when function return type inference resulted in various recursive cases.

Bug Fix: Fixed long-standing bug that resulted in incorrect code flow analysis and type evaluation when handling some forms of NoReturn calls. There are still some limitations though; for example, it doesn't handle overloaded functions that return NoReturn for some argument lists.

v1.1.242: Published 1.1.242

Compare Source

Performance: Improved performance of import cycle check by adding caching.

Enhancement: Removed limitation that Literal must be imported directly from typing or typing_extensions. It can now be re-exported from another library, although analysis performance will suffer a bit in that case.

Enhancement: Improved error message for CLI version of pyright when it is passed a file that is not a Python source file.

Bug Fix: Fixed bug that resulted in infinite recursion and a crash in rare circumstances involving a self parameter annotation that referred to its own class.

Bug Fix: Fixed a bug that resulted in inconsistent type evaluation depending on evaluation ordering when a parameter or return type annotation involved a | (union) operator.

Bug Fix: Fixed bug that resulted in wrong ordering of type parameters in a generic protocol if Protocol[...] was meant to specify an explicit ordering, similar to the way Generic[...] specify an explicit ordering.

Bug Fix: Fixed bug that led to inconsistent type evaluation results when the code flow engine determined that an expression was unreachable. The results differed depending on whether there was a branch between the expression and point of the graph that was unreachable.

Bug Fix: Fixed bug in stub generator that resulted in code that was syntactically incorrect when an index subscript contained an extra "hanging" comma.

Bug Fix: Fixed a bug in the stub generator logic that produced syntactically incorrect code when the source file contained a function with a position-only separator in its signature.

Bug Fix: Fixed a bug that led to a false positive "reportOverlappingOverload" error when the return type of two overlapping overloads both used a generic return type.

Enhancement: Extended type guard for discriminated literal fields to support properties.

Bug Fix: Fixed bug in expression printer for lambda expressions. It was not properly printing a position-only separator.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when using a generic type alias with an instantiable class (as opposed to a class instance) when the TypeVar used within that type alias was bound to a type[x].

Enhancement: Updated typeshed stubs to the latest version.

v1.1.241: Published 1.1.241

Compare Source

This is a quick-spin release that addresses two regressions introduced in the previous release:

Bug Fix: Fixed regression in "reportUnnecessaryComparison" diagnostic check that resulted in false positives when the LHS or RHS evaluated to Never.

Bug Fix: Restored compatibility with node 12.x. A dependency was updated in the previous build that assumed node 14 or newer, resulting in a crash when running on older versions of node.

v1.1.240: Published 1.1.240

Compare Source

Enhancement: Enhanced reportIncompatibleMethodOverride check to detect cases where a staticmethod, classmethod or instance method override a method that doesn't match in that regard.

Bug Fix: Added check for complex code blocks (that contain hundreds of if/elif statements within loops). These now emit an error rather than resulting in tens of seconds of compute.

Bug Fix: Fixed bug that resulted in combinatoric explosion within a union when using literals in an augmented assignment. This led to crashes in extreme cases.

Bug Fix: Added limit to the number of recursive function return type inference operations that can be pending concurrently. Theoretically, this could be arbitrarily deep, which will eventually overflow the call stack and crash. Such a crash is showing up in the pylance telemetry. We now limit it to 16 levels deep to prevent this crash.

Bug Fix: Fixed a bug that resulted in the incorrect type evaluation for a member expression when the LHS type was a Type[T] type.

Bug Fix: Fixed bug that caused a crash when the setter for a descriptor class had only two parameters and was used in a class variable for another class.

Performance: Implemented small perf improvements to core union functions, which are hot paths in the type analyzer.

Bug Fix: Fixed a bug that resulted in false negative errors during protocol matching when a method within the protocol contained a keyword-only parameter annotated with a class-scoped TypeVar.

Bug Fix: Fixed bug in type evaluator that resulted in an errant Unknown type when evaluating a dependent variable assigned through a tuple within a loop.

Bug Fix: Fixed bug in code flow engine that results in infinite recursion and a stack overflow under certain circumstances.

Bug Fix: Fixed bug that resulted in inconsistent behavior when a TypeVar was used as the value for a magic method and was explicitly or implicitly set to Any or Unknown.

Bug Fix: Fixed a false positive error related to __slots__ usage within a dataclass.

Bug Fix: Fixed bug in static expression evaluator that resulted in incorrect evaluation when using the not unary operator.

Bug Fix: Improved type evaluation for expressions that are determined to be unreachable. Such code should evaluate to the type Never and never generate errors or warnings.

v1.1.239: Published 1.1.239

Compare Source

Enhancement: Updated typeshed stubs to the latest.

Bug Fix: Fixed bug that resulted in an infinite loop when a reference to a generic function was passed to itself as an argument.

v1.1.238: Published 1.1.238

Compare Source

Bug Fix: Fixed a bug that generated a false positive when importing from a "py.typed" namespace package. This change also loosens the requirements for a "py.typed" file to be in each of the submodules within a namespace package; a single "py.typed" within the top-level namespace directory is also now supported.

Enhancement: Improved error message for protocol mismatch due to invariance of mutable attributes.

Bug Fix: Fixed bug in type evaluation of a generic type alias that refers to a generic Callable and is missing explicit type arguments. The type argument should implicitly be Unknown in this case.

Enhancement (contribution from Robert Craigie): Add support for showing key on hover for unions of TypedDicts.

Bug Fix: Fixed recent regression that broke the --watch mode of the cli version of pyright.

Bug Fix: Fixed an infinite recursion crash that occurs within the code flow engine in rare circumstances.

Bug Fix: Fixed bug that resulted in a false positive error when assigning certain value types to a property's setter.

Bug Fix: Fixed a bug that resulted in a false negative when solving for a ParamSpec. The type analyzer wasn't generating an error when multiple assignments to a ParamSpec were incompatible.

Bug Fix: Fixed bug in constraint solver logic that resulted in a crash in certain edge cases.

Bug FIx: Fixed bug that resulted in incorrect type evaluation in cases where a decorator returned a generic Callable[[U], U] and this decorator was applied to a function with one or more parameters that were typed with a union that included a "raw" type variable, such as func(x: T | list[T]).

v1.1.237: Published 1.1.237

Compare Source

Bug Fix: Fixed recent regression that results in a false positive when evaluating *P.args and **P.kwargs argument types passed to a function within a nested inner function.

Bug Fix: Fixed bug that resulted in false positive with the reportOverlappingOverload diagnostic check when a parameter in one overload is annotated with type or Type[Any] and the corresponding parameter in another overload is annotated with Any.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when an import statement failed to resolve and targeted a submodule of a previous import statement, such as import a.b followed by import a.b.c where a.b.c couldn't be resolved. In this circumstance, pyright "forgot" that a.b had been resolved previously, so all symbols imported from a.b were evaluated as Unknown.

Enhancement: Enhanced reportUnnecessaryComparison diagnostic check so it also detects cases where a function appears within a condition expression. This is a common source of programming error.

Bug Fix: Fixed bug that resulted in a false positive error when validating the variance of a type variable used within a protocol class. It specifically affected the case where a TypeVar was used in the return type of a read-only property.

Bug Fix: Fixed a bug that resulted in a false negative when validating arguments to a function that uses a specialized TypeVar within an unpacked tuple as an *args parameter type.

Enhancement: Expanded the reportUnknownVariableType check to cover some cases that it didn't previously. It now handles unknown or partially-unknown symbols imported from from a import b statements, unpacked assignments, with a as b statements, and more.

Bug Fix: Fixed a bug that resulted in a runtime assertion (and crash) when dealing with return expressions that involve more than one constrained TypeVar.

v1.1.236: Published 1.1.236

Compare Source

Performance: Improved performance of code flow analysis.

Bug Fix: Fixed inconsistency in type printer when outputting a callable with an Optional return type.

Bug Fix: Fixed bug that resulted in incorrect "unreachable code" when a match statement contained a guard expression that statically evaluates to True.

Bug Fix: Fixed a bug that caused a false negative with the reportMissingTypeArgument check when used with a member access expression where the LHS is a module.

Bug Fix: Fixed false negative when a class variable of type type[T] is specialized to type[Any] and then assigned a value in a base class that is not compatible with type[Any].

Bug Fix: Fixed a type evaluation bug that occurs when a constructor uses a class-scoped ParamSpec and uses *args: P.args and **kwargs: P.kwargs parameters.

Bug Fix: Added exception handling to recover from errors thrown by the YarnFS (zip handling library).

Bug Fix: Fixed regression that resulted in an incorrect Unknown type evaluation for a variable within a loop.

Bug Fix: Fixed a recent regression that resulted in incorrect type evaluation within a loop with dependency chains between variables.

Enhancement: Updated typeshed stubs to the latest.

Bug Fix: Fixed a bug related to specialization of a generic class that uses ParamSpec when the type argument corresponding to the ParamSpec is unspecified. In this case, the ParamSpec should receive a "default" signature (*args: Any, **kwargs: Any) — the ParamSpec equivalent of Any.

Bug Fix: Fixed a bug that resulted in a false negative in the type consistency checks for functions with a ParamSpec.

Bug Fix: Fixed a bug that resulted in a false negative when calling a function that includes a ParamSpec from within an inner function. The code was not verifying that *args and **kwargs with the appropriate ParamSpec type were passed as arguments.

Bug Fix: Fixed bug that resulted in a false negative when dealing with a mutable instance or class variable in a Protocol class. Such variables need to be treated as invariant when performing protocol compatibility checks.

v1.1.235: Published 1.1.235

Compare Source

Performance: Fixed a performance regression that manifested when analyzing a large dictionary literal statement with a declared type.

Enhancement: (Contributed by Robert Craigie) Show TypedDict key type and docstring on hover.

Behavior Change: Updated logic for dataclass_transform to handle recent clarification in PEP 681 for cases where one or more overloads are decorated with dataclass_transform.

Enhancement: (Contributed by Kevin Coffey) Added support for type guard based on a.b is None or a.b is not None patterns where b is a member variable that distinguishes two different classes.

Enhancement: (Contributed by Robert Craigie) Add support for going to definition for TypedDict keys.

Behavior Change: Changed hover provider to display (property) rather than (method) if the field is decorated with a descriptor object.

Enhancement: Changed logic for hover and completion providers to support docstrings for general descriptors rather than just properties.

Enhancement: Made synthesized get method in TypedDict classes a bit smarter. If a field is required, the default parameter's argument (or None if no default argument is provided) is ignored because the type will always come from the required field. If the TypedDict class is marked @final, any literal key name that is not part of the class will always return the type of the default argument (or None if no default argument is provided).

Bug Fix: Fixed bug that could theoretically account for some of the remaining stack overflows that we're seeing in the pylance telemetry.

Bug Fix: Fixed bug in the package type verifier where it incorrectly flagged an assignment to a descriptor member within a child class as an ambiguous override of that member.

Bug Fix: Changed the way pyright detects high memory usage and decides to empty its internal type cache.

Performance: Added perf enhancement to improve analysis times for complex unannotated code. Lowered complexity threshold for call-site return type inference and skipped argument expression evaluation for call expression when base call expression type is unknown.

Performance: More performance optimizations for complex unannotated functions. Don't evaluate argument or subscript expressions if base type of call expression or index expression is incomplete.

Enhancement: Updated typeshed stubs to latest.

v1.1.234: Published 1.1.234

Compare Source

Performance: Fixed bug that resulted in long analysis times when using call-site type inference for very complex functions that have no parameter annotations.

Behavior Change: Removed support for transform_descriptor_types parameter in dataclass_transform, a feature that was determined to be not necessary. Added support on normal dataclass handling for field types that are custom descriptor objects.

Bug Fix: Fixed bug in logic that determines whether to empty the in-memory type cache if it has the potential to overflow the heap.

Enhancement: Improved printing of string nodes in error and log messages. If the string node is long, it is truncated to 32 characters.

Enhancement: Improved textual form of string literal types. If the string literal is very long (>50 characters), it is truncated.

Bug Fix: Fixed recent regression that caused the "--verifytypes" feature to incorrectly report that the "self" parameter of a @property method as unannotated.

Performance: Removed older mechanism for tracking "incomplete types" — those that have been partially evaluated within a code flow loop. The older mechanism is no longer needed. Removing this is a big performance win in some (typically more complex) pieces of code.

Performance: Fixed performance issue that caused long analysis times in some complex unannotated functions when attempting to infer whether the function was a NoReturn return type.

Performance: Improved performance of code flow "reachability" analysis.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed false positive error in "unreachable exception" detection code when the exception was typed as Type[Exception].

Enhancement: Contributed by Kevin Coffey - Extended a[I] is None type narrowing logic to handle subtypes of Tuple including NamedTuple.

v1.1.233: Published 1.1.233

Compare Source

Behavior Change: When hovering over the LHS of an augmented assignment (e.g. the a within a += x), reveal the type of the symbol after the operation rather than before.

Enhancement: Updated the reportUnusedExpression check to also report diagnostics for a simple name expression as a standalone statement.

Bug Fix (from pylance): Fixed several bugs related to "Rename Symbol" command and improved performance in some cases.

Bug Fix: Fixed crashing bug due to stack overflow when traversing the code flow graph.

Behavior Change: Modified algorithm for calculating the complexity of a function's code flow. If the complexity exceeds a certain threshold, pyright will not attempt to analyze the code.

Bug Fix: Fixed a bug that resulted in incorrect import resolution when the import referenced an empty directory within the stubspath. It should continue searching for imports in other locations in this case.

Bug Fix: Fixed regression that caused false positive error when protocol match involved a property that returned a type that was generic.

Bug Fix: Fixed bug that resulted in a false negative when assigning an invariant type var was specialized with a protocol type.

Bug Fix: Fixed several bugs relating to type evaluation within loops. This is a significant change to the code flow engine logic.

v1.1.232: Published 1.1.232

Compare Source

Enhancement: Improved diagnostic messages for overload implementation mismatch.

Bug Fix: Fixed bug that resulted in false negative when assigning one function to another and the dest contains named positional arguments that have no corresponding positional slot in the dest and the dest does not contain a **kwargs.

Bug Fix: Modified the special-case logic for property so it exposes methods and attributes provided by object.

Bug Fix: Improved the reportIncompatibleMethodOverride check to report a diagnostic if the base method provides a default argument value for a parameter but the override does not.

Behavior Change: Lowered cyclical code complexity threshold for code flow analysis in an attempt to reduce stack overflow crashes.

Bug Fix: Fixed a false positive error relating to __slots__ when using a descriptor object that was assigned to a class variable in a base class.

Enhancement: Updated typeshed stubs to the latest version.

Enhancement: Added support for new assert_type call, which is being added to Python 3.11 and typing_extensions.

Bug Fix: Fixed false positive error that occurs when assigning a class variable with a type annotation an expression that involves the name of the class variable symbol.

Bug Fix: Improved modeling of property class so its fget, fset, fdel, __get__, __set__ and __delete__ methods are updated properly when adding a setter or deleter.

Bug Fix: Fixed bug that resulted in false positive when overriding a method with position-only parameters when the base uses the old-style mechanism and the override uses the new-style / separator or vice versa.

v1.1.231: Published 1.1.231

Compare Source

Behavior Change: Moved a couple of type-related diagnostics under the reportGeneralTypeIssues diagnostic rule rather than reporting them unconditionally.

Bug Fix: Fixed false negative for the reportIncompatibleMethodOverride diagnostic check. It was not detecting the case where the base method used keyword parameters but the override method used position-only parameters.

Bug Fix: Fixed bug that resulted in a false positive error when matching a module against a specialized generic protocol class.

Bug Fix: Fixed a bug that resulted in misleading output when printing the type of a generic alias that includes a generic function parameterized by a ParamSpec and is later specialized.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when a generic type alias parameterized with a ParamSpec was specialized multiple times.

Bug Fix: Fixed bug in "--verifytypes" feature. It was ignoring a missing parameter annotation for the first parameter in a non-method function.

Bug Fix: Fixed a bug that resulted in a false positive error when a generic callback protocol was passed as an argument to another generic callback protocol.

v1.1.230: Published 1.1.230

Compare Source

Bug Fix: Fixed a bug that resulted in a false positive "reportMissingParameterType" error when using an old-style double underscore parameter name to indicate position-only parameter.

Bug Fix: Handled the special case where an Any expression is bound to a ParamSpec giving it default parameters.

Bug Fix: Fixed bug that resulted in a false positive error when using a dictionary unpack operator ** with an instance of a class that satisfied the SupportsKeysAndGetItem protocol but did not directly derive from Mapping.

Enhancement: Added new diagnostic check reportUnusedExpression to catch bugs like a == 4 when a = 4 was intended.

Enhancement: Added special-case logic for a Type[T] (where T is an unbound TypeVar) that is instantiated through a call to its constructor. It should evaluate to T rather than Any.

Bug Fix: Fixed bug in pattern exhaustive match logic that failed to detect exhaustive match when the subject expression was a unnarrowable expression form.

Bug Fix: Improved the heuristics in the alias resolution logic to prefer declarations that are in non-exception paths even if the exception path has a typed decl and the non-exception decl must be inferred.

Bug Fix: Fixed two bugs that generated false positive errors when using PEP 604 union syntax in an implicit type alias. The first bug affected the case where the union started with None. The second affected the case where a TypeVar was included in the union.

Enhancement: Updated typeshed stubs to the latest.

Bug Fix: Fixed bug that resulted in false positive reportIncompatibleVariableOverride error when one base class defined a symbol as a property and another base class defined a symbol as Any.

Enhancement: Added support for the use of Concatenate as a type argument for a generic type alias that accepts a ParamSpec.

v1.1.229: Published 1.1.229

Compare Source

Bug Fix: Fixed a bug that caused semantic highlighting to sometimes skip information for certain tokens involved in member access expressions.

Enhancement: Added checks for incompatible variable types for same-named instance or class variables in two base classes.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that led to misleading type error messages and hover text when a type with an associated generic type alias was specialized. The underlying generic type was properly specialized, but the type alias itself appeared to be unspecialized still. Since the type alias is displayed in error messages and hover text, this was confusing.

Bug Fix: Fixed a bug where classes that derive from Any are not allowed to be assigned to a TypeVar. This resulted in a false positive error when returning NotImplemented in a function that is annotated to return a TypeVar.

Bug Fix: Fixed a bug that resulted in a false positive error "variable not in slots" when a value was assigned to a class variable that is a descriptor.

Bug Fix: Fixed a bug in the __post_init__ validation logic that resulted in a false positive when a dataclass with an InitVar derives from another dataclass with an InitVar.

Enhancement: Added support for per-line suppression of diagnostics using # pyright: ignore comment. This also supports rule-specific suppression using a list of diagnostic rules, as in # pyright: ignore [reportGeneralTypeIssues].

Bug Fix: Fixed a bug in the reportUnnecessaryComparison diagnostic rule that resulted in false negatives when one of the two operands included a None in the type.

Bug Fix: Fixed a bug that resulted in a false positive error when testing type compatibility of an invariant type argument that consists of a union of types, some of which are subtypes of each other.

v1.1.228: Published 1.1.228

Compare Source

Bug Fix: Improved "reportUnnecessaryComparison" diagnostic check so it catches more cases.

Performance: Fixed performance bug that was causing a significant slowdown when evaluating highly nested call expressions especially when there are argument errors in the innermost expressions.

Enhancement: Extended support for narrowing of index expressions to include those with negative subscripts, such as a[-1]. This is supported for all supported type guard patterns.

Bug Fix: Fixed bug that resulted in a false positive error when using typing.Self in an inner function defined within an outer method.

Enhancement: Added negative type narrowing support for sequence patterns in match statements.

Bug Fix: Fixed a bug in negative type narrowing for class patterns in match statements when the class in the class pattern is one of the designated "special built-in classes" specified in PEP 634 and a class argument is specified.

Bug Fix: Fixed a bug that resulted in incorrect TypeVar resolution when the TypeVar was used in a Type[T] type expression, was constrained, and two of the constraints overlapped in type.

Bug Fix: Fixed an edge case in the code flow engine that theoretically could result in incorrect type evaluation.

Bug Fix: Fixed a bug in the code flow engine that resulted in inconsistent type evaluation depending on order of evaluation in some cases where a variable is modified in a loop.

Bug Fix: Fixed bug that resulted in a stack overflow when evaluating unions with large numbers of subtypes.

v1.1.227: Published 1.1.227

Compare Source

Enhancement: Extended conditional types to function and constructor calls where one or more arguments is a conditional type.

Bug Fix: Fixed a bug that resulted in incorrect type inference when assigning () to a variable with an explicit type declaration of tuple[()].

Bug Fix: Fixed bug that results in incorrect type evaluation when an if statement is not paired with an else and the condition expression uses a not paired with an and or or.

Bug Fix: Fixed bug that caused a class that derives from NamedTuple to not conform to the Hashable protocol.

Behavior Change: Changed override detection to always use an overload implementation if present.

Behavior Change: Fixed bug that caused symbols in unreachable code to be ignored in "Rename Symbol" and "Find all References" operations.

Bug Fix: Fixed bug that resulted in a false positive when cls was used as an argument to a dynamic type creation call.

Enhancement: Improved error message for overload that doesn't match its implementation.

Bug Fix: Added code to avoid an attempt to analyze a function if its code flow complexity is too high. This reduces the likelihood of a stack overflow within the type evaluator. If a function or module is too complex, a diagnostic is now emitted to tell the developer that full analysis is suspended for that execution scope.

Bug Fix: Improved reportIncompatibleMethodOverride diagnostic check, including fixes for a few false positives and false negatives and improvements to diagnostic messages.

v1.1.226: Published 1.1.226

Compare Source

Bug Fix: Improved parser to detect extremely deep chains of call expressions that can crash the type evaluator.

Bug Fix: Fixed bug that resulted in false positive error when detecting overlapping method overloads when the overloads use a class-scoped TypeVar.

Bug Fix: Fixed a bug that resulted in a false positive error when validating type compatibility between two functions with nested Concatenate and ParamSpec usage.

Bug Fix: Fixed a bug in the code flow graph relating to "with" statements that are nested within a "try" statement when the context manager does not swallow exceptions but instead forwards them to the outer except clause.

Enhancement: Improved error message for binary and unary operations when an expected type (bidirectional inference) is present.

Bug Fix: Fixed a performance issue that caused long analysis times for some code flow graphs that involve deeply nested loops and many interdependent variables.

Bug Fix: Fixed a bug that resulted in a false positive error when assigning a value of type type | Any to type type[T].

Bug Fix: Fixed a bug that resulted in false positive errors when assigning a value to class variable that contains a generic descriptor object.

Enhancement: Improved the error message for a call expression where a keyword argument and a positional argument target the same parameter.

Enhancement: Updated typeshed stubs to the latest version.

v1.1.225: Published 1.1.225

Compare Source

Bug Fix: Added missing checks for an attempt to modify a variable that has been marked "Final" using a means other than a simple assignment statement. This includes augmented assignments, tuple assignments, for statements, with statements, assignment expressions, etc.

Behavior Change: Modified parameter type inference logic to not infer a parameter's type based on the default argument value if the value is a tuple, list, set or dict.

Enhancement: Improved type evaluation of type(x) to handle the case where x is a union type.

Bug Fix: Fixed bug that caused false negative when a class defined a __getattr__ method but no __getitem__ method and a subscript expression was used with a class instance.

Bug Fix: Fixed a bug in the logic that determines whether a class that derives from a protocol implements all of the functions and variables within that protocol. It wasn't considering mix-in classes.

Bug Fix: Fixed regression in "finally" type analysis that allowed type violation errors to go unreported in finally clauses.

Behavior Change: Changed the behavior of type evaluator when it encounters an unannotated symbol within a "py.typed" source file. Previously, it did not fall back on type inference and instead evaluated the type as "Unknown". It now falls back on type inference but internally marks the type as "ambiguous". Added logic to detect "likely ambiguous inferences".

Behavior Change: Updated package type verifier to differentiate between "unknown" and "ambiguous" types.

Bug Fix: Fixed a bug in type evaluator that resulted in a crash when a function signature contains a "**" parameter with no name.

Bug Fix: Fixed a bug that resulted in a crash due to infinite recursion.

Bug Fix: Enhanced parser to detect extremely deep parse trees created from index or member access expressions. The parser now emits an error rather than allowing the type evaluator to crash (with a stack overflow) in such situations.

Enhancement: Updated typeshed stubs to the latest.

v1.1.224: Published 1.1.224

Compare Source

Bug Fix: Improved NoReturn return call inference when the callable type evaluates to a partial Any or Unknown.

Bug Fix: Improved heuristics related to NoReturn detection when dealing with certain libraries that attempt to import another package within a try statement but provide a "dummy implementation" in an except clause. In this situation, we should use the declaration within the try block and ignore the one in the except clause.

Bug Fix: Fixed buggy assert in type evaluator that resulted in some crashes.

Behavior Change: Changed strictParameterNoneValue to default to true rather than false. This reflects the updated guidance in PEP 484, which indicates that type checkers should not assume that a default argument of None should imply an Optional type.

Enhancement: If CLI version of pyright is run without providing arguments to certain commands, a failure is detected and reported. Thanks to Martin Fischer for this contribution.

Bug Fix: Fixed performance regression due to a recent change in the code flow engine when attempting to evaluate whether call is a NoReturn.

Enhancement: Added support for parameter type inference based on annotated base class method signatures and on default argument expressions.

Bug Fix: Fixed recent regression that caused unnecessary reanalysis when closing a file when using pyright as an LSP. The regression also sometimes resulted in unexpected errors from reanalyzed files including diagnostics about unaccessed variables.

v1.1.223: Published 1.1.223

Compare Source

Bug Fix: Fixed a bug in negative type narrowing logic for value patterns in match statement.

Behavior Change: Removed provisional support for PEP 677 (Alternate Call Syntax) because the proposal was rejected by the Python steering council.

Bug Fix: Fixed a bug that led to incorrect type evaluation in the "implied else" code flow path.

Bug Fix: Improved support for functions or methods that return a context manager that swallow exceptions, such as pytest.raises.

Behavior Change: Modified reportIncompatibleVariableOverride check to permit a ClassVar in the base class to be overridden by a compatible class declaration in a child class.

Bug Fix: Fixed a bug in the type evaluator that led to false positives when assigning a function type to another function type and the source contained parameters annotated with literal types and the dest contained corresponding parameters annotated with TypeVars.

Bug Fix: Fixed bug in the handling of wildcard imports. If the target module doesn't contain a dunder all definition, the resulting imported symbol list should exclude names that start with a single underscore.

Bug Fix: Fixed bug that resulted in a false positive error when using a TypeVarTuple in a classmethod.

Behavior Change: Changed heap overflow detection to use a dynamic value based on available memory rather than a hard-coded size. For the pyright VS Code extension, changed the default "max heap size" from 1.7GB to 3.0GB on 32-bit systems. On 64-bit systems, this value appears to already be a higher value (4GB), and it doesn't appear to get overridden by the lower number.

v1.1.222: Published 1.1.222

Compare Source

Bug Fix: Fixed bug that resulted in false positive when using a recursive type alias with a generic dataclass constructor.

Bug Fix: Fixed a bug that results in a false negative when handling a function parameter that is annotated with a function-scoped TypeVar and has a default argument value.

Behavior Change: Changed the handling of reveal_type so it participates in bidirectional type inference when used within a larger expression.

Bug Fix: Fixed long-standing bug in logic that applies config file settings for diagnostic rule severity levels. The bug caused all settings overrides to be ignored if a pyrightconfig.json file was present. The new logic applies the default values, then the settings overrides, then the pyrightconfig.json file values. The change also simplifies the code, which was getting a bit unmaintainable.

Enhancement: Extended dataclass_transform to support transform_descriptor_types parameter.

Enhancement: Added support for an unpacked TypedDict as a type annotation for a *kwargs parameter.

Bug Fix: Improved the type(x) is y type narrowing logic to handle the case where y is a TypeVar or Self type.

Bug Fix: Fixed bug in match statement type narrowing. It wasn't properly handling the negative type narrowing case for class patterns when the subject expression was a bound TypeVar or Self type.

Bug Fix: Fixed a bug related to the __eq__ method (and other order methods) that are synthesized for a dataclass. The parameter name was incorrect. It should be other.

Bug Fix: Added support for NFKC normalization of identifiers as specified in the Python lexical specification.

v1.1.221: Published 1.1.221

Compare Source

Behavior Change (from Pylance): Auto-exclude any folder under workspace starting with a period.

Bug Fix: Fixed a bug in type narrowing for match statement. It was not properly handling None literal patterns when narrowing in the negative case.

Bug Fix: Fixed bug that leads to a false positive error when using a class whose constructor doesn't contain any type annotations. Pyright treats such classes as though they are generic to help with inference of instance variables initialized in the constructor, but it shouldn't enforce the variance of the under-the-cover type variables.

Bug Fix: Fixed bug that resulted in a false positive when evaluating certain list comprehensions where the subexpressions had interdependencies.

Bug Fix: Fixed bug that resulted in a false positive error when evaluating type compatibility between two callables that included an *args parameter plus a set of keyword-only parameters.

Enhancement: Updated typeshed stubs to the latest version.

Enhancement: Added support for PEP 675 (arbitrary literal strings).

Bug Fix: Added support for multiple unpack operators in a tuple list without parentheses when used in the RHS of a for statement. This was a grammar change introduced in Python 3.9.

Enhancement: Improved completions for class member access when the member variable in a child class is unannotated but a parent class provides an annotation. In this case, we should use the type information from the annotated symbol.

Behavior Change: 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.

Bug Fix: Fixed bug that resulted in an incorrect type evaluation when handling a namedtuple call with a second parameter that is dynamic (not statically known).

Enhancement: Improved support for namedtuple when the second argument is a tuple of string literals. It's more common to pass a list of string literals, but tuples should work as well.

Bug Fix: Reverted a recent bug fix that caused significant performance degradations and crashes under some circumstances.

Enhancement: Added special-case check for new callable syntax used within a quoted annotation passed as a bound or constraint argument to a TypeVar constructor.

Bug Fix: Improved symbol resolution of module imports within the code flow engine when determining whether a context manager swallows exceptions or a callable returns NoReturn.

Performance: Mitigated performance issue that results when doing a type compatibility check between two distinct recursive type aliases.

Bug Fix: Fixed incorrect type evaluation when evaluating a constructor call with bidirectional type inference when the expected type is generic.

Bug Fix: Fixed bug that resulted in incorrect type evaluation when a generic class with constrained type parameters was explicitly specialized with a subclass of one of the constrained types.

v1.1.220: Published 1.1.220

Compare Source

Behavior Change: Changed the type narrowing logic for truthy and falsy conditions to exempt protocol classes.

Bug Fix: Fixed bug that resulted in incorrect type evaluation of an or binary operator when the same expression was used in the LHS and RHS and was always truthy.

Bug Fix: Fixed bug that resulted in the incorrect evaluation of a type resulting from a call to a constructor for an explicitly-specialized generic class in the case where that class implements neither a __new__ nor an __init__ method.

Enhancement: Improved error message for descriptor and property setters.

Bug Fix: Fixed a bug in PEP 646 unpacked tuple support where *args could not be annotated with *tuple type.

Bug Fix: Fixed a false negative in the handling of dataclasses that contain fields with default orders before fields without default values in the case where an __init__ is already defined on the class.

Bug Fix: Fixed bug that results in false positive error when using a PEP 677 callable arrow syntax within a quoted type on Python 3.10 or older.

Bug Fix: Fixed a bug in the code that prints types to text. It was not properly handling the case where a callable contains a synthesized *args parameter with a type that isn't unpacked.

Bug Fix: Fixed false negative where type annotations beginning with "*" were not properly flagged as a syntax error. Improved support for matching of TypeVarTuple when used with *args parameter.

Bug Fix: Added missing check for a TypeVarTuple value that is not unpacked when passed as an argument.

v1.1.219: Published 1.1.219

Compare Source

Enhancement: Updated typeshed stubs to latest version.

Bug Fix: Fixed a bug that results in a false positive error when using a Self return type for an __aenter__ method.

Bug Fix: Fixed false positive error when P.args or P.kwargs parameter type annotation is wrapped in Annotated.

Bug Fix: Fixed bug that caused false negative when evaluating a recursive type alias involving a tuple.

Bug Fix: Fixed a bug in the bidirectional type inference logic for list, set and dictionary expressions when that affected certain cases where the expected type contained a union.

Bug Fix: Fixed bug that resulted in false negative when using a recursive type alias with dictionary, list or set expressions.

Bug Fix: Fixed bug that resulted in the inappropriate generation of an Unknown type (and therefore false positive errors in strict mode) when using bidirectional type inference with a function that accepts a generic callable parameter.

Bug Fix: Improved detection of NoReturn calls within code flow graph. In particular, the code now handles the case where the LHS of the call expression is a member access expression and the LHS of that expression is a local variable whose type needs to be inferred.

Enhancement: Added better error handling and reporting for dataclass_transform.

Bug Fix: Fixed bug that caused crash when handling bigint literal values.

Bug Fix: Added missing check for a dataclass field that is declared with a default value in a base class but then overridden with one that doesn't include a default value in a child class. At runtime, it still acts as though it has a default value, which is inherited from the base class.

Bug Fix: Fixed bug that prevented the "--verifytypes" feature from working with namespace packages.

Bug Fix: Added missing check for improper use of Unpack when used in some contexts.

v1.1.218: Published 1.1.218

Compare Source

Enhancement: Allow "--watch" to be used in conjunction with "--outputjson" command-line options.

Enhancement: Added support for bidirectional type inference for yield statements. The expected type is based on the first type argument in a Generator or AsyncGenerator return type annotation.

Enhancement: Added the ability to add new symbols to builtins by simply adding a type stub file named __builtins__.pyi locally.

Bug Fix: Fixed a bug that led to a false positive error when handling bidirectional type inference for tuple expressions when the expected type was a union that contained multiple tuple subtypes.

Bug Fix: Fixed a bug that resulted in a false negative when a list comprehension was used within a class body and referenced a class-scoped variable in a subexpression other than the first iterable. This also fixes a similar bug where a lambda was used within a class body and referenced a class-scoped variable in its return expression. These now property generate errors, reflecting the runtime behavior.

Bug Fix: Fixed a bug that resulted in incorrect type inference for positional parameters used in class patterns if the corresponding class was defined in a "py.typed" library and it defined a __match_args__ symbol with no annotation.

Bug Fix: Fixed bug in stub generator that caused it to omit import statements with multi-part names (e.g. import a.b.c) even though there was a reference within the generated stub to the imported module.

Enhancement: Extended type narrowing for class pattern matching so it supports narrowing in the negative case when arguments are present and when the pattern class is generic.

Bug Fix: Fixed a bug that resulted in a false negative when a *args parameter was used in conjunction with a * keyword-only separator parameter. This generates a syntax error at runtime.

Bug Fix: Fixed a false positive error when TypeGuard was used without a type argument in a runtime manner (outside of a type annotation).

Bug Fix: Fixed recent regression that results in false positive errors detected in the reportUnknownParameterType diagnostic check when the function includes a parameter with a double underscore name indicating that it's positional-only.

Enhancement: Improved signature help and hover text for synthesized __init__ dataclass method when a parameter uses a field descriptor with a default value.

v1.1.217: Published 1.1.217

Compare Source

Bug Fix: Fixed a bug that resulted in a false positive error when passing an *args argument typed as an unpacked TypeVarTuple to a function that includes an unpacked TypeVarTuple parameter.

Enhancement: Added special-case bidirectional type inference for the right operand of the "|" and "|=" operators (with an expected type based on the left operand). This supports the case where the left operand is a TypedDict and the right operand is a dict expression that conforms to the TypedDict type.

Bug Fix: Fixed a bug in the reportIncompatibleMethodOverride check that resulted in false positive errors when both the base class and child methods have overloads but the base class does not have an implementation and the child class does.

Enhancement: Updated typeshed stubs to the latest version.

Bug Fix: Fixed a bug that results in false positive errors when a ClassVar type declaration appears within an Annotated.

Bug Fix: Added special-case handling of Generic base types to match the (undocumented) runtime behavior. Without this special-case handling, pyright reports that "a consistent method ordering cannot be found" in some cases where the runtime does not.

Bug Fix: Fixed bug that is leading to some crashes that appear in the telemetry.

Bug Fix: Added recursion detection for wildcard import lookups during code flow.

Bug Fix: Fixed a bug that caused a type alias of Any to be evaluated as Unknown if defined within a py.typed library.

Performance: Improved performance when analyzing types that involve some forms of recursive type aliases.

Enhancement: Added support for typing_extensions.Never and typing.Never type and unified the underlying handling of Never and NoReturn, which are synonyms.

Enhancement: Improved type stub generation code to emit definitions for TypeVar, TypeVarTuple, ParamSpec and NewType.

Behavior Change: Changed heuristics for matching two union types when the destination union includes a combination of concrete types and one or more type variables. This case involves some heuristics in the constraint solver because multiple solutions are possible.

Bug Fix: Fixed a bug that resulted in a false positive when assigning to a field in a dataclass that is annotated with a Callable type.

v1.1.216: Published 1.1.216

Compare Source

Bug Fix: Fixed recent regression that resulted in a crash (stack overflow) in the code flow engine.

Bug Fix: Fixed a bug that resulted in unknown types in member access expressions to go unreported with reportUnknownMemberType was enabled. This occurred when the member access expression was located within a subscript of an index expression.

Performance: Changed the logic that infers a NoReturn type to avoid inferring symbol types. This was causing a bunch of extra work to be performed in complex unannotated code bases like sklearn.

Performance: Fixed performance issue in parser for deeply-nested parenthesized expressions.

Bug Fix: Fixed bug in callable type compatibility logic. It was not properly handling some edge cases where a keyword parameter in the source and destination had an incompatible type if one or both of the types were specialized.

Bug Fix: Fixed a bug that resulted in false positives when specializing a callback protocol with a TypeVarTuple when the callback protocol also contained one or more keyword parameters that were generic.

Bug Fix: Fixed a bug in the protocol invariance checking logic. It wasn't properly handling protocols that used a TypeVarTuple as a type parameter that wasn't last (right-most) in the type parameter list.

Behavior Change: 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.


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

👻 Immortal: This MR will be recreated if closed unmerged. Get config help if that's undesired.


  • If you want to rebase/retry this MR, check this box

This MR has been generated by Renovate Bot.

Edited by Vincent Meurisse

Merge request reports