Skip to content

Commit

Permalink
mini dep-update and minor quality improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasertl committed Dec 25, 2024
1 parent a665559 commit b8e0c42
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
4 changes: 1 addition & 3 deletions ca/django_ca/tests/views/test_generic_ocsp_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,7 @@ def test_certificate_never_generated(


@pytest.mark.freeze_time(TIMESTAMPS["profile_certs_expired"])
def test_certificate_expired(
caplog: LogCaptureFixture, client: Client, child_cert: Certificate, profile_ocsp: Certificate
) -> None:
def test_certificate_expired(caplog: LogCaptureFixture, client: Client, child_cert: Certificate) -> None:
"""Test error log when the key has expired."""
response = ocsp_get(client, child_cert, hash_algorithm=hashes.SHA512)
assert caplog.record_tuples == [
Expand Down
20 changes: 9 additions & 11 deletions devscripts/commands/docker_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@

import argparse
import functools
import io
import shlex
import subprocess
import sys
from multiprocessing.pool import Pool
from pathlib import Path
from typing import TypedDict
from typing import TypedDict, Union

from devscripts import config
from devscripts.commands import DevCommand
Expand All @@ -35,13 +36,13 @@ class DockerRunDict(TypedDict):
error: str


def build_docker_image(cmd: list[str], log_path: Path, output=False) -> int:
def build_docker_image(cmd: list[str], log_path: Path, output: bool = False) -> int:
"""Run command to build a Docker image."""
env = {"DOCKER_BUILDKIT": "1"}

with open(log_path, "bw") as stream:
if output:
stdout = subprocess.PIPE
stdout: Union[int, io.BufferedWriter] = subprocess.PIPE
else:
stdout = stream
stream.write(f"+ {shlex.join(cmd)}\n".encode())
Expand Down Expand Up @@ -89,17 +90,14 @@ def handle_image(image: str, no_cache: bool, keep_image: bool, output: bool) ->
if returncode == 0:
ok(f"{image} passed.")
return {"image": image, "success": True, "error": ""}
else:
failed_str = f"{image} failed: return code {returncode}."

# pylint: disable-next=consider-using-f-string # just more convenient
err(failed_str)
return {"image": image, "success": False, "error": f"return code: {returncode}"}
failed_str = f"{image} failed: return code {returncode}."
err(failed_str)
return {"image": image, "success": False, "error": f"return code: {returncode}"}

except Exception as ex: # pylint: disable=broad-except; to make sure we test all images
msg = f"{image}: {type(ex).__name__} {ex}"
return {"image": image, "success": False, "error": msg}
err(f"\n{msg}\n")
finally:
if not keep_image:
subprocess.run(
Expand All @@ -111,7 +109,7 @@ def handle_image(image: str, no_cache: bool, keep_image: bool, output: bool) ->


def handle_parallel(
images: list[str], processes: int, no_cache: bool, keep_image: bool
images: tuple[str, ...], processes: int, no_cache: bool, keep_image: bool
) -> list[DockerRunDict]:
"""Handle images in parallel."""
with Pool(processes) as pool:
Expand Down Expand Up @@ -163,7 +161,7 @@ def handle(self, args: argparse.Namespace) -> None:
docker_runs: list[DockerRunDict] = []

if args.images:
images: tuple[str] = tuple(args.images)
images: tuple[str, ...] = tuple(args.images)
elif args.debian:
images = config.DEBIAN_IMAGES
elif args.alpine:
Expand Down
2 changes: 1 addition & 1 deletion devscripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def minor_to_major(version: str) -> str:
_debian_images = []
for python_version in reversed(PYTHON_RELEASES):
for debian_version in reversed(DEBIAN_RELEASES):
image_name = f"python:{python_version}-slim-{debian_version}"
image_name = f"python:{python_version}-slim-{debian_version}" # pylint: disable=invalid-name

# Skip images that are just no longer built upstream
if image_name in _release_config["docker-image-blacklist"]:
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-dev-common.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# modules imported in devscripts/ and/or required by mypy for type checking
GitPython==3.1.43
Jinja2==3.1.4
Jinja2==3.1.5
PyYAML==6.0.2
Sphinx==7.3.7
coverage[toml]==7.6.9
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-lint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
astroid>=3.3.6,!=3.3.7
pre-commit==4.0.1
pylint-django==2.6.1
pylint==3.3.2
pylint==3.3.3
ruff==0.8.4
setuptools>=65

0 comments on commit b8e0c42

Please sign in to comment.