[meld/pathlabel: 10/10] Style and indentation fixes




commit de2630ef9f43cfc989e3a2d29e7a2a5be2ca148b
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Mon Dec 7 06:34:48 2020 +1000

    Style and indentation fixes

 meld/actiongutter.py | 12 ++++++------
 meld/dirdiff.py      | 12 ++++++------
 meld/filediff.py     |  2 +-
 meld/meldapp.py      |  4 ++--
 meld/melddoc.py      |  8 ++++----
 meld/misc.py         | 30 +++++++++++++++---------------
 meld/vc/_vc.py       |  4 ++--
 meld/vc/cvs.py       | 22 ++++++++++++++--------
 meld/vc/git.py       | 17 ++++++++++-------
 setup_win32.py       | 24 ++++++++++++------------
 10 files changed, 72 insertions(+), 63 deletions(-)
---
diff --git a/meld/actiongutter.py b/meld/actiongutter.py
index 1cf276da..1abc23db 100644
--- a/meld/actiongutter.py
+++ b/meld/actiongutter.py
@@ -143,12 +143,12 @@ class ActionGutter(Gtk.DrawingArea):
 
     @GObject.Signal
     def chunk_action_activated(
-            self,
-            action: str,  # String-ified ChunkAction
-            from_view: Gtk.TextView,
-            to_view: Gtk.TextView,
-            chunk: object,
-            ) -> None:
+        self,
+        action: str,  # String-ified ChunkAction
+        from_view: Gtk.TextView,
+        to_view: Gtk.TextView,
+        chunk: object,
+    ) -> None:
         ...
 
     def __init__(self):
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index c8982c22..7bc3c5ad 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -76,8 +76,8 @@ CacheResult = namedtuple('CacheResult', 'stats result')
 
 
 _cache = {}
-Same, SameFiltered, DodgySame, DodgyDifferent, Different, FileError = \
-    list(range(6))
+Same, SameFiltered, DodgySame, DodgyDifferent, Different, FileError = (
+    list(range(6)))
 # TODO: Get the block size from os.stat
 CHUNK_SIZE = 4096
 
@@ -118,7 +118,7 @@ def _contents_same(contents, file_size):
     other_files_index = list(range(1, len(contents)))
     chunk_range = zip(
         range(0, file_size, CHUNK_SIZE),
-        range(CHUNK_SIZE, file_size + CHUNK_SIZE, CHUNK_SIZE)
+        range(CHUNK_SIZE, file_size + CHUNK_SIZE, CHUNK_SIZE),
     )
 
     for start, end in chunk_range:
@@ -240,8 +240,8 @@ def _files_same(files, regexes, comparison_args):
 EMBLEM_NEW = "emblem-new"
 EMBLEM_SYMLINK = "emblem-symbolic-link"
 
-COL_EMBLEM, COL_EMBLEM_SECONDARY, COL_SIZE, COL_TIME, COL_PERMS, COL_END = \
-        range(tree.COL_END, tree.COL_END + 6)
+COL_EMBLEM, COL_EMBLEM_SECONDARY, COL_SIZE, COL_TIME, COL_PERMS, COL_END = (
+    range(tree.COL_END, tree.COL_END + 6))
 
 
 class DirDiffTreeStore(tree.DiffTreeStore):
@@ -253,7 +253,7 @@ class DirDiffTreeStore(tree.DiffTreeStore):
         defaults = {
             COL_TIME: MISSING_TIMESTAMP,
             COL_SIZE: -1,
-            COL_PERMS: -1
+            COL_PERMS: -1,
         }
         super().add_error(parent, msg, pane, defaults)
 
diff --git a/meld/filediff.py b/meld/filediff.py
index eef5a40f..eb208d30 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -2146,7 +2146,7 @@ class FileDiff(Gtk.VBox, MeldDoc):
     def queue_draw(self, junk=None):
         for t in self.textview:
             t.queue_draw()
-        for i in range(self.num_panes-1):
+        for i in range(self.num_panes - 1):
             self.linkmap[i].queue_draw()
         for gutter in self.actiongutter:
             gutter.queue_draw()
diff --git a/meld/meldapp.py b/meld/meldapp.py
index e2e2fbf6..43d3c295 100644
--- a/meld/meldapp.py
+++ b/meld/meldapp.py
@@ -41,8 +41,8 @@ class MeldApp(Gtk.Application):
 
     def __init__(self):
         super().__init__(
-          application_id=meld.conf.APPLICATION_ID,
-          flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE,
+            application_id=meld.conf.APPLICATION_ID,
+            flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE,
         )
         GLib.set_application_name(meld.conf.APPLICATION_NAME)
         GLib.set_prgname(meld.conf.APPLICATION_ID)
diff --git a/meld/melddoc.py b/meld/melddoc.py
index f3ffd888..d3f78fcc 100644
--- a/meld/melddoc.py
+++ b/meld/melddoc.py
@@ -22,7 +22,7 @@ import shlex
 import string
 import subprocess
 import sys
-from typing import Iterable, List, Optional, Sequence
+from typing import List, Optional, Sequence
 
 from gi.repository import Gdk, Gio, GLib, GObject, Gtk
 
@@ -42,7 +42,7 @@ def make_custom_editor_command(path: str, line: int = 0) -> Sequence[str]:
     if not any(replacements):
         return [custom_command, path]
     elif not all(r in (None, 'file', 'line') for r in replacements):
-        log.error("Unsupported fields found", )
+        log.error("Unsupported fields found")
         return [custom_command, path]
     else:
         cmd = custom_command.format(file=pipes.quote(path), line=line)
@@ -62,8 +62,8 @@ def open_files_external(
         elif sys.platform == "darwin":
             subprocess.Popen(["open", path])
         else:
-            Gtk.show_uri(Gdk.Screen.get_default(), uri,
-                         Gtk.get_current_event_time())
+            Gtk.show_uri(
+                Gdk.Screen.get_default(), uri, Gtk.get_current_event_time())
 
     def open_cb(source, result, *data):
         info = source.query_info_finish(result)
diff --git a/meld/misc.py b/meld/misc.py
index b0acec55..b7f7ef4f 100644
--- a/meld/misc.py
+++ b/meld/misc.py
@@ -92,12 +92,12 @@ def error_dialog(primary: str, secondary: str) -> Gtk.ResponseType:
 
 
 def modal_dialog(
-            primary: str,
-            secondary: str,
-            buttons: Union[Gtk.ButtonsType, Sequence[Tuple[str, int]]],
-            parent: Optional[Gtk.Window] = None,
-            messagetype: Gtk.MessageType = Gtk.MessageType.WARNING
-        ) -> Gtk.ResponseType:
+    primary: str,
+    secondary: str,
+    buttons: Union[Gtk.ButtonsType, Sequence[Tuple[str, int]]],
+    parent: Optional[Gtk.Window] = None,
+    messagetype: Gtk.MessageType = Gtk.MessageType.WARNING
+) -> Gtk.ResponseType:
     """A common message dialog handler for Meld
 
     This should only ever be used for interactions that must be resolved
@@ -205,11 +205,11 @@ SubprocessGenerator = Generator[Union[Tuple[int, str], None], None, None]
 
 
 def read_pipe_iter(
-            command: List[str],
-            workdir: str,
-            errorstream: 'ConsoleStream',
-            yield_interval: float = 0.1,
-        ) -> SubprocessGenerator:
+    command: List[str],
+    workdir: str,
+    errorstream: 'ConsoleStream',
+    yield_interval: float = 0.1,
+) -> SubprocessGenerator:
     """Read the output of a shell command iteratively.
 
     Each time 'callback_interval' seconds pass without reading any data,
@@ -372,10 +372,10 @@ def merge_intervals(
 
 
 def apply_text_filters(
-            txt: AnyStr,
-            regexes: Sequence[Pattern],
-            apply_fn: Optional[Callable[[int, int], None]] = None
-        ) -> AnyStr:
+    txt: AnyStr,
+    regexes: Sequence[Pattern],
+    apply_fn: Optional[Callable[[int, int], None]] = None
+) -> AnyStr:
     """Apply text filters
 
     Text filters "regexes", resolved as regular expressions are applied
diff --git a/meld/vc/_vc.py b/meld/vc/_vc.py
index e55449e8..18b13777 100644
--- a/meld/vc/_vc.py
+++ b/meld/vc/_vc.py
@@ -231,8 +231,8 @@ class Vc:
             valid_actions.add('add')
         if all(s == STATE_CONFLICT for s in states):
             valid_actions.add('resolve')
-        if (all(s not in non_removeable_states for s in states)
-                and self.root not in path_states.keys()):
+        if (all(s not in non_removeable_states for s in states) and
+                self.root not in path_states.keys()):
             valid_actions.add('remove')
         if all(s not in non_revertable_states for s in states):
             valid_actions.add('revert')
diff --git a/meld/vc/cvs.py b/meld/vc/cvs.py
index a1192af1..f0b59161 100644
--- a/meld/vc/cvs.py
+++ b/meld/vc/cvs.py
@@ -45,7 +45,7 @@ class Vc(_vc.Vc):
         "!":                _vc.STATE_MISSING,
         "I":                _vc.STATE_IGNORED,
         "Locally Modified": _vc.STATE_MODIFIED,
-        "Locally Removed":  _vc.STATE_REMOVED
+        "Locally Removed":  _vc.STATE_REMOVED,
     }
 
     def commit(self, runner, files, message):
@@ -59,13 +59,15 @@ class Vc(_vc.Vc):
     def add(self, runner, afiles):
         # CVS needs to add files together with all the parents
         # (if those are Unversioned yet)
-        relfiles = [os.path.relpath(s, self.root)
-                    for s in afiles if os.path.isfile(s)]
+        relfiles = [
+            os.path.relpath(s, self.root)
+            for s in afiles if os.path.isfile(s)
+        ]
         command = [self.CMD, 'add']
 
         relargs = []
         for f1 in relfiles:
-            positions = [i for i, ch in enumerate(f1+os.sep) if ch == os.sep]
+            positions = [i for i, ch in enumerate(f1 + os.sep) if ch == os.sep]
             arg1 = [f1[:pos] for pos in positions]
             relargs += arg1
 
@@ -115,10 +117,14 @@ class Vc(_vc.Vc):
                 files = self._find_files(path) if path_isdir else [path]
 
                 # Should suppress stderr here
-                proc = _vc.popen([self.CMD, "-Q", "status"] + files,
-                                 cwd=self.location)
-                entries = [li for li in proc.read().splitlines()
-                           if li.startswith('File:')]
+                proc = _vc.popen(
+                    [self.CMD, "-Q", "status"] + files,
+                    cwd=self.location,
+                )
+                entries = [
+                    li for li in proc.read().splitlines()
+                    if li.startswith('File:')
+                ]
                 break
             except OSError as e:
                 if e.errno != errno.EAGAIN:
diff --git a/meld/vc/git.py b/meld/vc/git.py
index 473e8590..4b25d721 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -89,15 +89,18 @@ class Vc(_vc.Vc):
                 # Translators: First %s is replaced by translated "%d unpushed
                 # commits", second %s is replaced by translated "%d branches"
                 label = _("%s in %s") % (
-                    ngettext("%d unpushed commit", "%d unpushed commits",
-                             unpushed_commits) % unpushed_commits,
-                    ngettext("%d branch", "%d branches",
-                             unpushed_branches) % unpushed_branches)
+                    ngettext(
+                        "%d unpushed commit", "%d unpushed commits",
+                        unpushed_commits) % unpushed_commits,
+                    ngettext(
+                        "%d branch", "%d branches",
+                        unpushed_branches) % unpushed_branches)
             else:
                 # Translators: These messages cover the case where there is
                 # only one branch, and are not part of another message.
-                label = ngettext("%d unpushed commit", "%d unpushed commits",
-                                 unpushed_commits) % (unpushed_commits)
+                label = ngettext(
+                    "%d unpushed commit", "%d unpushed commits",
+                    unpushed_commits) % (unpushed_commits)
         else:
             label = ""
         return label
@@ -216,7 +219,7 @@ class Vc(_vc.Vc):
 
             suffix = os.path.splitext(path)[1]
             filename, is_temp = self.remerge_with_ancestor(
-                    local, base, remote, suffix=suffix)
+                local, base, remote, suffix=suffix)
 
             for temp_file in (local, base, remote):
                 if os.name == "nt":
diff --git a/setup_win32.py b/setup_win32.py
index f8d4bebc..a6ac8811 100755
--- a/setup_win32.py
+++ b/setup_win32.py
@@ -39,10 +39,10 @@ def get_non_python_libs():
             inst_lib.append(os.path.join(local_bin, 'gspawn-win64-helper.exe'))
 
     return [
-            (f, os.path.basename(f)) for f in inst_root
-        ] + [
-            (f, os.path.join('lib', os.path.basename(f))) for f in inst_lib
-        ]
+        (f, os.path.basename(f)) for f in inst_root
+    ] + [
+        (f, os.path.join('lib', os.path.basename(f))) for f in inst_lib
+    ]
 
 
 gtk_data_dirs = [
@@ -64,7 +64,7 @@ for data_dir in gtk_data_dirs:
         data_subdir = os.path.relpath(local_data_subdir, local_data_dir)
         gtk_data_files.append((
             os.path.join(data_dir, data_subdir),
-            [os.path.join(local_data_subdir, file) for file in files]
+            [os.path.join(local_data_subdir, file) for file in files],
         ))
 
 manually_added_libs = {
@@ -100,14 +100,14 @@ registry_table = [
 # Provide the locator and app search to give MSI the existing install directory
 # for future upgrades
 reg_locator_table = [
-    ('MeldInstallDirLocate', 2, r'SOFTWARE\Meld', 'InstallDir', 0)
+    ('MeldInstallDirLocate', 2, r'SOFTWARE\Meld', 'InstallDir', 0),
 ]
 app_search_table = [('TARGETDIR', 'MeldInstallDirLocate')]
 
 msi_data = {
     'Registry': registry_table,
     'RegLocator': reg_locator_table,
-    'AppSearch': app_search_table
+    'AppSearch': app_search_table,
 }
 
 bdist_msi_options = {
@@ -125,13 +125,13 @@ console_executable_options = dict(executable_options)
 
 if 'mingw' in sysconfig.get_platform():
     executable_options.update({
-         "base": "Win32GUI",  # comment to build console version to see stderr
-         "targetName": "Meld.exe",
-         "shortcutName": "Meld",
-         "shortcutDir": "ProgramMenuFolder",
+        "base": "Win32GUI",  # comment to build console version to see stderr
+        "targetName": "Meld.exe",
+        "shortcutName": "Meld",
+        "shortcutDir": "ProgramMenuFolder",
     })
     console_executable_options.update({
-         "targetName": "MeldConsole.exe",
+        "targetName": "MeldConsole.exe",
     })
 
 # Copy conf.py in place if necessary


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