Skip to content

dataclasses error message "non-default argument '<name>' follows default argument" should mention the default argument field #107838

@ericvsmith

Description

@ericvsmith

The error message from this dataclass:

@dataclass
class C:
    x: int = 0
    y: int

is
TypeError: non-default argument 'y' follows default argument

It would be helpful if it was:
TypeError: non-default argument 'y' follows default argument 'x'

In this case, of course, the default argument field name is obvious, but I have a complicated case where this would be useful information.

I have a patch ready.

Linked PRs

Metadata

Metadata

Assignees

Labels

stdlibPython modules in the Lib dirtype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions