WIP: Fix pycodestyle errors (#653)
* Fix pycodestyle errors W503 is condracting PEP-8 and was added to the default ignore list by pycodestyle developers * Use setup.cfg for pycodestyle ignore parameters Addresses #651 (kind of). Appending ignores to the default list prevents us from getting warnings that we don't care about. * W503 is not in the default ignore list in 2.4.0
This commit is contained in:
parent
0dad095c07
commit
0d7156b5b1
@ -9,7 +9,7 @@ BUILD=${1:-ci-build}
|
||||
rm -rf ${BUILD}/
|
||||
mkdir -p $BUILD
|
||||
|
||||
python3 -mpycodestyle --ignore E501,E741,E305,E722 i3pystatus tests
|
||||
python3 -mpycodestyle i3pystatus tests
|
||||
|
||||
# Check that the setup.py script works
|
||||
rm -rf ${BUILD}/test-install ${BUILD}/test-install-bin
|
||||
|
@ -13,9 +13,9 @@ class ClassFinder:
|
||||
def predicate_factory(self, module):
|
||||
def predicate(obj):
|
||||
return (
|
||||
inspect.isclass(obj) and
|
||||
issubclass(obj, self.baseclass) and
|
||||
obj.__module__ == module.__name__
|
||||
inspect.isclass(obj)
|
||||
and issubclass(obj, self.baseclass)
|
||||
and obj.__module__ == module.__name__
|
||||
)
|
||||
|
||||
return predicate
|
||||
|
@ -271,7 +271,7 @@ def formatp(string, **kwargs):
|
||||
return subtree
|
||||
|
||||
def merge_tree(items):
|
||||
return "".join(flatten(items)).replace("\]", "]").replace("\[", "[")
|
||||
return "".join(flatten(items)).replace(r"\]", "]").replace(r"\[", "[")
|
||||
|
||||
stack = build_stack(string)
|
||||
tree = build_tree(stack, 0)
|
||||
|
@ -171,8 +171,8 @@ cleartext to the server.)"),
|
||||
full_text = formatp(self.format, **fdict).strip()
|
||||
full_text_len = len(full_text)
|
||||
if full_text_len > self.max_len and self.max_len > 0:
|
||||
shrink = floor((self.max_len - full_text_len) /
|
||||
len(self.truncate_fields)) - 1
|
||||
shrink = floor((self.max_len - full_text_len)
|
||||
/ len(self.truncate_fields)) - 1
|
||||
|
||||
for key in self.truncate_fields:
|
||||
fdict[key] = fdict[key][:shrink] + "…"
|
||||
|
@ -353,8 +353,8 @@ class Network(IntervalModule, ColorRangeModule):
|
||||
|
||||
def init(self):
|
||||
# Don't require importing basiciw unless using the functionality it offers.
|
||||
if any(s in self.format_down or s in self.format_up or
|
||||
any(s in f for f in self.format_active_up.values())
|
||||
if any(s in self.format_down or s in self.format_up
|
||||
or any(s in f for f in self.format_active_up.values())
|
||||
for s in ['essid', 'freq', 'quality', 'quality_bar']):
|
||||
get_wifi_info = True
|
||||
else:
|
||||
|
@ -160,10 +160,10 @@ https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html
|
||||
"title": currentsong.get("xesam:title", ""),
|
||||
"album": currentsong.get("xesam:album", ""),
|
||||
"artist": ", ".join(currentsong.get("xesam:artist", "")),
|
||||
"song_length": TimeWrapper((currentsong.get("mpris:length") or
|
||||
0) / 1000 ** 2),
|
||||
"song_elapsed": TimeWrapper((get_prop("Position") or 0) /
|
||||
1000 ** 2),
|
||||
"song_length": TimeWrapper(
|
||||
(currentsong.get("mpris:length") or 0) / 1000 ** 2),
|
||||
"song_elapsed": TimeWrapper(
|
||||
(get_prop("Position") or 0) / 1000 ** 2),
|
||||
"filename": "",
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ class PulseAudio(Module, ColorRangeModule):
|
||||
if self.move_sink_inputs:
|
||||
sink_inputs = subprocess.check_output("pacmd list-sink-inputs".split(),
|
||||
universal_newlines=True)
|
||||
for input_index in re.findall('index:\s+(\d+)', sink_inputs):
|
||||
for input_index in re.findall(r'index:\s+(\d+)', sink_inputs):
|
||||
command = "pacmd move-sink-input {} {}".format(input_index, next_sink)
|
||||
|
||||
# Not all applications can be moved and pulseaudio, and when
|
||||
|
@ -75,9 +75,9 @@ class Reddit(IntervalModule):
|
||||
_permalink = ""
|
||||
_url = ""
|
||||
|
||||
subreddit_pattern = re.compile("\{submission_\w+\}")
|
||||
message_pattern = re.compile("\{message_\w+\}")
|
||||
user_pattern = re.compile("\{comment_karma\}|\{link_karma\}")
|
||||
subreddit_pattern = re.compile(r"{submission_\w+}")
|
||||
message_pattern = re.compile(r"{message_\w+\}")
|
||||
user_pattern = re.compile(r"{comment_karma}|{link_karma}")
|
||||
|
||||
reddit_session = None
|
||||
|
||||
|
@ -56,9 +56,10 @@ class WindowTitle(Module):
|
||||
|
||||
# don't show window title when the window already has means
|
||||
# to display it
|
||||
if (not self.always_show and
|
||||
(w.border == "normal" or w.type == "workspace" or
|
||||
(p.layout in ("stacked", "tabbed") and len(p.nodes) > 1))):
|
||||
if (not self.always_show
|
||||
and (w.border == "normal"
|
||||
or w.type == "workspace"
|
||||
or (p.layout in ("stacked", "tabbed") and len(p.nodes) > 1))):
|
||||
return self.empty_title
|
||||
else:
|
||||
title = w.name
|
||||
@ -74,10 +75,10 @@ class WindowTitle(Module):
|
||||
# check if we need to update title due to changes
|
||||
# in the workspace layout
|
||||
layout_changed = (
|
||||
hasattr(e, "binding") and
|
||||
(e.binding.command.startswith("layout") or
|
||||
e.binding.command.startswith("move container") or
|
||||
e.binding.command.startswith("border"))
|
||||
hasattr(e, "binding")
|
||||
and (e.binding.command.startswith("layout")
|
||||
or e.binding.command.startswith("move container")
|
||||
or e.binding.command.startswith("border"))
|
||||
)
|
||||
|
||||
if title_changed or layout_changed:
|
||||
|
2
setup.cfg
Normal file
2
setup.cfg
Normal file
@ -0,0 +1,2 @@
|
||||
[pycodestyle]
|
||||
ignore = E501,W503,W504,E741,E305,E722
|
@ -189,7 +189,7 @@ class KeyConstraintDictAdvancedTests(unittest.TestCase):
|
||||
|
||||
class FormatPTests(unittest.TestCase):
|
||||
def test_escaping(self):
|
||||
assert util.formatp("[razamba \[ mabe \]]") == "razamba [ mabe ]"
|
||||
assert util.formatp(r"[razamba \[ mabe \]]") == "razamba [ mabe ]"
|
||||
|
||||
def test_numerical(self):
|
||||
assert util.formatp("[{t} - [schmuh {x}]]", t=1, x=2) == "1 - schmuh 2"
|
||||
|
Loading…
Reference in New Issue
Block a user