![](https://secure.gravatar.com/avatar/833c1ef94aebf738851577a5cb0b71e7.jpg?s=120&d=mm&r=g)
On Sun, 2021-04-11 at 23:34 -0700, Larry Hastings wrote:
Your example was valid, and I think your workaround should be fine. Do you have a use case for this, or is this question motivated purely by curiosity?
It took a few readings for me to understand the limitations in the PEP. My example and workaround were mostly for me to confirm I had read it correctly.
It's fine to modify the __annotations__ dict after the creation of the class or module. It's code that modifies "__annotations__" from within the class or module that is disallowed here. Similarly for dataclasses; once it creates a class object, it can explicitly set and / or modify the annotations dict on that class.
Thanks. I think this clarification should be added to the PEP. Paul