2023-05-03 11:06:20 +02:00
== Why is this an issue?
2021-06-08 14:23:48 +02:00
``++NotImplemented++`` is a constant which is intended to be used only by comparison methods such as ``++__lt__++``. Use it instead of ``++NotImplementedError++``, which is an exception, and callers will have a hard time using your code.
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2021-06-08 14:23:48 +02:00
2022-02-04 17:28:24 +01:00
[source,python]
2021-06-08 14:23:48 +02:00
----
class MyClass:
def do_something(self):
raise NotImplemented("Haven't gotten this far yet.") #Noncompliant
----
2023-05-03 11:06:20 +02:00
=== Compliant solution
2021-06-08 14:23:48 +02:00
2022-02-04 17:28:24 +01:00
[source,python]
2021-06-08 14:23:48 +02:00
----
class MyClass:
def do_something(self):
raise NotImplementedError("Haven't gotten this far yet.")
----
ifdef::env-github,rspecator-view[]
2021-06-08 15:52:13 +02:00
'''
2021-06-08 14:23:48 +02:00
== Comments And Links
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== on 28 Apr 2015, 10:04:00 Ann Campbell wrote:
http://mouadino.appspot.com/notimpelementederror-vs-notimplemented-in-python/
=== on 31 Jan 2020, 15:48:43 Nicolas Harraudeau wrote:
Closing in favor of RSPEC-5632.
``++NotImplemented++`` does not derive from BaseException so it will fail as any other non-exception.
2021-06-08 14:23:48 +02:00
endif::env-github,rspecator-view[]