# PEP 705: Read-only TypedDict items

**URL:** <https://discuss.python.org/t/pep-705-read-only-typeddict-items/37867>\
**Category:** PEPs\
**Tags:** typing\
**Created:** [November 4, 2023, 8:28am UTC](https://discuss.python.org/t/pep-705-read-only-typeddict-items/37867 "2023-11-04T08:28:36Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![davidfstr](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/davidfstr/32/6944_2.png) [@davidfstr](https://discuss.python.org/u/davidfstr)\
**Post date:** [November 4, 2023, 2:23pm UTC](https://discuss.python.org/t/pep-705-read-only-typeddict-items/37867/2 "2023-11-04T14:23:56Z")

</div>

Looks great! Some feedback:

- PEP readers who are not typing experts may appreciate adding a paragraph like the following to the end of §“Abstract”, so that they don’t need to read further: (I added a similar paragraph in PEP 655 based on feedback received then.)

> This PEP makes no Python grammar changes. Correct usage of read-only keys of TypedDicts is intended to be enforced only by static type checkers and need not be enforced by Python itself at runtime.

- §“Motivation” is quite clear. 👍 [§“Updating nested dicts”](https://peps.python.org/pep-0705/#updating-nested-dicts) in particular is not something I considered when thinking about `ReadOnly[]` before.

- I’d recommend adding a section to §“Specification” explaining how `get_type_hints()` treats `ReadOnly[]`, similar to [the callouts in PEP 655](https://peps.python.org/pep-0655/#runtime-behavior). For completeness you might consider mentioning the altered behavior of `get_origin()`, and `get_args()` as well.

- Nit: Suggest adding the following changes in bold:

> Suggest **ed** changes to the [`typing`](https://docs.python.org/3/library/typing.html#module-typing) module **documentation** , in line with current practice:

- Nit: In “Individual items can be excluded from mutate operations […]” the phrase “mutate operations” feels both overly technical and vague to me. Suggested wordsmithing to be less technical:

> Individual items can be prevented from being changed by marking then as ReadOnly, allowing them only to be read.

- Nit: For “pyright 1.1.332 fully implements this proposal.” suggest linking to the changelog or commit from pyright that indicates that it added ReadOnly support.

- Nit: In the sentence “It would be reasonable for someone familiar with `frozen`, […]” it’s not clear what `frozen` is referring to. There are no other uses of the word “frozen” in the PEP. Did you mean `readonly` instead?

- There are multiple locations in this PEP that include a `Never`-typed TypedDict item. (See example below.) It’s not clear to me what that even means. I suppose I don’t have specific feedback on this construction other than I find it confusing.

```python
class B(TypedDict):
  foo: NotRequired[Never]

```

- In §“Rejected alternatives” maybe it would be worth talking about why the existing `Final[]` qualifier couldn’t be used in place of introducing a new `ReadOnly[]` qualifier? I think this was discussed before but I don’t remember what was said.

- (I did not review the formal rules in §“Type Consistency”, due to lack of energy/time)

---

_[View the full topic](https://discuss.python.org/t/pep-705-read-only-typeddict-items/37867)._
