Closed vansivallab closed 6 years ago
This is the defined behavior. The generated Bar.__init__
would look like:
def __init__(self, some_default: dict = <something>, other_field: int)
Which is an error.
What would you suggest the behavior should be?
We could fall back to (or explicitly allow) keyword only arguments in this case such that we end up with a signature for Bar.__init__
of:
def __init__(self, *, some_default: dict = <something>, other_field: int):
...
which is not an error.
I think that's more complexity than we want to promote.
Possibly as a decorator argument:
@dataclass(keyword_only=True)
class Bar(Foo):
other_field: int
That might be reasonable. Now that I've merged this to cpython, suggestions like this should probably go to the python-ideas mailing list.
@gwax
I think this adds unnecessary complexity. What is your use case? Also note that the current behaviour is consistent with typing.NamedTuple
and mypy_extensions.TypedDict
(which will likely be promoted to typing
).
@vansivallab: I'm closing this issue. Please bring it up on python-ideas if you're still interesting in it.
My goal is to shut down this repo except for backporting to Python 3.6.
A
TypeError
is raised when trying to create a subclass off a class which contains a default field.Error output: