Hmm,

It does make you wonder if using the presence of an annotation to indicate
a field was a good choice -- but here we are.

Additionally one could consider adding an `attribute` typing construct,
> such that `attr0: attribute[int]` would mark it as a non-field attribute.
>

Better yet, a dataclasses.attribute object that would indicate that:

from dataclasses import dataclass, field, attribute
@dataclass
class C:
    x: int = 0
    mylist: list[int] = field(default_factory=list)
    y: int = attribute(value=0)

x and mylist are fields, y is not. y would get set to the value specified.

Then the type annotation is left unadulterated -- much easier for the type
checkers.

-CHB



-- 
Christopher Barker, PhD (Chris)

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/LS3AN6LEOH5OUYMVTKBC7T4XA6ZRYFDJ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to