rspec/rules/S2875/python/rule.adoc

41 lines
1.0 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
``++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.
=== Noncompliant code example
2022-02-04 17:28:24 +01:00
[source,python]
----
class MyClass:
def do_something(self):
raise NotImplemented("Haven't gotten this far yet.") #Noncompliant
----
=== Compliant solution
2022-02-04 17:28:24 +01:00
[source,python]
----
class MyClass:
def do_something(self):
raise NotImplementedError("Haven't gotten this far yet.")
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
=== 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.
endif::env-github,rspecator-view[]