Skip to content

Commit a65444e

Browse files
authored
Make the code black (#125)
1 parent 69047da commit a65444e

16 files changed

Lines changed: 309 additions & 264 deletions

File tree

.github/workflows/build.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@ jobs:
3131
run: |
3232
tox -e $TOX_ENV
3333
34+
black:
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- uses: actions/checkout@v2
39+
- name: Set up Python 3.x
40+
uses: actions/setup-python@v2
41+
with:
42+
python-version: '3.9'
43+
- name: Install dependencies
44+
run: |
45+
python -m pip install --upgrade pip
46+
pip install black invoke
47+
- name: Run linting
48+
run: invoke check-black
49+
50+
3451
flake8:
3552
runs-on: ubuntu-latest
3653

sockpuppet/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import channels
22

3-
channels_version = channels.__version__.split('.')[0]
3+
channels_version = channels.__version__.split(".")[0]
44
if int(channels_version) >= 3:
5-
from sockpuppet.consumer import SockpuppetConsumerAsgi as SockpuppetConsumer # noqa
5+
from sockpuppet.consumer import SockpuppetConsumerAsgi as SockpuppetConsumer # noqa
66
else:
7-
from sockpuppet.consumer import SockpuppetConsumer # noqa
7+
from sockpuppet.consumer import SockpuppetConsumer # noqa
88

9-
__version__ = '0.6.0'
9+
__version__ = "0.6.0"

sockpuppet/apps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44

55
class SockpuppetConfig(AppConfig):
6-
name = 'sockpuppet'
6+
name = "sockpuppet"

sockpuppet/channel.py

Lines changed: 79 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class Channel:
12-
'''
12+
"""
1313
Accepts a name which should either be the name of the group
1414
or the channel_name to which the content will be broadcast to.
1515
@@ -20,11 +20,11 @@ class Channel:
2020
If you're using this and initializes this with the session key as a name.
2121
You need to set the identifier to '{"channel":"StimulusReflex::Channel"}'
2222
which is the default identifier in the frontend.
23-
'''
23+
"""
2424

25-
def __init__(self, name, identifier=''):
25+
def __init__(self, name, identifier=""):
2626
if not identifier:
27-
identifier = json.dumps({'channel': name}).replace(' ', '')
27+
identifier = json.dumps({"channel": name}).replace(" ", "")
2828
self.identifier = identifier
2929
self.name = name
3030
self.operations = self.stub()
@@ -37,27 +37,28 @@ def add_operation(self, key, options):
3737

3838
def stub(self):
3939
return {
40-
'dispatch_event': [],
41-
'morph': [],
42-
'inner_html': [],
43-
'outer_html': [],
44-
'text_content': [],
45-
'insert_adjacent_html': [],
46-
'insert_adjacent_text': [],
47-
'remove': [],
48-
'set_value': [],
49-
'set_attribute': [],
50-
'remove_attribute': [],
51-
'add_css_class': [],
52-
'remove_css_class': [],
53-
'set_dataset_property': [],
54-
'set_style': []
40+
"dispatch_event": [],
41+
"morph": [],
42+
"inner_html": [],
43+
"outer_html": [],
44+
"text_content": [],
45+
"insert_adjacent_html": [],
46+
"insert_adjacent_text": [],
47+
"remove": [],
48+
"set_value": [],
49+
"set_attribute": [],
50+
"remove_attribute": [],
51+
"add_css_class": [],
52+
"remove_css_class": [],
53+
"set_dataset_property": [],
54+
"set_style": [],
5555
}
5656

5757
def broadcast(self):
5858
operations = {
5959
camelcase(key): camelize_value(value)
60-
for key, value in self.operations.items() if value
60+
for key, value in self.operations.items()
61+
if value
6162
}
6263
channel_layer = get_channel_layer()
6364
group_send = async_to_sync(channel_layer.group_send)
@@ -67,24 +68,24 @@ def broadcast(self):
6768
"identifier": self.identifier,
6869
"type": "message",
6970
"cableReady": True,
70-
"operations": operations
71-
}
71+
"operations": operations,
72+
},
7273
)
7374
self.clear()
7475

7576
def dispatch_event(self, options={}):
76-
'''
77+
"""
7778
dispatch_event: [{
7879
name: "string",
7980
detail: "object",
8081
selector: "string",
8182
}, ...
8283
],
83-
'''
84-
self.add_operation('dispatch_event', options)
84+
"""
85+
self.add_operation("dispatch_event", options)
8586

8687
def morph(self, options={}):
87-
'''
88+
"""
8889
morph: [{
8990
selector: "string",
9091
html: "string"
@@ -93,120 +94,120 @@ def morph(self, options={}):
9394
focus_selector: "string",
9495
}, ...
9596
],
96-
'''
97-
self.add_operation('morph', options)
97+
"""
98+
self.add_operation("morph", options)
9899

99100
def inner_html(self, options={}):
100-
'''
101-
inner_html: [{
102-
selector: "string",
103-
focus_selector: "string",
104-
html: "string"
105-
}, ...],
106-
'''
107-
self.add_operation('inner_html', options)
101+
"""
102+
inner_html: [{
103+
selector: "string",
104+
focus_selector: "string",
105+
html: "string"
106+
}, ...],
107+
"""
108+
self.add_operation("inner_html", options)
108109

109110
def outer_html(self, options={}):
110-
'''
111-
outer_html: [{
112-
selector: "string",
113-
focus_selector: "string",
114-
html: "string"
115-
}, ...],
116-
'''
117-
self.add_operation('outer_html', options)
111+
"""
112+
outer_html: [{
113+
selector: "string",
114+
focus_selector: "string",
115+
html: "string"
116+
}, ...],
117+
"""
118+
self.add_operation("outer_html", options)
118119

119120
def text_content(self, options={}):
120-
'''
121-
text_content: [{
122-
selector: "string",
123-
text: "string"
124-
}, ...]
125-
'''
126-
self.add_operation('text_content', options)
121+
"""
122+
text_content: [{
123+
selector: "string",
124+
text: "string"
125+
}, ...]
126+
"""
127+
self.add_operation("text_content", options)
127128

128129
def insert_adjacent_html(self, options={}):
129-
'''
130+
"""
130131
insert_adjacent_html: [{
131132
selector: "string",
132133
focus_selector: "string",
133134
position: "string",
134135
html: "string"
135136
}, ...],
136-
'''
137-
self.add_operation('insert_adjacent_html', options)
137+
"""
138+
self.add_operation("insert_adjacent_html", options)
138139

139140
def remove(self, options={}):
140-
'''
141+
"""
141142
remove: [{
142143
selector: "string",
143144
focus_selector: "string,
144145
}, ...],
145-
'''
146-
self.add_operation('remove', options)
146+
"""
147+
self.add_operation("remove", options)
147148

148149
def remove_attribute(self, options={}):
149-
'''
150+
"""
150151
remove_attribute: [{
151152
selector: "string",
152153
name: "string"
153154
}, ...],
154-
'''
155-
self.add_operation('remove_attribute', options)
155+
"""
156+
self.add_operation("remove_attribute", options)
156157

157158
def set_attribute(self, options={}):
158-
'''
159+
"""
159160
set_attribute: [{
160161
selector: "string",
161162
name: "string",
162163
value: "string"
163164
}, ...],
164-
'''
165-
self.add_operation('set_attribute', options)
165+
"""
166+
self.add_operation("set_attribute", options)
166167

167168
def set_value(self, options={}):
168-
'''
169+
"""
169170
set_value: [{
170171
selector: "string",
171172
value: "string"
172173
}, ...],
173-
'''
174-
self.add_operation('set_value', options)
174+
"""
175+
self.add_operation("set_value", options)
175176

176177
def add_css_class(self, options={}):
177-
'''
178+
"""
178179
add_css_class: [{
179180
selector: "string",
180181
name: "string"
181182
}, ...],
182-
'''
183-
self.add_operation('add_css_class', options)
183+
"""
184+
self.add_operation("add_css_class", options)
184185

185186
def remove_css_class(self, options={}):
186-
'''
187+
"""
187188
remove_css_class: [{
188189
selector: "string",
189190
name: "string"
190191
}, ...],
191-
'''
192-
self.add_operation('remove_css_class', options)
192+
"""
193+
self.add_operation("remove_css_class", options)
193194

194195
def set_dataset_property(self, options):
195-
'''
196+
"""
196197
set_dataset_property: [{
197198
selector: "string",
198199
name: "string",
199200
value: "string"
200201
}, ...],
201-
'''
202-
self.add_operation('set_dataset_property', options)
202+
"""
203+
self.add_operation("set_dataset_property", options)
203204

204205
def set_style(self, options):
205-
'''
206+
"""
206207
set_style: [{
207208
selector: "string",
208209
name: "string",
209210
value: "string"
210211
}, ...],
211-
'''
212-
self.add_operation('set_style', options)
212+
"""
213+
self.add_operation("set_style", options)

0 commit comments

Comments
 (0)