#29516 closed Cleanup/optimization (fixed)
Rephrase error message when passing incorrect kwarg to model constructor
Reported by: | Federico Bond | Owned by: | Federico Bond |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | error message |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When passing an incorrect keyword argument to a model constructor, the init method will throw an error like this:
TypeError: 'x' is an invalid keyword argument for this function
It takes a couple of seconds to notice what "this function" refers to, especially if the call is behind some abstraction like factory_boy. You have to scroll several levels up the stack trace to notice the offender. I propose to change this message to:
TypeError: 'x' is an invalid keyword argument for ModelName
I can submit a pull request once the ticket is accepted.
Change History (6)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Component: | Error reporting → Database layer (models, ORM) |
---|---|
Owner: | set to |
Summary: | Improve error message when passing incorrect kwarg to model constructor → Rephrase error message when passing incorrect kwarg to model constructor |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
comment:3 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
Perhaps even better would be to imitate the default error message in Python: