<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>@David<br></div>What you propose as `Infer` annotation was proposed some time ago (not only for dataclasses, there are other use cases).<br></div>The discussion is here <a href="https://github.com/python/typing/issues/276">https://github.com/python/typing/issues/276</a><br><br></div>@Chris<br></div>People are still allowed not to use dataclasses if they really don't like type hints :-)<br></div>Seriously however, annotations are just syntax. In this sense PEP 526 is more like PEP 3107,</div><div>and less like PEP 484. People are still free to write:<br></div><br></div>@dataclass<br></div>class C:<br></div>Â Â Â x: "first coordinate"<br></div>Â Â Â y: "second coordinate"<br></div>Â Â Â plus: "I don't like types"<br><br></div>or<br><br></div>@dataclass<br></div>class C:<br></div>Â Â Â x: ...<br></div>Â Â Â y: ...<br><br></div>I don't see so big difference between hypothesis (testing lib) using annotations for their purposes<br></div>from the situation with dataclasses. It is true that the syntax was chosen to simplify<br></div>support in static type checkers (partially because users were often asking for such feature),</div><div>but not more than this. If you don't use type checkers, there is no problem in using one of the above forms.<br></div><br></div>If you have ideas about how to improve the dataclass docs, this can be discussed in the issue <a href="https://bugs.python.org/issue32216">https://bugs.python.org/issue32216</a></div><div><br></div><div>> ... the type will in fact be completely ignored by the implementation.<div style="font-size:12.8px"></div><div style="font-size:12.8px">> Newbies are going to be confused by this -- they really are.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">This is not different from</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">def f(x: int):</div><div style="font-size:12.8px">Â Â Â pass</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">f("What")Â # OK</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">that exists starting from Python 3.0. Although I agree this is confusing, the way forward could be just</div><div style="font-size:12.8px">explaining this better in the docs.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">If you want my personal opinion about the current situation about type hints _in general_, then I can say that</div><div style="font-size:12.8px">I have seen many cases where people use type hints where they are not needed</div><div style="font-size:12.8px">(for example in 10 line scripts or in highly polymorphic functions), so I agree that some community</div><div style="font-size:12.8px">style guidance (like PEP 8) may be helpful. I had started such project an the end of last year</div><div style="font-size:12.8px">(it was called pep-555, but I didn't have time to work on this and this number is already taken).</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">--</div><div style="font-size:12.8px">Ivan</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div></div></div>