Skip to content

Report this problem to Python's developers #59

Description

@artgoldberg

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

help wantedExtra attention is needed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions