Skip to content

Commit 26c1005

Browse files
committed
Merge branch 'black' into 'main'
Black conformance See merge request cit/mathworks/jupyter-matlab-proxy!19
2 parents 73b927b + e1f99a9 commit 26c1005

File tree

5 files changed

+26
-18
lines changed

5 files changed

+26
-18
lines changed

jupyter_matlab_proxy/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ async def wsforward(ws_from, ws_to):
286286

287287

288288
async def transform_body(req):
289-
""" Transform some requests as required by the MATLAB JavaScript Desktop. """
289+
"""Transform some requests as required by the MATLAB JavaScript Desktop."""
290290

291291
body = await req.read()
292292

@@ -319,7 +319,7 @@ async def license_init(app):
319319

320320

321321
async def matlab_starter(app):
322-
""" Upon app startup, start MATLAB if able to do so. """
322+
"""Upon app startup, start MATLAB if able to do so."""
323323

324324
state = app["state"]
325325

jupyter_matlab_proxy/app_state.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(self, settings):
4444
return
4545

4646
async def init_licensing(self):
47-
""" Initialise licensing from persisted details or environment variable. """
47+
"""Initialise licensing from persisted details or environment variable."""
4848

4949
# Persisted licensing details present
5050
if self.settings["matlab_config_file"].exists():
@@ -105,7 +105,7 @@ async def init_licensing(self):
105105
}
106106

107107
def get_matlab_state(self):
108-
""" Determine the state of MATLAB to be down/starting/up. """
108+
"""Determine the state of MATLAB to be down/starting/up."""
109109

110110
matlab = self.processes["matlab"]
111111
xvfb = self.processes["xvfb"]
@@ -129,7 +129,7 @@ def get_matlab_state(self):
129129
return "starting"
130130

131131
async def set_licensing_nlm(self, conn_str):
132-
""" Set the licensing type to NLM and the connection string. """
132+
"""Set the licensing type to NLM and the connection string."""
133133

134134
# TODO Validate connection string
135135
self.licensing = {"type": "nlm", "conn_str": conn_str}
@@ -143,7 +143,7 @@ async def set_licensing_mhlm(
143143
entitlements=[],
144144
entitlement_id=None,
145145
):
146-
""" Set the licensing type to MHLM and the details. """
146+
"""Set the licensing type to MHLM and the details."""
147147

148148
try:
149149

@@ -178,7 +178,7 @@ async def set_licensing_mhlm(
178178
log_error(logger, e)
179179

180180
def unset_licensing(self):
181-
""" Unset the licensing. """
181+
"""Unset the licensing."""
182182

183183
self.licensing = None
184184

@@ -187,7 +187,7 @@ def unset_licensing(self):
187187
self.error = None
188188

189189
def is_licensed(self):
190-
""" Is MATLAB licensing configured? """
190+
"""Is MATLAB licensing configured?"""
191191

192192
if self.licensing is not None:
193193
if self.licensing["type"] == "nlm":
@@ -204,7 +204,7 @@ def is_licensed(self):
204204
return False
205205

206206
def is_matlab_present(self):
207-
""" Is MATLAB install accessible? """
207+
"""Is MATLAB install accessible?"""
208208

209209
return self.settings["matlab_path"] is not None
210210

@@ -289,7 +289,7 @@ def persist_licensing(self):
289289
f.write(json.dumps(config))
290290

291291
def reserve_matlab_port(self):
292-
""" Reserve a free port for MATLAB Embedded Connector in the allowed range. """
292+
"""Reserve a free port for MATLAB Embedded Connector in the allowed range."""
293293

294294
# FIXME Because of https://github.com/http-party/node-http-proxy/issues/1342 the
295295
# node application in development mode always uses port 31515 to bypass the
@@ -316,7 +316,7 @@ def reserve_matlab_port(self):
316316
raise e
317317

318318
async def start_matlab(self, restart=False):
319-
""" Start MATLAB. """
319+
"""Start MATLAB."""
320320

321321
# FIXME
322322
if self.get_matlab_state() != "down" and restart is False:
@@ -445,7 +445,7 @@ async def reader():
445445
loop.create_task(reader())
446446

447447
async def stop_matlab(self):
448-
""" Terminate MATLAB. """
448+
"""Terminate MATLAB."""
449449

450450
matlab = self.processes["matlab"]
451451
xvfb = self.processes["xvfb"]

jupyter_matlab_proxy/devel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
def wait_for_port(port):
27-
""" Waits for the given port to become available """
27+
"""Waits for the given port to become available"""
2828

2929
while True:
3030
print(f"Waiting for port {port} to be available")

jupyter_matlab_proxy/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def get_matlab_path():
1616

1717

1818
def get_matlab_version(matlab_path):
19-
""" Get the MATLAB Release version in this image"""
19+
"""Get the MATLAB Release version in this image"""
2020

2121
if matlab_path is None:
2222
return None

tests/test_mw.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def mwa_api_data_fixture():
2727

2828
mwa_api_endpoint = "https://login.mathworks.com/authenticationws/service/v4"
2929
mwa_api_endpoint_pattern = re.compile("^" + mwa_api_endpoint)
30-
mhlm_api_endpoint = "https://licensing.mathworks.com/mls/service/v1/entitlement/list"
30+
mhlm_api_endpoint = (
31+
"https://licensing.mathworks.com/mls/service/v1/entitlement/list"
32+
)
3133
mhlm_api_endpoint_pattern = re.compile("^" + mhlm_api_endpoint)
3234

3335
identity_token = secrets.token_urlsafe(324)
@@ -123,7 +125,9 @@ def mock_aiohttp_client_session():
123125
yield m
124126

125127

126-
async def test_fetch_access_token(mwa_api_data, fetch_access_token_valid_json, mock_response):
128+
async def test_fetch_access_token(
129+
mwa_api_data, fetch_access_token_valid_json, mock_response
130+
):
127131
"""Test to check mw.fetch_access_token method returns valid json response.
128132
129133
The mock_response fixture mocks the aiohttp.ClientSession().post() method to return a custom HTTP response.
@@ -224,7 +228,9 @@ def fetch_expand_token_valid_json_fixture():
224228
return json_data
225229

226230

227-
async def test_fetch_expand_token(mock_response, fetch_expand_token_valid_json, mwa_api_data):
231+
async def test_fetch_expand_token(
232+
mock_response, fetch_expand_token_valid_json, mwa_api_data
233+
):
228234
"""Test to check if mw.fetch_expand_token returns a correct json response
229235
230236
mock_response is used to mock ClientSession.post method to return a HTTP Response containing a valid json response.
@@ -245,7 +251,9 @@ async def test_fetch_expand_token(mock_response, fetch_expand_token_valid_json,
245251
referenceId=json_data["referenceDetail"]["referenceId"],
246252
)
247253

248-
payload = dict(expirationDate=json_data["expirationDate"], referenceDetail=referenceDetail)
254+
payload = dict(
255+
expirationDate=json_data["expirationDate"], referenceDetail=referenceDetail
256+
)
249257

250258
mock_response.post(url_pattern, payload=payload)
251259

0 commit comments

Comments
 (0)