Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser committed May 18, 2015
1 parent e28934d commit 31fdb3d
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 28 deletions.
14 changes: 14 additions & 0 deletions .prospector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
strictness: medium
doc-warnings: false
test-warnings: false
max-line-length: 120
ignore-patterns:
- docs
- docs_theme
dodgy:
run: false
pylint:
disable:
- import-error
options:
ignored-modules: bracketremove
26 changes: 18 additions & 8 deletions bh_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ class BhCore(object):
def __init__(
self, override_thresh=False, count_lines=False,
adj_only=None, no_outside_adj=False,
ignore={}, plugin={}, keycommand=False
ignore=None, plugin=None, keycommand=False
):
"""Load settings and setup reload events if settings changes."""

if ignore is None:
ignore = {}
if plugin is None:
plugin = {}

self.settings = sublime.load_settings("bh_core.sublime-settings")
self.keycommand = keycommand
if not keycommand:
Expand All @@ -57,10 +62,15 @@ def __init__(

def setup(
self, override_thresh=False, count_lines=False, adj_only=None,
no_outside_adj=False, ignore={}, plugin={}
no_outside_adj=False, ignore=None, plugin=None
):
"""Initialize class settings from settings file and inputs."""

if ignore is None:
ignore = {}
if plugin is None:
plugin = {}

# Init view params
self.last_id_view = None
self.last_id_sel = None
Expand Down Expand Up @@ -230,7 +240,7 @@ def validate(self, b, bracket_type, scope_bracket=False):
bracket_type,
self.search.get_buffer()
)
except:
except Exception:
log("Plugin Bracket Find Error:\n%s" % str(traceback.format_exc()))
return match

Expand Down Expand Up @@ -258,7 +268,7 @@ def compare(self, first, second, scope_bracket=False):
bh_plugin.BracketRegion(second.begin, second.end),
self.search.get_buffer()
)
except:
except Exception:
log("Plugin Compare Error:\n%s" % str(traceback.format_exc()))
return match

Expand Down Expand Up @@ -322,7 +332,7 @@ def post_match(self, left, right, center, scope_bracket=False):
right = bh_search.BracketEntry(rbracket.begin, rbracket.end, bracket_type)
else:
right = None
except:
except Exception:
log("Plugin Post Match Error:\n%s" % str(traceback.format_exc()))

return left, right
Expand Down Expand Up @@ -420,7 +430,7 @@ def sub_search(self, sel, scope=None):

# Find brackets inside scope
bracket = None
left, right, scope_adj = self.match_brackets(sel, scope)
left, right = self.match_brackets(sel, scope)[:2]

regions = [sublime.Region(sel.a, sel.b)]

Expand Down Expand Up @@ -508,7 +518,7 @@ def match_scope_brackets(self, sel, adj_dir):
scope_search = self.search.new_scope_search(
center, before_center, scope, adj_dir
)
except:
except Exception:
# log(str(traceback.format_exc()))
scope_count += 1
continue
Expand Down Expand Up @@ -797,7 +807,7 @@ def run(self, set_value=None):
else:
settings.set("debug_enable", set_value)

def is_checked(self, set_value=None):
def is_checked(self):
"""Check if command should be checked in menu."""

return sublime.load_settings("bh_core.sublime-settings").get('debug_enable', False)
Expand Down
4 changes: 3 additions & 1 deletion bh_modules/bracketselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SelectBracket(bh_plugin.BracketPluginCommand):

"""Select Bracket plugin."""

def run(self, edit, name, select='', tags=DEFAULT_TAGS, always_include_brackets=False, alternate=False):
def run(self, edit, name, select='', tags=None, always_include_brackets=False, alternate=False):
"""
Select the content between brackets.
Expand All @@ -23,6 +23,8 @@ def run(self, edit, name, select='', tags=DEFAULT_TAGS, always_include_brackets=
parent.
"""

if tags is None:
tags = DEFAULT_TAGS
current_left, current_right = self.selection[0].begin(), self.selection[0].end()
left, right = self.left, self.right
first, last = left.end, right.begin
Expand Down
2 changes: 1 addition & 1 deletion bh_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def load_modules(obj, loaded):
obj["validate"] = getattr(module, "validate", None)
obj["highlighting"] = getattr(module, "highlighting", None)
loaded.add(plib)
except:
except Exception:
log("Could not load module %s\n%s" % (plib, str(traceback.format_exc())))
raise

Expand Down
16 changes: 6 additions & 10 deletions bh_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,42 +86,38 @@ def select_bracket_icons(option, icon_path):
pth = "%s/%s.png" % (icon_path, option)
sublime.load_binary_resource(pth)
icon = pth
except:
except Exception:
pass
try:
pth = "%s/%s_small.png" % (icon_path, option)
sublime.load_binary_resource(pth)
small_icon = pth
except:
except Exception:
pass
try:
pth = "%s/%s_open.png" % (icon_path, option)
sublime.load_binary_resource(pth)
open_icon = pth
except:
except Exception:
open_icon = icon
pass
try:
pth = "%s/%s_open_small.png" % (icon_path, option)
sublime.load_binary_resource(pth)
small_open_icon = pth
except:
except Exception:
small_open_icon = small_icon
pass
try:
pth = "%s/%s_close.png" % (icon_path, option)
sublime.load_binary_resource(pth)
close_icon = pth
except:
except Exception:
close_icon = icon
pass
try:
pth = "%s/%s_close_small.png" % (icon_path, option)
sublime.load_binary_resource(pth)
small_close_icon = pth
except:
except Exception:
small_close_icon = small_icon
pass

return icon, small_icon, open_icon, small_open_icon, close_icon, small_close_icon

Expand Down
2 changes: 1 addition & 1 deletion bh_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def findall(self):
try:
start = m.start(g)
end = m.end(g)
except:
except Exception:
continue

match_type = int(not bool(g % 2))
Expand Down
13 changes: 6 additions & 7 deletions ure.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
from os.path import exists, join
try:
import unicodedata
except:
except Exception:
from os.path import dirname
sys.path.append(dirname(sys.executable))
import unicodedata
try:
import cpickle as pickle
except:
except Exception:
import pickle
from os import unlink
PY3 = sys.version_info[0] >= 3
Expand Down Expand Up @@ -66,7 +66,7 @@ def _build_unicode_property_table(unicode_range):
try:
c = uchr(i)
p = unicodedata.category(c)
except:
except Exception:
continue
if p[0] not in table:
table[p[0]] = {}
Expand All @@ -75,7 +75,7 @@ def _build_unicode_property_table(unicode_range):
table[p[0]][p[1]].append(c)

# Join as one string
for k1, v1 in table.items():
for v1 in table.values():
for k2, v2 in v1.items():
v1[k2] = ''.join(v2)

Expand Down Expand Up @@ -160,7 +160,6 @@ def parse_unicode_properties(re_pattern):
"""Replace regex property notation with unicode values."""

# Init unicode table if it has not already been initialized
global _loaded
if not _loaded:
_init_unicode()

Expand All @@ -181,7 +180,7 @@ def parse_unicode_properties(re_pattern):
return ure_pattern


def compile(pattern, flags=0):
def compile(pattern, flags=0): # pylint: disable=redefined-builtin
"""compile after parsing unicode properties and set flag to unicode."""

return re.compile(parse_unicode_properties(pattern), flags | re.UNICODE)
Expand Down Expand Up @@ -226,7 +225,7 @@ def sub(pattern, repl, string, count=0, flags=0):
def subn(pattern, repl, string, count=0, flags=0):
"""subn after parsing unicode properties and set flag to unicode."""

re.subn(parse_unicode_properties(pattern), repl, string, flags | re.UNICODE)
re.subn(parse_unicode_properties(pattern), repl, string, count, flags | re.UNICODE)


# _init_unicode()
Expand Down

0 comments on commit 31fdb3d

Please sign in to comment.