Skip to content

__annotate__ corner case when deleting __annotations__ #132285

@sobolevn

Description

@sobolevn

Consider this example:

>>> class A:
...      def __annotate__(format):
...           print(f'{format=}')
...           return {'a': int}
...           
>>> A.__annotations__
format=1
{'a': <class 'int'>}
>>> A.__annotations__
{'a': <class 'int'>}
>>> del A.__annotations__
>>> A.__annotations__
format=1
{'a': <class 'int'>}

In this particular case __annotate__ is called twice. It works correctly in my opinion. But, I can't find any tests for such cases. Should I add tests for this?

CC @JelleZijlstra

Linked PRs

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions