# PEP 767: Annotating Read-Only Attributes

**URL:** <https://discuss.python.org/t/pep-767-annotating-read-only-attributes/73408>\
**Category:** PEPs\
**Tags:** typing\
**Created:** [December 5, 2024, 5:58pm UTC](https://discuss.python.org/t/pep-767-annotating-read-only-attributes/73408 "2024-12-05T17:58:12Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![randolf-scholz](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/randolf-scholz/32/11123_2.png) [@randolf-scholz](https://discuss.python.org/u/randolf-scholz)\
**Post date:** [December 13, 2024, 3:00pm UTC](https://discuss.python.org/t/pep-767-annotating-read-only-attributes/73408/13 "2024-12-13T15:00:03Z")

</div>

Something like this is desperately needed in the type system, but I would suggest a few changes:

> A read-only attribute `name: T` on a [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol) in principle defines two requirements:
> 
> 1. `hasattr(obj, "name")`
> 2. `isinstance(obj.name, T)`

I wouldn’t call such a thing `ReadOnly`, but `Readable`. A read-only member of a protocol needs to satisfy an additional axiom: (3) `setattr(obj, name, T)` raises an `Exception`. I believe this is a simple oversight in this section, but at the end of the day, both concepts are necessary in order to facilitate correctly annotating duck-typed code: [Need a way to type-hint attributes that is compatible with duck-typing - #19 by randolf-scholz](https://discuss.python.org/t/need-a-way-to-type-hint-attributes-that-is-compatible-with-duck-typing/41137/19)

So if it is possible, it would be very nice to get Type Qualifiers `Readable`, `ReadOnly`, `Writeable` and `WriteOnly` and `Mutable` all in one go.

---

_[View the full topic](https://discuss.python.org/t/pep-767-annotating-read-only-attributes/73408)._
