Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1410.change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The error message if an attribute has both an annotation and a type argument will now disclose _what_ attribute seems to be the problem.
2 changes: 1 addition & 1 deletion src/attr/_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -2491,7 +2491,7 @@ def from_counting_attr(cls, name: str, ca: _CountingAttr, type=None):
if type is None:
type = ca.type
elif ca.type is not None:
msg = "Type annotation and type argument cannot both be present"
msg = f"Type annotation and type argument cannot both be present for '{name}'."
raise ValueError(msg)
return cls(
name,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class C:
x: int = attr.ib(type=int)

assert (
"Type annotation and type argument cannot both be present",
"Type annotation and type argument cannot both be present for 'x'.",
) == e.value.args

def test_typing_annotations(self):
Expand Down