github DetachHead/basedpyright v1.20.0
v1.20.0 (pyright 1.1.387)

13 hours ago

What's Changed

inlay hints for generics

these can be enabled using the new basedpyright.analysis.inlayHints.genericTypes setting:

  • when instantiating classes (#818)
  • Final and ClassVar annotations (#809)

note that it's disabled by default because the information it provides is often redundant when basedpyright.analysis.inlayHints.variableTypes is enabled:
image

new diagnostic rule: reportUnannotatedClassAttribute

pyright does not warn when a member of a class that doesn't have a type annotation is overridden with an incompatible type:

class A:
    value = 1

class B(A):
    value = None # no error, even though the type on the base class is `int` and the type here is `None`

this decision seems to have been made for performance reasons, which is fair enough. but because it's unsafe, there should be a check that enforces type annotations on class attributes (unless the class is decorated with @final). the reportUnannotatedClassAttribute rule will do just that:

class A:
    value = 1 # error: Type annotation for attribute `value` is required because this class is not decorated with `@final` 

(implemented in #812)

merge upstream & experimental inline TypedDict update

  • update upstream pyright version to 1.1.387 (#829)
  • previously, we supported an experimental syntax for defining inline TypedDicts:
    foo: dict[{"foo": int}] = {"foo": 1}
    this used to be supported in pyright but was removed a few months ago because it was never made into a PEP. i decided to keep the feature in basedpyright, however a draft PEP was created for it recently, which resulted in the feature being added back in this release of pyright, but with a different syntax:
    + foo: TypedDict[{"foo": int}] = {"foo": 1}
  • to reduce confusion, i've removed support for the old dict[{"foo": int}] syntax. from now on any deviations we make from the standard will be configured using a separate option instead of using pyright's enableExperimentalFeatures setting, which is now disabled by default like it is in pyright (#831)

other changes

  • fix crash when pyproject.toml contains an emoji by @DetachHead in #822
  • fix import suggestion code actions not working when no workspace is open by @DetachHead in #824
  • fix hang when installing basedpyright from github url using uv by @DetachHead in #825
  • Chinese (Simplified) localization update (2024.10) by @NCBM in #767
  • Remove redundant bullet point in docs by @tylerlaprade in #811

New Contributors

Full Changelog: v1.19.1...v1.20.0

Don't miss a new basedpyright release

NewReleases is sending notifications on new releases.