[New-bugs-announce] [issue32278] Allow dataclasses.make_dataclass() to omit type information

Eric V. Smith report at bugs.python.org
Mon Dec 11 14:47:31 EST 2017


New submission from Eric V. Smith <eric at trueblade.com>:

Make the typing information optional.

>From Raymond Hettinger:

The make_dataclass() factory function in the dataclasses module currently requires type declarations. It would be nice if the type declarations were optional.

With typing (currently works):

    Point = NamedTuple('Point', [('x', float), ('y', float), ('z', float)])
    Point = make_dataclass('Point', [('x', float), ('y', float), ('z', float)])

Without typing (only the first currently works):

    Point = namedtuple('Point', ['x', 'y', 'z'])          # underlying store is a tuple
    Point = make_dataclass('Point', ['x', 'y', 'z'])      # underlying store is an instance dict

----------
assignee: eric.smith
components: Library (Lib)
messages: 308071
nosy: eric.smith, levkivskyi, rhettinger
priority: normal
severity: normal
status: open
title: Allow dataclasses.make_dataclass() to omit type information
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32278>
_______________________________________


More information about the New-bugs-announce mailing list