79772411

Date: 2025-09-23 09:10:44
Score: 0.5
Natty:
Report link

The issue is with bar: dict as it seems to be a too generic type.

What worked for bar are:

from typing import Literal

bar: dict[Literal["bar"], str] = {"bar": "bar"}


# or

class BarDict(TypedDict):
    bar: str

bar: BarDict = {"bar": "bar"}

This means, that it's some sort of an "all in" situation if this way of typing wants to be used.

Cool new things are coming in this area, for example have a look at extra items https://peps.python.org/pep-0728/#the-extra-items-class-parameter

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Engensmax