File: 0002-satisfy-pylint-raise-missing-from-warnings.patch

package info (click to toggle)
git-revise 0.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 336 kB
  • sloc: python: 1,841; makefile: 16
file content (58 lines) | stat: -rw-r--r-- 2,486 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Description: 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.
Author: Nicolas Schier <nicolas@fjasle.eu>
Bug-Debian: https://bugs.debian.org/964862
Forwarded: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=964862#22
Last-Update: 2020-09-07

--- a/gitrevise/merge.py
+++ b/gitrevise/merge.py
@@ -204,7 +204,7 @@
         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 @@
 
         # 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)
--- a/gitrevise/utils.py
+++ b/gitrevise/utils.py
@@ -70,7 +70,7 @@
             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 @@
                 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