[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#964862: git-revice/0.6.0: pylint warning prevent Debian packaging



Hi Nika,

pylint complains since version 2.6 about some 'raise' keywords in 
git-revise that are not re-raising the original exceptions.  These 
issues currently prevent the release of the Debian package for 
git-revise/0.6.0:

> ...
> lint run-test: commands[0] | pylint gitrevise
> ************* Module gitrevise.merge
> gitrevise/merge.py:207:12: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
> gitrevise/merge.py:225:12: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
> ************* Module gitrevise.utils
> gitrevise/utils.py:73:8: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
> gitrevise/utils.py:89:12: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
> 
> ------------------------------------------------------------------
> Your code has been rated at 9.96/10 (previous run: 9.96/10, +0.00)
> 
> ERROR: InvocationError for command /tmp/autopkgtest.SDfHIM/tree/.tox/lint/bin/pylint gitrevise (exited with code 4)
> ...
> 

Can you please review the patch (attached or [1]) and possible consider 
adoption?  Shall I open a github issue/pull-request for that?

Looking forward for your feedback.

Kind regards,
Nicolas


[1] https://github.com/fjasle/git-revise -b satisfy-pylint26-raise-missing-from

-- 
epost: nicolas@fjasle.eu               irc://oftc.net/nsc
↳ gpg: 18ed 52db e34f 860e e9fb  c82b 7d97 0932 55a0 ce7f
     -- frykten for herren er opphav til kunnskap --
From 09ff90ded38e20a6d99ca86263332eb2a0515800 Mon Sep 17 00:00:00 2001
From: Nicolas Schier <nicolas@fjasle.eu>
Date: Thu, 3 Sep 2020 11:25:28 +0200
Subject: [PATCH] Satisfy pylint raise-missing-from warnings

Add 'from' to re-raise exceptions.  Since version 2.6, pylint complains
about four raise-missing-from issues:

  gitrevise/merge.py:207:12: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
  gitrevise/merge.py:225:12: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
  gitrevise/utils.py:73:8: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
  gitrevise/utils.py:89:12: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)

Simply adding the 'from' satisfies pylint.

Signed-off-by: Nicolas Schier <nicolas@fjasle.eu>
---
 gitrevise/merge.py | 4 ++--
 gitrevise/utils.py | 8 +++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/gitrevise/merge.py b/gitrevise/merge.py
index 9e0348d..30ff1c1 100644
--- a/gitrevise/merge.py
+++ b/gitrevise/merge.py
@@ -204,7 +204,7 @@ def merge_blobs(
         print(f"Conflict applying '{labels[2]}'")
         print(f"  Path: '{path}'")
         if input("  Edit conflicted file? (Y/n) ").lower() == "n":
-            raise MergeConflict("user aborted")
+            raise MergeConflict("user aborted") from err
 
         # Open the editor on the conflicted file. We ensure the relative path
         # matches the path of the original file for a better editor experience.
@@ -222,6 +222,6 @@ def merge_blobs(
 
         # Was the merge successful?
         if input("  Merge successful? (y/N) ").lower() != "y":
-            raise MergeConflict("user aborted")
+            raise MergeConflict("user aborted") from err
 
     return Blob(current.repo, merged)
diff --git a/gitrevise/utils.py b/gitrevise/utils.py
index 1395f6e..b3155e8 100644
--- a/gitrevise/utils.py
+++ b/gitrevise/utils.py
@@ -70,7 +70,7 @@ def edit_file_with_editor(editor: str, path: Path) -> bytes:
             cmd = ["sh", "-c", f'{editor} "$@"', editor, path.name]
         run(cmd, check=True, cwd=path.parent)
     except CalledProcessError as err:
-        raise EditorError(f"Editor exited with status {err}")
+        raise EditorError(f"Editor exited with status {err}") from err
     return path.read_bytes()
 
 
@@ -85,8 +85,10 @@ def get_commentchar(repo: Repository, text: bytes) -> bytes:
                 pass
         try:
             return chars[:1]
-        except IndexError:
-            raise EditorError("Unable to automatically select a comment character")
+        except IndexError as err:
+            raise EditorError(
+                "Unable to automatically select a comment character"
+            ) from err
     if commentchar == b"":
         raise EditorError("core.commentChar must not be empty")
     return commentchar
-- 
2.28.0

Attachment: signature.asc
Description: PGP signature


Reply to: