diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 36195ba3..917701f9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: # Autoformat: Python code - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black @@ -57,7 +57,7 @@ repos: # Lint: Python code - repo: https://github.com/PyCQA/flake8 - rev: "6.1.0" + rev: "7.0.0" hooks: - id: flake8 diff --git a/kubespawner/__init__.py b/kubespawner/__init__.py index ec65df34..89b7541d 100644 --- a/kubespawner/__init__.py +++ b/kubespawner/__init__.py @@ -7,6 +7,7 @@ in your `jupyterhub_config.py` file. """ + # We export KubeSpawner specifically here. This simplifies import for users. # Users can simply import kubespawner.KubeSpawner in their applications # instead of the more verbose import kubespawner.spawner.KubeSpawner. diff --git a/kubespawner/clients.py b/kubespawner/clients.py index b3078e43..0dd865e8 100644 --- a/kubespawner/clients.py +++ b/kubespawner/clients.py @@ -5,6 +5,7 @@ The instances of these REST API clients are also patched to avoid the creation of unused threads. """ + import asyncio from concurrent.futures import ThreadPoolExecutor from functools import lru_cache diff --git a/kubespawner/objects.py b/kubespawner/objects.py index 2153a46e..f644811f 100644 --- a/kubespawner/objects.py +++ b/kubespawner/objects.py @@ -1,6 +1,7 @@ """ Helper methods for generating k8s API objects. """ + import base64 import ipaddress import json @@ -353,9 +354,11 @@ def make_pod( # be a list, but it is allowed to have "a-string" elements or {"name": # "a-string"} elements. pod.spec.image_pull_secrets = [ - V1LocalObjectReference(name=secret_ref) - if type(secret_ref) == str - else get_k8s_model(V1LocalObjectReference, secret_ref) + ( + V1LocalObjectReference(name=secret_ref) + if type(secret_ref) == str + else get_k8s_model(V1LocalObjectReference, secret_ref) + ) for secret_ref in image_pull_secrets ] diff --git a/kubespawner/spawner.py b/kubespawner/spawner.py index 45437815..eafda735 100644 --- a/kubespawner/spawner.py +++ b/kubespawner/spawner.py @@ -4,6 +4,7 @@ This module exports `KubeSpawner` class, which is the actual spawner implementation that should be used by JupyterHub. """ + import asyncio import copy import ipaddress diff --git a/kubespawner/utils.py b/kubespawner/utils.py index 1d38147b..ca063fac 100644 --- a/kubespawner/utils.py +++ b/kubespawner/utils.py @@ -1,6 +1,7 @@ """ Misc. general utility functions, not tied to KubeSpawner directly """ + import copy import hashlib diff --git a/tests/conftest.py b/tests/conftest.py index 62eaee71..8d929fae 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """pytest fixtures for kubespawner""" + import asyncio import base64 import inspect diff --git a/tests/jupyterhub_config.py b/tests/jupyterhub_config.py index 849d6603..71bd06fd 100644 --- a/tests/jupyterhub_config.py +++ b/tests/jupyterhub_config.py @@ -1,4 +1,5 @@ """Minimal jupyterhub config for hub pod""" + import json import os import socket diff --git a/tests/test_objects.py b/tests/test_objects.py index c734c051..90aba79c 100644 --- a/tests/test_objects.py +++ b/tests/test_objects.py @@ -1,6 +1,7 @@ """ Test functions used to create k8s objects """ + import pytest from kubernetes_asyncio.client import ApiClient