From b8f8a3dce9db6b8170f524fe65ed8e92c60dfe5f Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 6 Jul 2019 22:03:58 +0200 Subject: [PATCH 1/3] Run flake8 on CI --- .travis.yml | 3 ++- appveyor.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ccf17fae2..4b2047ee3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,12 +30,13 @@ before_install: install: - sh travis.sh bootstrap - sh travis.sh install_package_control - - pip3 install python-coveralls pycodestyle; + - pip3 install python-coveralls pycodestyle flake8; script: - sh travis.sh run_tests --coverage - sh travis.sh run_syntax_tests - pycodestyle --statistics --count + - flake8 cmdbox after_success: - coveralls diff --git a/appveyor.yml b/appveyor.yml index 84af9eb34..43a626c71 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,7 +12,7 @@ install: - ps: .\appveyor.ps1 "install_package_control" -verbose - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" - ps: python -m pip install --upgrade pip - - ps: pip install pycodestyle + - ps: pip install pycodestyle flake8 build: off @@ -20,3 +20,4 @@ test_script: - ps: .\appveyor.ps1 "run_tests" -verbose - ps: .\appveyor.ps1 "run_syntax_tests" -verbose - ps: pycodestyle --statistics --count + - ps: flake8 cmdbox From 60f2655869bd6bd60067a6f8f12127552c7a8682 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 6 Jul 2019 22:36:21 +0200 Subject: [PATCH 2/3] Fix flake8 errors --- core/commands/amend.py | 5 +---- core/commands/blame.py | 2 +- core/commands/cherry_pick.py | 1 - core/commands/inline_diff.py | 7 +++---- core/commands/log.py | 1 - core/commands/rebase_interactive.py | 1 - core/commands/reflog.py | 1 - core/commands/show_commit.py | 1 - core/commands/show_file_at_commit.py | 1 - core/commands/status_bar.py | 2 +- setup.cfg | 2 ++ 11 files changed, 8 insertions(+), 16 deletions(-) diff --git a/core/commands/amend.py b/core/commands/amend.py index 410b6d3e4..21e41439c 100644 --- a/core/commands/amend.py +++ b/core/commands/amend.py @@ -1,7 +1,4 @@ -import os - -import sublime -from sublime_plugin import WindowCommand, TextCommand +from sublime_plugin import WindowCommand from ..git_command import GitCommand diff --git a/core/commands/blame.py b/core/commands/blame.py index 478c4cc01..1cee70e19 100644 --- a/core/commands/blame.py +++ b/core/commands/blame.py @@ -269,7 +269,7 @@ def parse_blame(self, blame_porcelain): # Iterate through header keys and values. try: k, v = re.match(r"([^ ]+) (.+)", next_line).groups() - except AttributeError as e: + except AttributeError: # Sometimes git-blame includes keys without values; # since we don't care about these, simply discard. print("Skipping blame line: " + repr(next_line)) diff --git a/core/commands/cherry_pick.py b/core/commands/cherry_pick.py index adf0ec185..909300656 100644 --- a/core/commands/cherry_pick.py +++ b/core/commands/cherry_pick.py @@ -1,5 +1,4 @@ import sublime -from sublime_plugin import TextCommand from .log import GsLogByBranchCommand from ...common import util diff --git a/core/commands/inline_diff.py b/core/commands/inline_diff.py index bec1abf4c..a358129e2 100644 --- a/core/commands/inline_diff.py +++ b/core/commands/inline_diff.py @@ -9,7 +9,6 @@ from ...common.theme_generator import XMLThemeGenerator, JSONThemeGenerator from ..git_command import GitCommand from ..constants import MERGE_CONFLICT_PORCELAIN_STATUSES -from ...common.util import debug HunkReference = namedtuple("HunkReference", ("section_start", "section_end", "hunk", "line_types", "lines")) @@ -72,11 +71,11 @@ def run_async(self, settings=None, cached=False): settings["git_savvy.repo_path"], settings["git_savvy.file_path"]) try: file_binary.decode() - except UnicodeDecodeError as unicode_err: + except UnicodeDecodeError: try: file_binary.decode("latin-1") diff_view.settings().set("git_savvy.inline_diff.encoding", "latin-1") - except UnicodeDecodeError as unicode_err: + except UnicodeDecodeError: fallback_encoding = self.savvy_settings.get("fallback_encoding") diff_view.settings().set("git_savvy.inline_diff.encoding", fallback_encoding) @@ -479,7 +478,7 @@ def get_diff_from_line(self, line_no, reset): if reset: xhead_start = head_start - index_in_hunk + (0 if line_type == "+" else add_length_earlier_in_diff) - xnew_start = head_start - cur_hunk_begin_on_minus + index_in_hunk + add_length_earlier_in_diff - 1 + # xnew_start = head_start - cur_hunk_begin_on_minus + index_in_hunk + add_length_earlier_in_diff - 1 return ( "@@ -{head_start},{head_length} +{new_start},{new_length} @@\n" diff --git a/core/commands/log.py b/core/commands/log.py index 4d06ce651..f30c89e49 100644 --- a/core/commands/log.py +++ b/core/commands/log.py @@ -4,7 +4,6 @@ from sublime_plugin import WindowCommand import sublime -from ...common import util from ..git_command import GitCommand from ..ui_mixins.quick_panel import PanelActionMixin, PanelCommandMixin from ..ui_mixins.quick_panel import show_log_panel, show_branch_panel diff --git a/core/commands/rebase_interactive.py b/core/commands/rebase_interactive.py index 5b86673c3..ef4a7eb14 100644 --- a/core/commands/rebase_interactive.py +++ b/core/commands/rebase_interactive.py @@ -6,7 +6,6 @@ class GsRebaseInteractiveTerminalCommand(TextCommand): """ Change current lines to be change to new type """ def run(self, edit, type): - scopes = self.view.find_by_selector('meta.git-savvy.rebase-interactive.line') for sel in self.view.sel(): line = self.view.line(sel.a) first_space = self.view.substr(line).find(" ") diff --git a/core/commands/reflog.py b/core/commands/reflog.py index da5d9eb46..3f2f71b73 100644 --- a/core/commands/reflog.py +++ b/core/commands/reflog.py @@ -2,7 +2,6 @@ from sublime_plugin import WindowCommand from ..git_command import GitCommand -from .log import LogMixin from ..ui_mixins.quick_panel import show_paginated_panel diff --git a/core/commands/show_commit.py b/core/commands/show_commit.py index 7ceadc2d4..0a4fbb694 100644 --- a/core/commands/show_commit.py +++ b/core/commands/show_commit.py @@ -1,6 +1,5 @@ import os -import sublime from sublime_plugin import WindowCommand, TextCommand from ..git_command import GitCommand diff --git a/core/commands/show_file_at_commit.py b/core/commands/show_file_at_commit.py index 37834d198..6bdead10d 100644 --- a/core/commands/show_file_at_commit.py +++ b/core/commands/show_file_at_commit.py @@ -1,4 +1,3 @@ -import re import sublime from sublime_plugin import WindowCommand diff --git a/core/commands/status_bar.py b/core/commands/status_bar.py index 5cef7b076..99bc5e938 100644 --- a/core/commands/status_bar.py +++ b/core/commands/status_bar.py @@ -85,7 +85,7 @@ def run_async(self): self.get_repo_path(offer_init=False) # check for ValueError short_status = self.get_branch_status_short() self.view.set_status("gitsavvy-repo-status", short_status) - except Exception as e: + except Exception: self.view.erase_status("gitsavvy-repo-status") global update_status_bar_soon diff --git a/setup.cfg b/setup.cfg index 81a067464..6122f3ec5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,3 +19,5 @@ exclude = tests/mockito, tests/parameterized/, .svn,CVS,.bzr,.hg,.git +per-file-ignores = + **/__init__.py:F401, F403 From ca356a1cf96de922be7c7fa23ab0307b036b569f Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 7 Jul 2019 19:18:26 +0200 Subject: [PATCH 3/3] Remove pycodestyle since it's run by flake8 --- .travis.yml | 3 +-- appveyor.yml | 3 +-- setup.cfg | 9 --------- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4b2047ee3..b70f49be9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,12 +30,11 @@ before_install: install: - sh travis.sh bootstrap - sh travis.sh install_package_control - - pip3 install python-coveralls pycodestyle flake8; + - pip3 install python-coveralls flake8; script: - sh travis.sh run_tests --coverage - sh travis.sh run_syntax_tests - - pycodestyle --statistics --count - flake8 cmdbox after_success: diff --git a/appveyor.yml b/appveyor.yml index 43a626c71..391914707 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,12 +12,11 @@ install: - ps: .\appveyor.ps1 "install_package_control" -verbose - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" - ps: python -m pip install --upgrade pip - - ps: pip install pycodestyle flake8 + - ps: pip install flake8 build: off test_script: - ps: .\appveyor.ps1 "run_tests" -verbose - ps: .\appveyor.ps1 "run_syntax_tests" -verbose - - ps: pycodestyle --statistics --count - ps: flake8 cmdbox diff --git a/setup.cfg b/setup.cfg index 6122f3ec5..b21076eb0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,12 +1,3 @@ -[pycodestyle] -count = False -ignore = E401, E731, W503, W504 -max-line-length = 120 -exclude = - tests/mockito, - tests/parameterized/, - .svn,CVS,.bzr,.hg,.git - [flake8] max-line-length = 120 ignore =