Loading .pre-commit-config.yaml +2 −1 Changes for .pre-commit-config.yaml: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ repos: hooks: - id: pyright additional_dependencies: &deps - coverage - git+https://code.kodo.org.uk/dom/type-stubs.git#type-stubs[behave,jsonpath] - packaging >=21 - parse ==1.22.0 Loading @@ -77,7 +78,7 @@ repos: - types-orjson - types-requests - types-urllib3 - typing-extensions ~=4.0; python_version < "3.11" - typing-extensions ~=4.6 - xdg-base-dirs ~=6.0 # - id: pyright # additional_dependencies: *deps Loading .ruff.toml +3 Changes for .ruff.toml: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -9,6 +9,9 @@ skip-magic-trailing-comma = false force-single-line = true required-imports = ["from __future__ import annotations"] [lint.flake8-builtins] ignorelist = ["input"] [lint] select = [ # pyflakes Loading behave_utils/__init__.py +2 −2 Changes for behave_utils/__init__.py: 2 added lines, 2 removed lines. Original line number Diff line number Diff line # Copyright 2021 Dominik Sekotill <dom.sekotill@kodo.org.uk> # Copyright 2021, 2026 Dominik Sekotill <dom.sekotill@kodo.org.uk> # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this Loading @@ -21,10 +21,10 @@ from .url import URL from .utils import wait __all__ = ( "URL", "JSONArray", "JSONObject", "PatternEnum", "URL", "exec_io", "make_secret", "redirect", Loading behave_utils/behave.py +15 −15 Changes for behave_utils/behave.py: 15 added lines, 15 removed lines. Original line number Diff line number Diff line # Copyright 2021-2023 Dominik Sekotill <dom.sekotill@kodo.org.uk> # Copyright 2021-2023, 2026 Dominik Sekotill <dom.sekotill@kodo.org.uk> # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this Loading @@ -12,8 +12,8 @@ from __future__ import annotations import enum from typing import TYPE_CHECKING from typing import Any from typing import Protocol from typing import Self from typing import TypeVar from typing import overload Loading @@ -27,20 +27,16 @@ __all__ = [ if TYPE_CHECKING: from typing_extensions import Self from typing import Self T = TypeVar("T") class PatternConverter(Protocol): __name__: str def __call__(self, match: str, /) -> object: ... class Decorator(Protocol[T]): def __call__(self, converter: T) -> T: ... Loading Loading @@ -80,20 +76,21 @@ def register_pattern( class EnumMeta(enum.EnumMeta): MEMBER_FILTER = 'member_filter' MEMBER_FILTER = "member_filter" if TYPE_CHECKING: T = TypeVar("T", bound="EnumMeta") def __new__(mtc: type[T], name: str, bases: tuple[type, ...], attr: enum._EnumDict, **kwds: Any) -> T: member_names: list[str] = attr._member_names # type: ignore def __new__( mtc: type[EnumMeta], name: str, bases: tuple[type, ...], attr: enum._EnumDict, **kwds: object ) -> EnumMeta: member_names: list[str] = attr._member_names # type: ignore # noqa: SLF001 member_filter = attr.pop(mtc.MEMBER_FILTER, None) if member_filter: assert isinstance(member_filter, staticmethod) member_filter.__func__(attr, member_names) cls = enum.EnumMeta.__new__(mtc, name, bases, attr, **kwds) decorator = parse.with_pattern('|'.join(member for member in cls.__members__)) cls = enum.EnumMeta.__new__(mtc, name, bases, attr, boundary=None, _simple=False, **kwds) decorator = parse.with_pattern("|".join(member for member in cls.__members__)) behave.register_type(**{name: decorator(cls)}) return cls Loading @@ -113,5 +110,8 @@ class PatternEnum(enum.Enum, metaclass=EnumMeta): """ @classmethod def _missing_(cls, key: Any) -> Self: return cls[key] def _missing_(cls, value: object) -> Self: if not isinstance(value, str): msg = "PatternEnum values must be strings" raise TypeError(msg) return cls[value] behave_utils/binaries.py +14 −12 Changes for behave_utils/binaries.py: 14 added lines, 12 removed lines. Original line number Diff line number Diff line # Copyright 2021-2024 Dominik Sekotill <dom.sekotill@kodo.org.uk> # Copyright 2021-2024, 2026 Dominik Sekotill <dom.sekotill@kodo.org.uk> # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this Loading @@ -15,19 +15,20 @@ import re from abc import ABC from abc import abstractmethod from collections.abc import Iterator from http.client import HTTPResponse from io import BytesIO from pathlib import Path from shutil import copyfileobj from tarfile import TarFile from typing import IO from typing import TYPE_CHECKING from typing import ClassVar import requests from packaging.version import Version from xdg_base_dirs import xdg_cache_home from behave_utils.json import JSONObject from behave_utils.url import URL if TYPE_CHECKING: from .types import Readable Loading @@ -54,16 +55,13 @@ class DownloadableExecutable(ABC): # Many Go binaries include the architecture value accepted by `go` in their names, so # the "goarch" class attribute is added for convenience, generated from this map. # This map may not be fully complete. Only non-equal values need to be added. GOARCH_MAP = { GOARCH_MAP: ClassVar = { "i386": "386", "i686": "386", "x86": "386", "x86_64": "amd64", "armv6l": "arm", "armv7l": "arm", "aarch64": "arm64", } Loading @@ -73,13 +71,13 @@ class DownloadableExecutable(ABC): name: str def __init_subclass__(cls, name: str|None = None): def __init_subclass__(cls, name: str | None = None) -> None: if name and hasattr(cls, "name"): raise TypeError(f"Got two 'name' attributes for {cls}: {name} and {cls.name}") if name: cls.name = name def __init__(self, version: str = "latest"): def __init__(self, version: str = "latest") -> None: self.version = version @abstractmethod Loading Loading @@ -232,7 +230,7 @@ class DownloadableKubeTools(DownloadableExecutable): URL = "https://dl.k8s.io/release/{version}/bin/{kernel}/{arch}/{name}" LATEST_URL = "https://dl.k8s.io/release/stable.txt" def __init__(self, name: str, version: str = "latest"): def __init__(self, name: str, version: str = "latest") -> None: DownloadableExecutable.__init__(self, version) self.name = name self._latest = "" Loading @@ -249,8 +247,11 @@ class DownloadableKubeTools(DownloadableExecutable): """ Return a stream that emits the requested Kubernetes binary """ url = self.URL.format(version=version, kernel=self.kernel, arch=self.goarch, name=self.name) stream: IO[bytes] = session.get(url, stream=True).raw url = self.URL.format( version=version, kernel=self.kernel, arch=self.goarch, name=self.name ) stream = session.get(url, stream=True).raw assert isinstance(stream, HTTPResponse) return stream Loading Loading @@ -306,5 +307,6 @@ class DownloadableKind(DownloadableExecutable): Return a stream that emits the requested Kind binary """ url = self.URL.format(version=version, kernel=self.kernel, arch=self.goarch) stream: IO[bytes] = session.get(url, stream=True).raw stream = session.get(url, stream=True).raw assert isinstance(stream, HTTPResponse) return stream Loading
.pre-commit-config.yaml +2 −1 Changes for .pre-commit-config.yaml: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ repos: hooks: - id: pyright additional_dependencies: &deps - coverage - git+https://code.kodo.org.uk/dom/type-stubs.git#type-stubs[behave,jsonpath] - packaging >=21 - parse ==1.22.0 Loading @@ -77,7 +78,7 @@ repos: - types-orjson - types-requests - types-urllib3 - typing-extensions ~=4.0; python_version < "3.11" - typing-extensions ~=4.6 - xdg-base-dirs ~=6.0 # - id: pyright # additional_dependencies: *deps Loading
.ruff.toml +3 Changes for .ruff.toml: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -9,6 +9,9 @@ skip-magic-trailing-comma = false force-single-line = true required-imports = ["from __future__ import annotations"] [lint.flake8-builtins] ignorelist = ["input"] [lint] select = [ # pyflakes Loading
behave_utils/__init__.py +2 −2 Changes for behave_utils/__init__.py: 2 added lines, 2 removed lines. Original line number Diff line number Diff line # Copyright 2021 Dominik Sekotill <dom.sekotill@kodo.org.uk> # Copyright 2021, 2026 Dominik Sekotill <dom.sekotill@kodo.org.uk> # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this Loading @@ -21,10 +21,10 @@ from .url import URL from .utils import wait __all__ = ( "URL", "JSONArray", "JSONObject", "PatternEnum", "URL", "exec_io", "make_secret", "redirect", Loading
behave_utils/behave.py +15 −15 Changes for behave_utils/behave.py: 15 added lines, 15 removed lines. Original line number Diff line number Diff line # Copyright 2021-2023 Dominik Sekotill <dom.sekotill@kodo.org.uk> # Copyright 2021-2023, 2026 Dominik Sekotill <dom.sekotill@kodo.org.uk> # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this Loading @@ -12,8 +12,8 @@ from __future__ import annotations import enum from typing import TYPE_CHECKING from typing import Any from typing import Protocol from typing import Self from typing import TypeVar from typing import overload Loading @@ -27,20 +27,16 @@ __all__ = [ if TYPE_CHECKING: from typing_extensions import Self from typing import Self T = TypeVar("T") class PatternConverter(Protocol): __name__: str def __call__(self, match: str, /) -> object: ... class Decorator(Protocol[T]): def __call__(self, converter: T) -> T: ... Loading Loading @@ -80,20 +76,21 @@ def register_pattern( class EnumMeta(enum.EnumMeta): MEMBER_FILTER = 'member_filter' MEMBER_FILTER = "member_filter" if TYPE_CHECKING: T = TypeVar("T", bound="EnumMeta") def __new__(mtc: type[T], name: str, bases: tuple[type, ...], attr: enum._EnumDict, **kwds: Any) -> T: member_names: list[str] = attr._member_names # type: ignore def __new__( mtc: type[EnumMeta], name: str, bases: tuple[type, ...], attr: enum._EnumDict, **kwds: object ) -> EnumMeta: member_names: list[str] = attr._member_names # type: ignore # noqa: SLF001 member_filter = attr.pop(mtc.MEMBER_FILTER, None) if member_filter: assert isinstance(member_filter, staticmethod) member_filter.__func__(attr, member_names) cls = enum.EnumMeta.__new__(mtc, name, bases, attr, **kwds) decorator = parse.with_pattern('|'.join(member for member in cls.__members__)) cls = enum.EnumMeta.__new__(mtc, name, bases, attr, boundary=None, _simple=False, **kwds) decorator = parse.with_pattern("|".join(member for member in cls.__members__)) behave.register_type(**{name: decorator(cls)}) return cls Loading @@ -113,5 +110,8 @@ class PatternEnum(enum.Enum, metaclass=EnumMeta): """ @classmethod def _missing_(cls, key: Any) -> Self: return cls[key] def _missing_(cls, value: object) -> Self: if not isinstance(value, str): msg = "PatternEnum values must be strings" raise TypeError(msg) return cls[value]
behave_utils/binaries.py +14 −12 Changes for behave_utils/binaries.py: 14 added lines, 12 removed lines. Original line number Diff line number Diff line # Copyright 2021-2024 Dominik Sekotill <dom.sekotill@kodo.org.uk> # Copyright 2021-2024, 2026 Dominik Sekotill <dom.sekotill@kodo.org.uk> # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this Loading @@ -15,19 +15,20 @@ import re from abc import ABC from abc import abstractmethod from collections.abc import Iterator from http.client import HTTPResponse from io import BytesIO from pathlib import Path from shutil import copyfileobj from tarfile import TarFile from typing import IO from typing import TYPE_CHECKING from typing import ClassVar import requests from packaging.version import Version from xdg_base_dirs import xdg_cache_home from behave_utils.json import JSONObject from behave_utils.url import URL if TYPE_CHECKING: from .types import Readable Loading @@ -54,16 +55,13 @@ class DownloadableExecutable(ABC): # Many Go binaries include the architecture value accepted by `go` in their names, so # the "goarch" class attribute is added for convenience, generated from this map. # This map may not be fully complete. Only non-equal values need to be added. GOARCH_MAP = { GOARCH_MAP: ClassVar = { "i386": "386", "i686": "386", "x86": "386", "x86_64": "amd64", "armv6l": "arm", "armv7l": "arm", "aarch64": "arm64", } Loading @@ -73,13 +71,13 @@ class DownloadableExecutable(ABC): name: str def __init_subclass__(cls, name: str|None = None): def __init_subclass__(cls, name: str | None = None) -> None: if name and hasattr(cls, "name"): raise TypeError(f"Got two 'name' attributes for {cls}: {name} and {cls.name}") if name: cls.name = name def __init__(self, version: str = "latest"): def __init__(self, version: str = "latest") -> None: self.version = version @abstractmethod Loading Loading @@ -232,7 +230,7 @@ class DownloadableKubeTools(DownloadableExecutable): URL = "https://dl.k8s.io/release/{version}/bin/{kernel}/{arch}/{name}" LATEST_URL = "https://dl.k8s.io/release/stable.txt" def __init__(self, name: str, version: str = "latest"): def __init__(self, name: str, version: str = "latest") -> None: DownloadableExecutable.__init__(self, version) self.name = name self._latest = "" Loading @@ -249,8 +247,11 @@ class DownloadableKubeTools(DownloadableExecutable): """ Return a stream that emits the requested Kubernetes binary """ url = self.URL.format(version=version, kernel=self.kernel, arch=self.goarch, name=self.name) stream: IO[bytes] = session.get(url, stream=True).raw url = self.URL.format( version=version, kernel=self.kernel, arch=self.goarch, name=self.name ) stream = session.get(url, stream=True).raw assert isinstance(stream, HTTPResponse) return stream Loading Loading @@ -306,5 +307,6 @@ class DownloadableKind(DownloadableExecutable): Return a stream that emits the requested Kind binary """ url = self.URL.format(version=version, kernel=self.kernel, arch=self.goarch) stream: IO[bytes] = session.get(url, stream=True).raw stream = session.get(url, stream=True).raw assert isinstance(stream, HTTPResponse) return stream