New submission from Konstantin <[email protected]>:
In [18]: class Str(str):
...: pass
In [19]: class Class:
...: Str: str
...:
...:
...: Class.__annotations__
Out[19]: {'Str': str}
In [20]: class Class:
...: Str: str = ""
...:
...:
...: Class.__annotations__
Out[20]: {'Str': str}
In [21]: class Class:
...: Str: Str = ""
...:
...:
...: Class.__annotations__ # Wrong!
Out[21]: {'Str': ''}
In [22]: class Class:
...: Str: Str
...:
...:
...: Class.__annotations__
Out[22]: {'Str': __main__.Str}
It reproduced all the version which support annotations as part of the core (I
tested python 3.6..3.10.2)
----------
components: Parser
messages: 413586
nosy: kgubaev, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Wrong class __annotations__ when field name and type are equal
type: behavior
versions: Python 3.10
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue46807>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com