Skip to content

Commit 2e802a4

Browse files
committed
run lint
1 parent 0ffdf8e commit 2e802a4

35 files changed

+218
-224
lines changed

examples/simple/simple_ext1/handlers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def get(self):
4242

4343
class TemplateHandler(BaseTemplateHandler):
4444
def get(self, path):
45-
""" Optionaly, you can print(self.get_template('simple1.html'))"""
45+
"""Optionaly, you can print(self.get_template('simple1.html'))"""
4646
self.write(self.render_template("simple1.html", path=path))
4747

4848

examples/simple/simple_ext1/static/bundle.js

+29-31
Original file line numberDiff line numberDiff line change
@@ -57,37 +57,35 @@
5757
/******/
5858
}; // create a fake namespace object // mode & 1: value is a module id, require it // mode & 2: merge all properties of value into the ns // mode & 4: return value when already ns object // mode & 8|1: behave like require
5959
/******/
60-
/******/ /******/ /******/ /******/ /******/ /******/ __webpack_require__.t = function (
61-
value,
62-
mode
63-
) {
64-
/******/ if (mode & 1) value = __webpack_require__(value);
65-
/******/ if (mode & 8) return value;
66-
/******/ if (
67-
mode & 4 &&
68-
typeof value === "object" &&
69-
value &&
70-
value.__esModule
71-
)
72-
return value;
73-
/******/ var ns = Object.create(null);
74-
/******/ __webpack_require__.r(ns);
75-
/******/ Object.defineProperty(ns, "default", {
76-
enumerable: true,
77-
value: value,
78-
});
79-
/******/ if (mode & 2 && typeof value != "string")
80-
for (var key in value)
81-
__webpack_require__.d(
82-
ns,
83-
key,
84-
function (key) {
85-
return value[key];
86-
}.bind(null, key)
87-
);
88-
/******/ return ns;
89-
/******/
90-
}; // getDefaultExport function for compatibility with non-harmony modules
60+
/******/ /******/ /******/ /******/ /******/ /******/ __webpack_require__.t =
61+
function (value, mode) {
62+
/******/ if (mode & 1) value = __webpack_require__(value);
63+
/******/ if (mode & 8) return value;
64+
/******/ if (
65+
mode & 4 &&
66+
typeof value === "object" &&
67+
value &&
68+
value.__esModule
69+
)
70+
return value;
71+
/******/ var ns = Object.create(null);
72+
/******/ __webpack_require__.r(ns);
73+
/******/ Object.defineProperty(ns, "default", {
74+
enumerable: true,
75+
value: value,
76+
});
77+
/******/ if (mode & 2 && typeof value != "string")
78+
for (var key in value)
79+
__webpack_require__.d(
80+
ns,
81+
key,
82+
function (key) {
83+
return value[key];
84+
}.bind(null, key)
85+
);
86+
/******/ return ns;
87+
/******/
88+
}; // getDefaultExport function for compatibility with non-harmony modules
9189
/******/
9290
/******/ /******/ __webpack_require__.n = function (module) {
9391
/******/ var getter =

jupyter_server/_sysinfo.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ def pkg_commit_hash(pkg_path):
5656
if repo_commit:
5757
return "repository", repo_commit.strip().decode("ascii")
5858
else:
59-
return u"", u""
59+
return "", ""
6060
par_path = p.dirname(par_path)
6161

62-
return u"", u""
62+
return "", ""
6363

6464

6565
def pkg_info(pkg_path):

jupyter_server/auth/login.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ def passwd_check(self, a, b):
7575
return passwd_check(a, b)
7676

7777
def post(self):
78-
typed_password = self.get_argument("password", default=u"")
79-
new_password = self.get_argument("new_password", default=u"")
78+
typed_password = self.get_argument("password", default="")
79+
new_password = self.get_argument("new_password", default="")
8080

8181
if self.get_login_available(self.settings):
8282
if self.passwd_check(self.hashed_password, typed_password) and not new_password:
@@ -247,7 +247,7 @@ def password_from_settings(cls, settings):
247247
248248
If there is no configured password, an empty string will be returned.
249249
"""
250-
return settings.get("password", u"")
250+
return settings.get("password", "")
251251

252252
@classmethod
253253
def get_login_available(cls, settings):

jupyter_server/base/handlers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -548,13 +548,13 @@ def get_json_body(self):
548548
if not self.request.body:
549549
return None
550550
# Do we need to call body.decode('utf-8') here?
551-
body = self.request.body.strip().decode(u"utf-8")
551+
body = self.request.body.strip().decode("utf-8")
552552
try:
553553
model = json.loads(body)
554554
except Exception as e:
555555
self.log.debug("Bad JSON: %r", body)
556556
self.log.error("Couldn't parse JSON", exc_info=True)
557-
raise web.HTTPError(400, u"Invalid JSON in body of request") from e
557+
raise web.HTTPError(400, "Invalid JSON in body of request") from e
558558
return model
559559

560560
def write_error(self, status_code, **kwargs):

jupyter_server/extension/application.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ def _default_log_level(self):
211211
@default("log_format")
212212
def _default_log_format(self):
213213
"""override default log format to include date & time"""
214-
return u"%(color)s[%(levelname)1.1s %(asctime)s.%(msecs).03d %(name)s]%(end_color)s %(message)s"
214+
return (
215+
"%(color)s[%(levelname)1.1s %(asctime)s.%(msecs).03d %(name)s]%(end_color)s %(message)s"
216+
)
215217

216218
static_url_prefix = Unicode(
217219
help="""Url where the static assets for the extension are served."""

jupyter_server/extension/serverextension.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def list_server_extensions(self):
329329
for name, extension in ext_manager.extensions.items():
330330
enabled = extension.enabled
331331
# Attempt to get extension metadata
332-
self.log.info(u" {} {}".format(name, GREEN_ENABLED if enabled else RED_DISABLED))
332+
self.log.info(" {} {}".format(name, GREEN_ENABLED if enabled else RED_DISABLED))
333333
try:
334334
self.log.info(" - Validating {}...".format(name))
335335
if not extension.validate():

jupyter_server/gateway/gateway_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def load_connection_args(self, **kwargs):
397397

398398

399399
async def gateway_request(endpoint, **kwargs):
400-
"""Make an async request to kernel gateway endpoint, returns a response """
400+
"""Make an async request to kernel gateway endpoint, returns a response"""
401401
client = AsyncHTTPClient()
402402
kwargs = GatewayClient.instance().load_connection_args(**kwargs)
403403
try:

jupyter_server/gateway/handlers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def send_ping(self):
8181
self.ping(b"")
8282

8383
def open(self, kernel_id, *args, **kwargs):
84-
"""Handle web socket connection open to notebook server and delegate to gateway web socket handler """
84+
"""Handle web socket connection open to notebook server and delegate to gateway web socket handler"""
8585
self.ping_callback = PeriodicCallback(self.send_ping, GATEWAY_WS_PING_INTERVAL_SECS * 1000)
8686
self.ping_callback.start()
8787

@@ -221,7 +221,7 @@ async def _read_messages(self, callback):
221221
jitter = random.randint(10, 100) * 0.01
222222
retry_interval = (
223223
min(
224-
GatewayClient.instance().gateway_retry_interval * (2 ** self.retry),
224+
GatewayClient.instance().gateway_retry_interval * (2**self.retry),
225225
GatewayClient.instance().gateway_retry_interval_max,
226226
)
227227
+ jitter

jupyter_server/gateway/managers.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(self, **kwargs):
5454
)
5555

5656
def remove_kernel(self, kernel_id):
57-
"""Complete override since we want to be more tolerant of missing keys """
57+
"""Complete override since we want to be more tolerant of missing keys"""
5858
try:
5959
return self._kernels.pop(kernel_id)
6060
except KeyError:
@@ -178,7 +178,7 @@ async def shutdown_all(self, now=False):
178178
self.remove_kernel(kernel_id)
179179

180180
async def cull_kernels(self):
181-
"""Override cull_kernels so we can be sure their state is current. """
181+
"""Override cull_kernels so we can be sure their state is current."""
182182
await self.list_kernels()
183183
await super().cull_kernels()
184184

@@ -299,7 +299,7 @@ class GatewaySessionManager(SessionManager):
299299
kernel_manager = Instance("jupyter_server.gateway.managers.GatewayMappingKernelManager")
300300

301301
async def kernel_culled(self, kernel_id):
302-
"""Checks if the kernel is still considered alive and returns true if its not found. """
302+
"""Checks if the kernel is still considered alive and returns true if its not found."""
303303
kernel = None
304304
try:
305305
km = self.kernel_manager.get_kernel(kernel_id)
@@ -313,7 +313,7 @@ async def kernel_culled(self, kernel_id):
313313

314314

315315
class GatewayKernelManager(AsyncKernelManager):
316-
"""Manages a single kernel remotely via a Gateway Server. """
316+
"""Manages a single kernel remotely via a Gateway Server."""
317317

318318
kernel_id = None
319319
kernel = None
@@ -449,23 +449,23 @@ async def start_kernel(self, **kwargs):
449449
self.kernel_url = url_path_join(self.kernels_url, url_escape(str(self.kernel_id)))
450450

451451
async def shutdown_kernel(self, now=False, restart=False):
452-
"""Attempts to stop the kernel process cleanly via HTTP. """
452+
"""Attempts to stop the kernel process cleanly via HTTP."""
453453

454454
if self.has_kernel:
455455
self.log.debug("Request shutdown kernel at: %s", self.kernel_url)
456456
response = await gateway_request(self.kernel_url, method="DELETE")
457457
self.log.debug("Shutdown kernel response: %d %s", response.code, response.reason)
458458

459459
async def restart_kernel(self, **kw):
460-
"""Restarts a kernel via HTTP. """
460+
"""Restarts a kernel via HTTP."""
461461
if self.has_kernel:
462462
kernel_url = self.kernel_url + "/restart"
463463
self.log.debug("Request restart kernel at: %s", kernel_url)
464464
response = await gateway_request(kernel_url, method="POST", body=json_encode({}))
465465
self.log.debug("Restart kernel response: %d %s", response.code, response.reason)
466466

467467
async def interrupt_kernel(self):
468-
"""Interrupts the kernel via an HTTP request. """
468+
"""Interrupts the kernel via an HTTP request."""
469469
if self.has_kernel:
470470
kernel_url = self.kernel_url + "/interrupt"
471471
self.log.debug("Request interrupt kernel at: %s", kernel_url)

jupyter_server/kernelspecs/handlers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def get(self, kernel_name, path, include_body=True):
1616
try:
1717
self.root = ksm.get_kernel_spec(kernel_name).resource_dir
1818
except KeyError as e:
19-
raise web.HTTPError(404, u"Kernel spec %s not found" % kernel_name) from e
19+
raise web.HTTPError(404, "Kernel spec %s not found" % kernel_name) from e
2020
self.log.debug("Serving kernel resource from: %s", self.root)
2121
return web.StaticFileHandler.get(self, path, include_body=include_body)
2222

jupyter_server/nbconvert/handlers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def get_exporter(format, **kwargs):
6767
Exporter = get_exporter(format)
6868
except KeyError as e:
6969
# should this be 400?
70-
raise web.HTTPError(404, u"No exporter for format: %s" % format) from e
70+
raise web.HTTPError(404, "No exporter for format: %s" % format) from e
7171

7272
try:
7373
return Exporter(**kwargs)

jupyter_server/pytest_plugin.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def jp_environ(
109109
jp_env_jupyter_path,
110110
jp_env_config_path,
111111
):
112-
"""Configures a temporary environment based on Jupyter-specific environment variables. """
112+
"""Configures a temporary environment based on Jupyter-specific environment variables."""
113113
monkeypatch.setenv("HOME", str(jp_home_dir))
114114
monkeypatch.setenv("PYTHONPATH", os.pathsep.join(sys.path))
115115
# monkeypatch.setenv("JUPYTER_NO_CONFIG", "1")
@@ -127,7 +127,7 @@ def jp_environ(
127127

128128
@pytest.fixture
129129
def jp_server_config():
130-
"""Allows tests to setup their specific configuration values. """
130+
"""Allows tests to setup their specific configuration values."""
131131
return {}
132132

133133

@@ -145,7 +145,7 @@ def jp_template_dir(tmp_path):
145145

146146
@pytest.fixture
147147
def jp_argv():
148-
"""Allows tests to setup specific argv values. """
148+
"""Allows tests to setup specific argv values."""
149149
return []
150150

151151

@@ -157,7 +157,7 @@ def jp_extension_environ(jp_env_config_path, monkeypatch):
157157

158158
@pytest.fixture
159159
def jp_http_port(http_server_port):
160-
"""Returns the port value from the http_server_port fixture. """
160+
"""Returns the port value from the http_server_port fixture."""
161161
return http_server_port[-1]
162162

163163

@@ -406,7 +406,7 @@ def client_fetch(*parts, headers=None, params=None, **kwargs):
406406
return client_fetch
407407

408408

409-
some_resource = u"The very model of a modern major general"
409+
some_resource = "The very model of a modern major general"
410410
sample_kernel_json = {
411411
"argv": ["cat", "{connection_file}"],
412412
"display_name": "Test kernel",

jupyter_server/serverapp.py

+15-13
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ class JupyterServerStopApp(JupyterApp):
537537
help="Port of the server to be killed. Default %s" % DEFAULT_JUPYTER_SERVER_PORT,
538538
)
539539

540-
sock = Unicode(u"", config=True, help="UNIX socket of the server to be killed.")
540+
sock = Unicode("", config=True, help="UNIX socket of the server to be killed.")
541541

542542
def parse_command_line(self, argv=None):
543543
super(JupyterServerStopApp, self).parse_command_line(argv)
@@ -768,7 +768,9 @@ def _default_log_level(self):
768768
@default("log_format")
769769
def _default_log_format(self):
770770
"""override default log format to include date & time"""
771-
return u"%(color)s[%(levelname)1.1s %(asctime)s.%(msecs).03d %(name)s]%(end_color)s %(message)s"
771+
return (
772+
"%(color)s[%(levelname)1.1s %(asctime)s.%(msecs).03d %(name)s]%(end_color)s %(message)s"
773+
)
772774

773775
# file to be opened in the Jupyter server
774776
file_to_run = Unicode("", help="Open the named file when the application is launched.").tag(
@@ -847,12 +849,12 @@ def _default_ip(self):
847849
@validate("ip")
848850
def _validate_ip(self, proposal):
849851
value = proposal["value"]
850-
if value == u"*":
851-
value = u""
852+
if value == "*":
853+
value = ""
852854
return value
853855

854856
custom_display_url = Unicode(
855-
u"",
857+
"",
856858
config=True,
857859
help=_i18n(
858860
"""Override URL shown to users.
@@ -894,7 +896,7 @@ def port_default(self):
894896
def port_retries_default(self):
895897
return int(os.getenv(self.port_retries_env, self.port_retries_default_value))
896898

897-
sock = Unicode(u"", config=True, help="The UNIX socket the Jupyter server will listen on.")
899+
sock = Unicode("", config=True, help="The UNIX socket the Jupyter server will listen on.")
898900

899901
sock_mode = Unicode(
900902
"0600", config=True, help="The permissions mode for UNIX socket creation (default: 0600)."
@@ -911,7 +913,7 @@ def _validate_sock_mode(self, proposal):
911913
bool(converted_value & stat.S_IRUSR),
912914
bool(converted_value & stat.S_IWUSR),
913915
# And isn't out of bounds.
914-
converted_value <= 2 ** 12,
916+
converted_value <= 2**12,
915917
)
916918
)
917919
except ValueError:
@@ -923,17 +925,17 @@ def _validate_sock_mode(self, proposal):
923925
return value
924926

925927
certfile = Unicode(
926-
u"", config=True, help=_i18n("""The full path to an SSL/TLS certificate file.""")
928+
"", config=True, help=_i18n("""The full path to an SSL/TLS certificate file.""")
927929
)
928930

929931
keyfile = Unicode(
930-
u"",
932+
"",
931933
config=True,
932934
help=_i18n("""The full path to a private key file for usage with SSL/TLS."""),
933935
)
934936

935937
client_ca = Unicode(
936-
u"",
938+
"",
937939
config=True,
938940
help=_i18n(
939941
"""The full path to a certificate authority certificate for SSL/TLS client authentication."""
@@ -1013,7 +1015,7 @@ def _token_default(self):
10131015
if self.password:
10141016
# no token if password is enabled
10151017
self._token_generated = False
1016-
return u""
1018+
return ""
10171019
else:
10181020
self._token_generated = True
10191021
return binascii.hexlify(os.urandom(24)).decode("ascii")
@@ -1074,7 +1076,7 @@ def _token_changed(self, change):
10741076
self._token_generated = False
10751077

10761078
password = Unicode(
1077-
u"",
1079+
"",
10781080
config=True,
10791081
help="""Hashed password to use for web authentication.
10801082
@@ -1219,7 +1221,7 @@ def _default_allow_remote(self):
12191221
)
12201222

12211223
browser = Unicode(
1222-
u"",
1224+
"",
12231225
config=True,
12241226
help="""Specify what command to use to invoke a web
12251227
browser when starting the server. If not specified, the

0 commit comments

Comments
 (0)