This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.smith
Recipients John Parejko2, eric.smith
Date 2019-04-09.21:56:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <[email protected]>
In-reply-to
Content
I'm not sure why dataclasses would be different here:

>>> import dataclasses
>>> import unittest.mock
>>> @dataclasses.dataclass
... class Foo:
...     name: str
...     baz: float
...     bar: int = 12
...
>>> import inspect
>>> inspect.signature(Foo)
<Signature (name: str, baz: float, bar: int = 12) -> None>
>>>

Foo is just a normal class with a normal __init__.

This is no different than if you don't use dataclasses:

>>> class Bar:
...     def __init__(self, name: str, baz: float, bar: int = 12) -> None:
...         pass
...
>>> Bar()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() missing 2 required positional arguments: 'name' and 'baz'
>>> inspect.signature(Bar)
<Signature (name: str, baz: float, bar: int = 12) -> None>
>>> BarMock = unittest.mock.Mock(Bar)
>>> barMock = BarMock()
History
Date User Action Args
2019-04-09 21:56:44eric.smithsetrecipients: + eric.smith, John Parejko2
2019-04-09 21:56:44eric.smithsetmessageid: <[email protected]>
2019-04-09 21:56:44eric.smithlinkissue36580 messages
2019-04-09 21:56:44eric.smithcreate