From b3e9bc150e64c1c915ab600557ea267783939684 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 05:06:16 -0500 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#406) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- jupyterlab_server/listings_handler.py | 8 ++------ jupyterlab_server/themes_handler.py | 2 +- jupyterlab_server/workspaces_handler.py | 5 +---- tests/test_settings_api.py | 4 ++-- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e21a4a8f..9d044bb6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.23.2 + rev: 0.23.3 hooks: - id: check-github-workflows @@ -31,12 +31,12 @@ repos: [mdformat-gfm, mdformat-frontmatter, mdformat-footnote] - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.276 + rev: v0.0.281 hooks: - id: ruff args: ["--fix"] diff --git a/jupyterlab_server/listings_handler.py b/jupyterlab_server/listings_handler.py index dd7935d7..9b2acb76 100644 --- a/jupyterlab_server/listings_handler.py +++ b/jupyterlab_server/listings_handler.py @@ -22,9 +22,7 @@ def fetch_listings(logger): blocked_extensions = [] for blocked_extensions_uri in ListingsHandler.blocked_extensions_uris: logger.info( - "Fetching blocked_extensions from {}".format( - ListingsHandler.blocked_extensions_uris - ) + f"Fetching blocked_extensions from {ListingsHandler.blocked_extensions_uris}" ) r = requests.request( "GET", blocked_extensions_uri, **ListingsHandler.listings_request_opts @@ -37,9 +35,7 @@ def fetch_listings(logger): allowed_extensions = [] for allowed_extensions_uri in ListingsHandler.allowed_extensions_uris: logger.info( - "Fetching allowed_extensions from {}".format( - ListingsHandler.allowed_extensions_uris - ) + f"Fetching allowed_extensions from {ListingsHandler.allowed_extensions_uris}" ) r = requests.request( "GET", allowed_extensions_uri, **ListingsHandler.listings_request_opts diff --git a/jupyterlab_server/themes_handler.py b/jupyterlab_server/themes_handler.py index f9f584f8..97dafda0 100644 --- a/jupyterlab_server/themes_handler.py +++ b/jupyterlab_server/themes_handler.py @@ -82,7 +82,7 @@ def replacer(m): """Replace the matched relative url with the mangled url.""" group = m.group() # Get the part that matched - part = [g for g in m.groups() if g][0] + part = next(g for g in m.groups() if g) # Ignore urls that start with `/` or have a protocol like `http`. parsed = urlparse(part) diff --git a/jupyterlab_server/workspaces_handler.py b/jupyterlab_server/workspaces_handler.py index 6e5ccb39..c7795a7a 100644 --- a/jupyterlab_server/workspaces_handler.py +++ b/jupyterlab_server/workspaces_handler.py @@ -150,10 +150,7 @@ def save(self, space_name: str, raw: str) -> Path: metadata_id = metadata_id if metadata_id.startswith("/") else "/" + metadata_id metadata_id = urllib.parse.unquote(metadata_id) if metadata_id != "/" + space_name: - message = "Workspace metadata ID mismatch: expected {!r} got {!r}".format( - space_name, - metadata_id, - ) + message = f"Workspace metadata ID mismatch: expected {space_name!r} got {metadata_id!r}" raise ValueError(message) slug = slugify(space_name) diff --git a/tests/test_settings_api.py b/tests/test_settings_api.py index 231ba8aa..181925d6 100644 --- a/tests/test_settings_api.py +++ b/tests/test_settings_api.py @@ -124,7 +124,7 @@ async def test_listing_ids(jp_fetch, labserverapp): # Checks there is only the 'id' key in each item assert all( - (len(item.keys()) == 1 and list(item.keys())[0] == 'id') for item in response["settings"] + (len(item.keys()) == 1 and next(iter(item.keys())) == 'id') for item in response["settings"] ) @@ -177,7 +177,7 @@ async def test_patch(jp_fetch, labserverapp): validate_request(r) data = json.loads(r.body.decode()) listing = data["settings"] - list_data = [item for item in listing if item["id"] == id][0] + list_data = next(item for item in listing if item["id"] == id) # TODO(@echarles) Check this...