de_sim
de_sim copied to clipboard
Report this problem to Python's developers
As of Python 3.7, Python's parsing of PEP 526 type annotations does not report replicated attributes properly. A replicated attribute name with default value(s) is not consistent in namespace
and namespace['__annotations__']
. namespace['__annotations__']
contains the attribute's last type BUT its order there reflects its FIRST declaration. And namespace contains the attribute's LAST default value. This example illustrates the problem, with EventMessage defined below.
class ExampleEventMessageWithReplicatedAttr(EventMessage):
name: str = 'hi'
unit_price: float
quantity_on_hand: int = 0
name: float = 1.1
name: int