From f39da5561d386c96e073a26f5e8976eda5845b61 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sat, 15 Jul 2023 15:08:20 -0500 Subject: [PATCH] lint --- jupyter_server/serverapp.py | 2 +- jupyter_server/services/kernels/connection/channels.py | 2 +- jupyter_server/services/kernels/websocket.py | 2 +- jupyter_server/utils.py | 6 +++--- pyproject.toml | 4 +++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index 9ecd875d65..7e3e9b868a 100644 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -1229,7 +1229,7 @@ def _default_allow_remote(self): # if blank, self.ip was configured to "*" meaning bind to all interfaces, # see _valdate_ip - if self.ip == "": # noqa + if self.ip == "": return True try: diff --git a/jupyter_server/services/kernels/connection/channels.py b/jupyter_server/services/kernels/connection/channels.py index bbc7792bb0..212954f301 100644 --- a/jupyter_server/services/kernels/connection/channels.py +++ b/jupyter_server/services/kernels/connection/channels.py @@ -644,7 +644,7 @@ def write_stderr(self, error_message, parent_header): err_msg["channel"] = "iopub" self.write_message(json.dumps(err_msg, default=json_default)) - def _limit_rate(self, channel, msg, msg_list): # noqa + def _limit_rate(self, channel, msg, msg_list): """Limit the message rate on a channel.""" if not (self.limit_rate and channel == "iopub"): return False diff --git a/jupyter_server/services/kernels/websocket.py b/jupyter_server/services/kernels/websocket.py index cfc40da8ee..753ab01e26 100644 --- a/jupyter_server/services/kernels/websocket.py +++ b/jupyter_server/services/kernels/websocket.py @@ -87,7 +87,7 @@ def select_subprotocol(self, subprotocols): preferred_protocol = self.connection.kernel_ws_protocol if preferred_protocol is None: preferred_protocol = "v1.kernel.websocket.jupyter.org" - elif preferred_protocol == "": # noqa + elif preferred_protocol == "": preferred_protocol = None selected_subprotocol = preferred_protocol if preferred_protocol in subprotocols else None # None is the default, "legacy" protocol diff --git a/jupyter_server/utils.py b/jupyter_server/utils.py index 7c370d6bd7..dc710c8c28 100644 --- a/jupyter_server/utils.py +++ b/jupyter_server/utils.py @@ -57,7 +57,7 @@ def path2url(path): """Convert a local file path to a URL""" pieces = [quote(p) for p in path.split(os.sep)] # preserve trailing / - if pieces[-1] == "": # noqa + if pieces[-1] == "": pieces[-1] = "/" url = url_path_join(*pieces) return url @@ -121,7 +121,7 @@ def to_os_path(path: ApiPath, root: str = "") -> str: root must be a filesystem path already. """ parts = str(path).strip("/").split("/") - parts = [p for p in parts if p != ""] # noqa # remove duplicate splits + parts = [p for p in parts if p != ""] # remove duplicate splits path_ = os.path.join(root, *parts) return os.path.normpath(path_) @@ -135,7 +135,7 @@ def to_api_path(os_path: str, root: str = "") -> ApiPath: if os_path.startswith(root): os_path = os_path[len(root) :] parts = os_path.strip(os.path.sep).split(os.path.sep) - parts = [p for p in parts if p != ""] # noqa # remove duplicate splits + parts = [p for p in parts if p != ""] # remove duplicate splits path = "/".join(parts) return ApiPath(path) diff --git a/pyproject.toml b/pyproject.toml index b63f67c01b..2f81774889 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -121,7 +121,7 @@ detached = true dependencies = [ "black[jupyter]==23.3.0", "mdformat>0.7", - "ruff==0.0.270", + "ruff==0.0.276", ] [tool.hatch.envs.lint.scripts] style = [ @@ -222,6 +222,8 @@ ignore = [ "PLR0913", # PLR0912 Too many branches "PLR0912", + # RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + "RUF012", ] unfixable = [ # Don't touch print statements