smarie/python-pyfields

`@autofields` does not take definition order into account

smarie opened this issue · 1 comments

Consider this:

from pyfields import autofields, get_fields

@autofields
class Foo:
    c: int
    b: str = "hello"

get_fields(Foo)  # <-- (<NativeField: Foo.b>, <NativeField: Foo.c>)

So the order in which the fields are returned is wrong.

After investigating, this bug only happens when there are attributes that do not have default values (only an annotation).