Opened 2 years ago

Closed 2 years ago

#20841 closed Cleanup/optimization (fixed)

NotImplementedErrors should provide exception messages

Reported by: joseph@… Owned by: TimClifford
Component: Core (Other) Version: master
Severity: Normal Keywords: NotImplementedError
Cc: joseph@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The Django source has many occurrences of NotImplementedErrors raised without a message. For example, if a dev creates a class inheriting from contrib.admin.SimpleListFilter and does not provide a lookups() method, all they see from the Debug template is "NotImplementedError at /path/to/file/ No exception supplied". This, in my opinion, makes seeking help difficult for those not comfortable enough to dig through the Django source. A simple message such as "instances of SimpleListFilter must provide a lookups() method" provides instant feedback and a non-ambiguous means to seeking help if needed.

In short, my request is to have all NotImplementedError exceptions raised accompanied by a message.

I realize this change would be boring to work on, so I am more than willing to read through the patch procedures and submit a patch myself if you all find this a worthy cause. (The nature of this request may even be simple enough to send through Github)

Change History (5)

comment:1 Changed 2 years ago by claudep

  • Component changed from Uncategorized to Core (Other)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Version changed from 1.5 to master

comment:2 Changed 2 years ago by TimClifford

  • Owner changed from nobody to TimClifford
  • Status changed from new to assigned

Looks like gruntwork that requires a base level of code literacy, which is perfect to assign during a sprint.

I'm on it!

comment:3 Changed 2 years ago by TimClifford

Pull request submitted and awaiting review. 92 instances of "raise NotImplementedError" used to placehold base class methods for subclassing were given verbose may/must subclass explanations, and two instances of not-implemented features were written up as well (found in /utils/datetime.py line #67 and /utils/regex_helper.py line #95).

Version 0, edited 2 years ago by TimClifford (next)

comment:4 Changed 2 years ago by TimClifford

  • Has patch set

Added a patch in the form of a Pull Request, visible here:
https://github.com/django/django/pull/1569

comment:5 Changed 2 years ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In b2b763448f726ee952743596e9a34fcb154bdb12:

Fixed #20841 -- Added messages to NotImplementedErrors

Thanks joseph at vertstudios.com for the suggestion.

Note: See TracTickets for help on using tickets.
Back to Top