Prepare for Black autoformatting: dependencies, string staging, single-quote string override

This commit is contained in:
Josh Klar
2019-07-24 22:56:10 -07:00
parent 8100b91dbc
commit 5c0c13e8d0
15 changed files with 159 additions and 60 deletions

View File

@@ -2,13 +2,17 @@ from kmk.kmktime import ticks_diff, ticks_ms
def df_pressed(key, state, *args, **kwargs):
"""Switches the default layer"""
'''
Switches the default layer
'''
state.active_layers[-1] = key.meta.layer
return state
def mo_pressed(key, state, *args, **kwargs):
"""Momentarily activates layer, switches off when you let go"""
'''
Momentarily activates layer, switches off when you let go
'''
state.active_layers.insert(0, key.meta.layer)
return state
@@ -32,7 +36,9 @@ def mo_released(key, state, KC, *args, **kwargs):
def lm_pressed(key, state, *args, **kwargs):
"""As MO(layer) but with mod active"""
'''
As MO(layer) but with mod active
'''
state.hid_pending = True
# Sets the timer start and acts like MO otherwise
state.start_time['lm'] = ticks_ms()
@@ -41,7 +47,9 @@ def lm_pressed(key, state, *args, **kwargs):
def lm_released(key, state, *args, **kwargs):
"""As MO(layer) but with mod active"""
'''
As MO(layer) but with mod active
'''
state.hid_pending = True
state.keys_pressed.discard(key.meta.kc)
state.start_time['lm'] = None
@@ -68,8 +76,9 @@ def lt_released(key, state, *args, **kwargs):
def tg_pressed(key, state, *args, **kwargs):
"""Toggles the layer (enables it if not active, and vise versa)"""
'''
Toggles the layer (enables it if not active, and vise versa)
'''
# See mo_released for implementation details around this
try:
del_idx = state.active_layers.index(key.meta.layer)
@@ -81,7 +90,9 @@ def tg_pressed(key, state, *args, **kwargs):
def to_pressed(key, state, *args, **kwargs):
"""Activates layer and deactivates all other layers"""
'''
Activates layer and deactivates all other layers
'''
state.active_layers.clear()
state.active_layers.insert(0, key.meta.layer)
@@ -89,7 +100,9 @@ def to_pressed(key, state, *args, **kwargs):
def tt_pressed(key, state, *args, **kwargs):
"""Momentarily activates layer if held, toggles it if tapped repeatedly"""
'''
Momentarily activates layer if held, toggles it if tapped repeatedly
'''
# TODO Make this work with tap dance to function more correctly, but technically works.
if state.start_time['tt'] is None:
# Sets the timer start and acts like MO otherwise

View File

@@ -274,10 +274,9 @@ class KeyboardConfig:
if self.split_flip and not self.is_master:
self.col_pins = list(reversed(self.col_pins))
if self.split_side == "Left":
if self.split_side == 'Left':
self.split_master_left = self.is_master
elif self.split_side == "Right":
elif self.split_side == 'Right':
self.split_master_left = not self.is_master
else:
self.is_master = True

View File

@@ -361,7 +361,7 @@ def make_argumented_key(
else:
raise ValueError(
'Argumented key validator failed for unknown reasons. '
'This may not be the keymap\'s fault, as a more specific error '
"This may not be the keymap's fault, as a more specific error "
'should have been raised.',
)
@@ -439,7 +439,7 @@ make_key(code=47, names=('LBRACKET', 'LBRC', '['))
make_key(code=48, names=('RBRACKET', 'RBRC', ']'))
make_key(code=49, names=('BACKSLASH', 'BSLASH', 'BSLS', '\\'))
make_key(code=51, names=('SEMICOLON', 'SCOLON', 'SCLN', ';'))
make_key(code=52, names=('QUOTE', 'QUOT', '\''))
make_key(code=52, names=('QUOTE', 'QUOT', "'"))
make_key(code=53, names=('GRAVE', 'GRV', 'ZKHK', '`'))
make_key(code=54, names=('COMMA', 'COMM', ','))
make_key(code=55, names=('DOT', '.'))
@@ -539,7 +539,7 @@ make_shifted_key('LBRACKET', names=('LEFT_CURLY_BRACE', 'LCBR', '{'))
make_shifted_key('RBRACKET', names=('RIGHT_CURLY_BRACE', 'RCBR', '}'))
make_shifted_key('BACKSLASH', names=('PIPE', '|'))
make_shifted_key('SEMICOLON', names=('COLON', 'COLN', ':'))
make_shifted_key('QUOTE', names=('DOUBLE_QUOTE', 'DQUO', 'DQT', '\''))
make_shifted_key('QUOTE', names=('DOUBLE_QUOTE', 'DQUO', 'DQT', '"'))
make_shifted_key('COMMA', names=('LEFT_ANGLE_BRACKET', 'LABK', '<'))
make_shifted_key('DOT', names=('RIGHT_ANGLE_BRACKET', 'RABK', '>'))
make_shifted_key('SLSH', names=('QUESTION', 'QUES', '?'))

View File

@@ -88,20 +88,20 @@ class led:
self.set_brightness(0)
def increase_ani(self):
"""
'''
Increases animation speed by 1 amount stopping at 10
:param step:
"""
'''
if (self.animation_speed + 1) >= 10:
self.animation_speed = 10
else:
self.val += 1
def decrease_ani(self):
"""
'''
Decreases animation speed by 1 amount stopping at 0
:param step:
"""
'''
if (self.val - 1) <= 0:
self.val = 0
else:
@@ -127,10 +127,10 @@ class led:
return self
def animate(self):
"""
'''
Activates a "step" in the animation based on the active mode
:return: Returns the new state in animation
"""
'''
if self.effect_init:
self._init_effect()
if self.enabled:

View File

@@ -97,13 +97,13 @@ class RGB:
return int(time.monotonic() * 1000)
def hsv_to_rgb(self, hue, sat, val):
"""
'''
Converts HSV values, and returns a tuple of RGB values
:param hue:
:param sat:
:param val:
:return: (r, g, b)
"""
'''
r = 0
g = 0
b = 0
@@ -149,24 +149,24 @@ class RGB:
return int(r), int(g), int(b)
def hsv_to_rgbw(self, hue, sat, val):
"""
'''
Converts HSV values, and returns a tuple of RGBW values
:param hue:
:param sat:
:param val:
:return: (r, g, b, w)
"""
'''
rgb = self.hsv_to_rgb(hue, sat, val)
return rgb[0], rgb[1], rgb[2], min(rgb)
def set_hsv(self, hue, sat, val, index):
"""
'''
Takes HSV values and displays it on a single LED/Neopixel
:param hue:
:param sat:
:param val:
:param index: Index of LED/Pixel
"""
'''
if self.neopixel:
if self.rgbw:
self.set_rgb(self.hsv_to_rgbw(hue, sat, val), index)
@@ -176,12 +176,12 @@ class RGB:
return self
def set_hsv_fill(self, hue, sat, val):
"""
'''
Takes HSV values and displays it on all LEDs/Neopixels
:param hue:
:param sat:
:param val:
"""
'''
if self.neopixel:
if self.rgbw:
self.set_rgb_fill(self.hsv_to_rgbw(hue, sat, val))
@@ -190,11 +190,11 @@ class RGB:
return self
def set_rgb(self, rgb, index):
"""
'''
Takes an RGB or RGBW and displays it on a single LED/Neopixel
:param rgb: RGB or RGBW
:param index: Index of LED/Pixel
"""
'''
if self.neopixel and 0 <= index <= self.num_pixels - 1:
self.neopixel[index] = rgb
if not self.disable_auto_write:
@@ -203,10 +203,10 @@ class RGB:
return self
def set_rgb_fill(self, rgb):
"""
'''
Takes an RGB or RGBW and displays it on all LEDs/Neopixels
:param rgb: RGB or RGBW
"""
'''
if self.neopixel:
self.neopixel.fill(rgb)
if not self.disable_auto_write:
@@ -215,10 +215,10 @@ class RGB:
return self
def increase_hue(self, step=None):
"""
'''
Increases hue by step amount rolling at 360 and returning to 0
:param step:
"""
'''
if not step:
step = self.hue_step
@@ -230,10 +230,10 @@ class RGB:
return self
def decrease_hue(self, step=None):
"""
'''
Decreases hue by step amount rolling at 0 and returning to 360
:param step:
"""
'''
if not step:
step = self.hue_step
@@ -248,10 +248,10 @@ class RGB:
return self
def increase_sat(self, step=None):
"""
'''
Increases saturation by step amount stopping at 100
:param step:
"""
'''
if not step:
step = self.sat_step
@@ -266,10 +266,10 @@ class RGB:
return self
def decrease_sat(self, step=None):
"""
'''
Decreases saturation by step amount stopping at 0
:param step:
"""
'''
if not step:
step = self.sat_step
@@ -284,10 +284,10 @@ class RGB:
return self
def increase_val(self, step=None):
"""
'''
Increases value by step amount stopping at 100
:param step:
"""
'''
if not step:
step = self.val_step
if (self.val + step) >= 100:
@@ -301,10 +301,10 @@ class RGB:
return self
def decrease_val(self, step=None):
"""
'''
Decreases value by step amount stopping at 0
:param step:
"""
'''
if not step:
step = self.val_step
if (self.val - step) <= 0:
@@ -318,20 +318,20 @@ class RGB:
return self
def increase_ani(self):
"""
'''
Increases animation speed by 1 amount stopping at 10
:param step:
"""
'''
if (self.animation_speed + 1) >= 10:
self.animation_speed = 10
else:
self.val += 1
def decrease_ani(self):
"""
'''
Decreases animation speed by 1 amount stopping at 0
:param step:
"""
'''
if (self.val - 1) <= 0:
self.val = 0
else:
@@ -340,28 +340,28 @@ class RGB:
return self
def off(self):
"""
'''
Turns off all LEDs/Neopixels without changing stored values
"""
'''
if self.neopixel:
self.set_hsv_fill(0, 0, 0)
return self
def show(self):
"""
'''
Turns on all LEDs/Neopixels without changing stored values
"""
'''
if self.neopixel:
self.neopixel.show()
return self
def animate(self):
"""
'''
Activates a "step" in the animation based on the active mode
:return: Returns the new state in animation
"""
'''
if self.effect_init:
self._init_effect()