Open DetachHead opened 1 month ago
pyright's has experimental support for inline TypedDict syntax:
TypedDict
foo: dict[{"foo": int}]
(although it will probably be removed from pyright in the future, if that happens i will keep it in basedpyright.)
unfortunately the @final decorator doesn't work on it:
@final
from typing import final Foo = final(dict[{"foo": int}]) class Bar(Foo): # no error b: int
perhaps we could use typing.Final instead:
typing.Final
Foo = Final[dict[{"foo": int}]]
which is a convenient solution because it unintentionally also provides runtime protection against subtyping it too:
TypeError: Cannot subclass typing.Final[dict[{'foo': <class 'int'>}]]
(related: #385)
pyright's has experimental support for inline
TypedDict
syntax:(although it will probably be removed from pyright in the future, if that happens i will keep it in basedpyright.)
unfortunately the
@final
decorator doesn't work on it:perhaps we could use
typing.Final
instead:which is a convenient solution because it unintentionally also provides runtime protection against subtyping it too:
(related: #385)