Skip to content

Commit

Permalink
chore: format with ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaakola-aiven committed Jan 8, 2025
1 parent 8c6e0e9 commit bdb5f5c
Show file tree
Hide file tree
Showing 157 changed files with 202 additions and 72 deletions.
1 change: 1 addition & 0 deletions container/healthcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from http import HTTPStatus
Expand Down
1 change: 1 addition & 0 deletions performance-test/rest-proxy-produce-consume-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from kafka.admin import KafkaAdminClient, NewTopic
from kafka.errors import TopicAlreadyExistsError
from locust import FastHttpUser, task
Expand Down
1 change: 1 addition & 0 deletions performance-test/schema-registry-schema-post.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from dataclasses import dataclass, field
from locust import FastHttpUser, task
from locust.contrib.fasthttp import ResponseContextManager
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from setuptools import Extension, setup

setup(
Expand Down
1 change: 1 addition & 0 deletions src/karapace/anonymize_schemas/anonymize_avro.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from typing import Any, TypeAlias, Union

import hashlib
Expand Down
16 changes: 6 additions & 10 deletions src/karapace/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from base64 import b64encode
Expand Down Expand Up @@ -98,26 +99,21 @@ class AuthData(TypedDict):


class AuthenticateProtocol(Protocol):
def authenticate(self, *, username: str, password: str) -> User | None:
...
def authenticate(self, *, username: str, password: str) -> User | None: ...


class AuthorizeProtocol(Protocol):
def get_user(self, username: str) -> User | None:
...
def get_user(self, username: str) -> User | None: ...

def check_authorization(self, user: User | None, operation: Operation, resource: str) -> bool:
...
def check_authorization(self, user: User | None, operation: Operation, resource: str) -> bool: ...

def check_authorization_any(self, user: User | None, operation: Operation, resources: list[str]) -> bool:
...
def check_authorization_any(self, user: User | None, operation: Operation, resources: list[str]) -> bool: ...


class AuthenticatorAndAuthorizer(AuthenticateProtocol, AuthorizeProtocol):
MUST_AUTHENTICATE: bool = True

async def close(self) -> None:
...
async def close(self) -> None: ...

async def start(self, stats: StatsClient) -> None: # pylint: disable=unused-argument
...
Expand Down
9 changes: 3 additions & 6 deletions src/karapace/avro_dataclasses/introspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@
from _typeshed import DataclassInstance
else:

class DataclassInstance:
...
class DataclassInstance: ...


class UnsupportedAnnotation(NotImplementedError):
...
class UnsupportedAnnotation(NotImplementedError): ...


class UnderspecifiedAnnotation(UnsupportedAnnotation):
...
class UnderspecifiedAnnotation(UnsupportedAnnotation): ...


def _field_type_array(field: Field, origin: type, type_: object) -> AvroType:
Expand Down
4 changes: 2 additions & 2 deletions src/karapace/avro_dataclasses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from .introspect import record_schema
Expand All @@ -22,8 +23,7 @@
from _typeshed import DataclassInstance
else:

class DataclassInstance:
...
class DataclassInstance: ...


__all__ = ("AvroModel",)
Expand Down
1 change: 1 addition & 0 deletions src/karapace/avro_dataclasses/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from collections.abc import Mapping
Expand Down
1 change: 1 addition & 0 deletions src/karapace/backup/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from .backends.reader import BaseBackupReader, BaseItemsBackupReader, ProducerSend, RestoreTopic, RestoreTopicLegacy
Expand Down
4 changes: 2 additions & 2 deletions src/karapace/backup/backends/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from collections.abc import Callable, Generator, Iterator, Mapping, Sequence
Expand Down Expand Up @@ -78,8 +79,7 @@ def __init__(

@staticmethod
@abc.abstractmethod
def items_from_file(fp: IO[str]) -> Iterator[Sequence[str]]:
...
def items_from_file(fp: IO[str]) -> Iterator[Sequence[str]]: ...

def read(
self,
Expand Down
1 change: 1 addition & 0 deletions src/karapace/backup/backends/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from collections.abc import Generator
Expand Down
1 change: 1 addition & 0 deletions src/karapace/backup/backends/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from collections.abc import Generator, Sequence
Expand Down
1 change: 1 addition & 0 deletions src/karapace/backup/backends/v3/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from .checksum import RunningChecksum
Expand Down
7 changes: 3 additions & 4 deletions src/karapace/backup/backends/v3/checksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from typing import Protocol


class RunningChecksum(Protocol):
def update(self, data: bytes) -> None:
...
def update(self, data: bytes) -> None: ...

def digest(self) -> bytes:
...
def digest(self) -> bytes: ...
1 change: 1 addition & 0 deletions src/karapace/backup/backends/v3/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from typing import Final

V3_MARKER: Final = b"/V3\n"
1 change: 1 addition & 0 deletions src/karapace/backup/backends/v3/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from .checksum import RunningChecksum
Expand Down
1 change: 1 addition & 0 deletions src/karapace/backup/backends/v3/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from collections.abc import Mapping
from dataclasses import field
from karapace.avro_dataclasses.models import AvroModel
Expand Down
1 change: 1 addition & 0 deletions src/karapace/backup/backends/v3/schema_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from . import schema
from avro.compatibility import ReaderWriterCompatibilityChecker, SchemaCompatibilityType
from collections.abc import Generator
Expand Down
1 change: 1 addition & 0 deletions src/karapace/backup/backends/v3/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from .checksum import RunningChecksum
from .constants import V3_MARKER
from .errors import IntegerAboveBound, IntegerBelowBound
Expand Down
4 changes: 2 additions & 2 deletions src/karapace/backup/backends/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from collections.abc import Iterator, Mapping, Sequence
Expand Down Expand Up @@ -170,5 +171,4 @@ def store_record(
def serialize_record(
key_bytes: bytes | None,
value_bytes: bytes | None,
) -> str:
...
) -> str: ...
1 change: 1 addition & 0 deletions src/karapace/backup/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from . import api
Expand Down
1 change: 1 addition & 0 deletions src/karapace/backup/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from karapace.key_format import KeyFormatter
Expand Down
4 changes: 2 additions & 2 deletions src/karapace/backup/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from confluent_kafka import TopicPartition
from karapace.backup.poll_timeout import PollTimeout

Expand All @@ -12,8 +13,7 @@ class BackupError(Exception):
"""Baseclass for all backup errors."""


class EmptyPartition(BackupError):
...
class EmptyPartition(BackupError): ...


class PartitionCountError(BackupError):
Expand Down
1 change: 1 addition & 0 deletions src/karapace/backup/poll_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from datetime import timedelta
Expand Down
4 changes: 2 additions & 2 deletions src/karapace/backup/safe_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from collections.abc import Generator
Expand All @@ -19,8 +20,7 @@
std_out_alias: Final = ("", "-")


class OverwriteRefused(Exception):
...
class OverwriteRefused(Exception): ...


def _check_destination_file(destination: Path, allow_overwrite: bool) -> None:
Expand Down
1 change: 1 addition & 0 deletions src/karapace/backup/topic_configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from collections.abc import Container
Expand Down
1 change: 1 addition & 0 deletions src/karapace/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from aiohttp import BasicAuth, ClientSession
from collections.abc import Awaitable, Callable, Mapping
from karapace.typing import JsonData
Expand Down
1 change: 1 addition & 0 deletions src/karapace/compatibility/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Copyright (c) 2019 Aiven Ltd
See LICENSE for details
"""

from enum import Enum, unique

import logging
Expand Down
1 change: 1 addition & 0 deletions src/karapace/compatibility/jsonschema/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from avro.compatibility import merge, SchemaCompatibilityResult, SchemaCompatibilityType, SchemaIncompatibilityType
Expand Down
1 change: 1 addition & 0 deletions src/karapace/compatibility/jsonschema/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from collections.abc import Callable
from dataclasses import dataclass
from enum import Enum, unique
Expand Down
1 change: 1 addition & 0 deletions src/karapace/compatibility/jsonschema/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from copy import copy
from jsonschema import Draft7Validator
from karapace.compatibility.jsonschema.types import BooleanSchema, Instance, Keyword, Subschema
Expand Down
1 change: 1 addition & 0 deletions src/karapace/compatibility/protobuf/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from avro.compatibility import SchemaCompatibilityResult, SchemaCompatibilityType
from karapace.protobuf.compare_result import CompareResult
from karapace.protobuf.schema import ProtobufSchema
Expand Down
1 change: 1 addition & 0 deletions src/karapace/compatibility/schema_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 2024 Aiven Ltd
See LICENSE for details
"""

from avro.compatibility import (
merge,
ReaderWriterCompatibilityChecker as AvroChecker,
Expand Down
1 change: 1 addition & 0 deletions src/karapace/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from collections.abc import Mapping
Expand Down
1 change: 1 addition & 0 deletions src/karapace/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from typing import Final

SCHEMA_TOPIC_NUM_PARTITIONS: Final = 1
Expand Down
1 change: 1 addition & 0 deletions src/karapace/coordinator/master_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""

from __future__ import annotations

from aiokafka import AIOKafkaClient
Expand Down
Loading

0 comments on commit bdb5f5c

Please sign in to comment.