<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/typeddict-with-extra-items-y15hcfxfy" -->

---
title: TypedDict with extra items | daily.dev
description: Python 3.15 adds an extra_items class parameter to TypedDict, letting you allow additional dictionary keys of a specified type. Setting extra_items=str on a...
canonical: https://daily.dev/posts/typeddict-with-extra-items-y15hcfxfy
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: TypedDict with extra items | daily.dev
og:description: Python 3.15 adds an extra_items class parameter to TypedDict, letting you allow additional dictionary keys of a specified type. Setting extra_items=str on a...
og:url: https://daily.dev/posts/typeddict-with-extra-items-y15hcfxfy
og:image: https://api.daily.dev/og/posts/Y15HCfxFY.png
og:image:alt: TypedDict with extra items
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# TypedDict with extra items

**[Planet Python](https://daily.dev/sources/planetpython)** · 4 min read · 0 upvotes · 0 comments

## Summary

Python 3.15 adds an extra_items class parameter to TypedDict, letting you allow additional dictionary keys of a specified type. Setting extra_items=str on a Movie TypedDict means an extra key like 'genre' with a string value still type checks, while a float value for an unknown key fails. A separate closed=True parameter locks a TypedDict to exactly its declared keys and blocks subclasses from adding more; it can't be combined with extra_items. The same extra_items setting also controls whether typing.Unpack allows extra keyword arguments in a function signature.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://mathspp.com/blog/typeddict-with-extra-items>

## Questions this post answers

### How do I make a Python TypedDict allow extra keys with a specific type?

Use the extra_items class parameter when defining the TypedDict, e.g. class Movie(TypedDict, extra_items=str). This lets dictionaries of that type include additional keys beyond those declared in the class body, as long as their values match the specified type. A key with a value of the wrong type still fails type checking.

_Tracking new typing features like this gets easier when daily.dev surfaces Python 3.15 changes as they land._

### What does closed=True do for a Python TypedDict?

Setting closed=True on a TypedDict specifies that it has exactly the keys declared in its body and no others, and it also prevents subclasses from adding new keys. It cannot be combined with extra_items, and closed=False behaves the same as omitting both parameters, matching pre-3.15 TypedDict behavior.

_Developers deciding how strict to make their type definitions can follow these typing changes on daily.dev._

### How does extra_items affect typing.Unpack with keyword arguments in Python?

When a TypedDict used with Unpack has no extra_items set, a function typed with Unpack accepts no extra keyword arguments beyond those declared. When extra_items=str is set, the function also accepts arbitrary extra keyword arguments of that type, equivalent to adding **kwargs: str to the signature manually.

_Developers migrating function signatures to Python 3.15 typing features can keep up with these details on daily.dev._

## Similar posts on daily.dev

- [The varying strictness of TypedDict](https://daily.dev/posts/the-varying-strictness-of-typeddict-woau6xf94) · Planet Python · 0 upvotes · 0 comments
- [Get started with Python’s new frozendict type](https://daily.dev/posts/get-started-with-python-s-new-frozendict-type-z3smdzvfm) · InfoWorld · 0 upvotes · 0 comments
- [Python: store extra data for objects in a WeakKeyDictionary](https://daily.dev/posts/python-store-extra-data-for-objects-in-a-weakkeydictionary-i6dtgtava) · Adam Johnson · 0 upvotes · 0 comments
- [The Joy of Typing](https://daily.dev/posts/the-joy-of-typing-r5aiqx2dz) · Towards Data Science · 0 upvotes · 0 comments

---

Tags: [#general-programming](https://daily.dev/tags/general-programming), [#python](https://daily.dev/tags/python)

[View this post on daily.dev](https://daily.dev/posts/typeddict-with-extra-items-y15hcfxfy)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"TypedDict with extra items","url":"https://daily.dev/posts/typeddict-with-extra-items-y15hcfxfy","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/typeddict-with-extra-items-y15hcfxfy"},"datePublished":"2026-10-26T19:53:37.050Z","dateModified":"2026-10-26T19:57:22.820Z","description":"Python 3.15 adds an extra_items class parameter to TypedDict, letting you allow additional dictionary keys of a specified type. Setting extra_items=str on a...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8161884df1aa4793de332e312b43688a?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8161884df1aa4793de332e312b43688a?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Planet Python","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Planet Python","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/eac3cc584cb043b5a242d13752bd3d0c","url":"https://daily.dev/sources/planetpython"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/typeddict-with-extra-items-y15hcfxfy","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"general-programming,python","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Planet Python","item":"https://daily.dev/sources/planetpython"},{"@type":"ListItem","position":3,"name":"TypedDict with extra items"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/typeddict-with-extra-items-y15hcfxfy#faq","mainEntity":[{"@type":"Question","name":"How do I make a Python TypedDict allow extra keys with a specific type?","acceptedAnswer":{"@type":"Answer","text":"Use the extra_items class parameter when defining the TypedDict, e.g. class Movie(TypedDict, extra_items=str). This lets dictionaries of that type include additional keys beyond those declared in the class body, as long as their values match the specified type. A key with a value of the wrong type still fails type checking. Tracking new typing features like this gets easier when daily.dev surfaces Python 3.15 changes as they land."}},{"@type":"Question","name":"What does closed=True do for a Python TypedDict?","acceptedAnswer":{"@type":"Answer","text":"Setting closed=True on a TypedDict specifies that it has exactly the keys declared in its body and no others, and it also prevents subclasses from adding new keys. It cannot be combined with extra_items, and closed=False behaves the same as omitting both parameters, matching pre-3.15 TypedDict behavior. Developers deciding how strict to make their type definitions can follow these typing changes on daily.dev."}},{"@type":"Question","name":"How does extra_items affect typing.Unpack with keyword arguments in Python?","acceptedAnswer":{"@type":"Answer","text":"When a TypedDict used with Unpack has no extra_items set, a function typed with Unpack accepts no extra keyword arguments beyond those declared. When extra_items=str is set, the function also accepts arbitrary extra keyword arguments of that type, equivalent to adding **kwargs: str to the signature manually. Developers migrating function signatures to Python 3.15 typing features can keep up with these details on daily.dev."}}]}
```

