ast: Improve behavior for user-defined classes · Issue #117486 · python/cpython (original) (raw)

From @encukou:

          Thanks for the fix. Since it's a blocker I merged it, even though I'd have one more review comment:

It would be good to add this to the new test, and improve the behaviour (the error is quite opaque):

    class MoreFieldsThanTypes(ast.AST):
        _fields = ('a', 'b')
        _field_types = {'a': int | None}
        a: int | None = None
        b: int | None = None

Originally posted by @encukou in #117266 (comment)

Based on robotframework/robotframework#5091 (comment), we should also document _field_types.

Linked PRs