On Thu, Dec 9, 2021 at 3:23 PM Ricky Teachey <ri...@teachey.org> wrote:
> On Thu, Dec 9, 2021 at 3:08 PM Christopher Barker <python...@gmail.com> > wrote: > >> On Thu, Dec 9, 2021 at 11:08 AM Simão Afonso < >> simao.afo...@powertools-tech.com> wrote: >> >>> Shouldn't typing be encouraged on dataclasses, at least? >> >> >> Typing shouldn’t be encouraged for any particular class, nor the language >> itself. Typing policy is a matter for the project/organization to decide. >> >> But Annotations are required by dataclasses in any case. That’s how the >> decorator identifies fields. >> >> The contents of those annotations are up to the user. >> >> -CHB >> >> > Since not everyone uses dataclasses and to avoid confusion: what you mean > here is that type HINTS are required by dataclasses, not Annotations. An > Annotated is a type of type hint that contains an annotation, which we're > loosely calling a member docstring in this thread (currently, a "member > docstring" is not really a thing that exists, unless you count a comment or > a string nearby the statement creating the member). > A correction to my correction (Chris Barker very kindly replied to me off-list about it; what a mensch): type hints aren't required in a dataclass. All that is required is *something* in the "type hint slot" of the expression, and that something is often (officially?) called an annotation. So we have at least 3 meanings of annotation/annotate/annotated possibly at work in this thread (what fun): 1. an annotation (the slot where type hints usually go these days, but really, you can put anything there even when constructing a dataclass), 2. the Annotated type hint type, and 3. the annotation that is the second argument of the Annotated brackets operator. How confusing! --- Ricky. "I've never met a Kentucky man who wasn't either thinking about going home or actually going home." - Happy Chandler
_______________________________________________ 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/26WOAIZF4Y57XTXRKYSOBBETHPKKG5H7/ Code of Conduct: http://python.org/psf/codeofconduct/