TypedDict does not allow optional keys?

Since Python 3.11, as per PEP 655, what you need is NotRequired: class _trending(TypedDict): allStores: NotRequired[bool] category: str date: str average: List[int] notice that you shouldn’t use Optional in TypedDict, and only use (Not)Required if you want to use TypedDict with Pydantic, you could refer this article

Python 3 dictionary with known keys typing

As pointed out by Blckknght, you and Stanislav Ivanov in the comments, you can use NamedTuple: from typing import NamedTuple class NameInfo(NamedTuple): name: str first_letter: str def get_info(name: str) -> NameInfo: return NameInfo(name=name, first_letter=name[0]) Starting from Python 3.8 you can use TypedDict which is more similar to what you want: from typing import TypedDict class … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)