diff mbox series

[v2,03/13] python/sepolgen: return NotImplemented instead of raising it

Message ID 20180812202522.3743-4-nicolas.iooss@m4x.org (mailing list archive)
State Not Applicable
Headers show
Series Fix some issues found by flake8 | expand

Commit Message

Nicolas Iooss Aug. 12, 2018, 8:25 p.m. UTC
sepolgen uses "return NotImplemented" (in access.py and matching.py) in
order to make Python's sorting function use an other call to compare
objects. For this to work, "NotImplemented" needs to be returned, not
raised like _compare's default implementation does.

This issue has been found using flake8. This Python linter reported:

    python/sepolgen/src/sepolgen/util.py:128:9: F901 'raise
    NotImplemented' should be 'raise NotImplementedError'

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 python/sepolgen/src/sepolgen/util.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/python/sepolgen/src/sepolgen/util.py b/python/sepolgen/src/sepolgen/util.py
index 5d38bce29827..f5b66d0370a2 100644
--- a/python/sepolgen/src/sepolgen/util.py
+++ b/python/sepolgen/src/sepolgen/util.py
@@ -123,7 +123,7 @@  class Comparison():
     _compare function within your class."""
 
     def _compare(self, other, method):
-        raise NotImplemented
+        return NotImplemented
 
     def __eq__(self, other):
         return self._compare(other, lambda a, b: a == b)