Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .github/pyright-matcher.json

This file was deleted.

8 changes: 2 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,9 @@ jobs:
run: |
uv run --frozen ruff check . --config pyproject.toml --no-fix ${{ matrix.format-for-github && '--output-format=github' }}

- name: Typing (basedpyright)
- name: Typing (ty)
run: |
if [[ "${{ matrix.format-for-github }}" == "true" ]]
then
echo "::add-matcher::.github/pyright-matcher.json"
fi;
uv run --frozen basedpyright
uv run --frozen ty check ${{ matrix.format-for-github && '--output-format=github' }}

format:
name: Format
Expand Down
2 changes: 1 addition & 1 deletion hooks/gen_docs/gen_docs_env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def fill_csv_pipeline_config(target: Path) -> None:
):
assert isinstance(field_info, FieldInfo)
with suppress(KeyError): # In case the prefix is ever removed from KpopsConfig
env_var_name = KpopsConfig.model_config["env_prefix"] + env_var_name # pyright: ignore[reportTypedDictNotRequiredAccess]
env_var_name = KpopsConfig.model_config["env_prefix"] + env_var_name
field_name = concatted_field_name.rsplit(".", 1)[-1]
field_description: str = (
field_info.description
Expand Down
6 changes: 3 additions & 3 deletions kpops/api/options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from enum import StrEnum
from enum import StrEnum, auto
from typing import TYPE_CHECKING

if TYPE_CHECKING:
Expand All @@ -9,8 +9,8 @@


class FilterType(StrEnum):
INCLUDE = "include"
EXCLUDE = "exclude"
INCLUDE = auto()
EXCLUDE = auto()

@staticmethod
def is_in_steps(component: PipelineComponent, component_names: set[str]) -> bool:
Expand Down
16 changes: 5 additions & 11 deletions kpops/component_handlers/kafka_connect/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from typing_extensions import override

from kpops.components.common.topic import KafkaTopic, KafkaTopicStr
from kpops.utils.enum import UpperStrEnum
from kpops.utils.pydantic import (
DescConfigModel,
by_alias,
Expand All @@ -34,9 +35,9 @@ class KafkaConnectorConfig(DescConfigModel):

@override
@staticmethod
def json_schema_extra(schema: dict[str, Any], model: type[BaseModel]) -> None:
def json_schema_extra(schema: dict[str, Any], model_cls: type[BaseModel]) -> None:
super(KafkaConnectorConfig, KafkaConnectorConfig).json_schema_extra(
schema, model
schema, model_cls
)
schema["additional_properties"] = {
"type": {
Expand Down Expand Up @@ -95,13 +96,6 @@ def serialize_model(
}


class UpperStrEnum(StrEnum):
@override
@staticmethod
def _generate_next_value_(name: str, *args: Any, **kwargs: Any) -> str:
return name.upper()


class ConnectorCurrentState(UpperStrEnum):
RUNNING = auto()
PAUSED = auto()
Expand Down Expand Up @@ -144,8 +138,8 @@ class ConnectorTaskStatus(BaseModel):


class KafkaConnectorType(StrEnum):
SINK = "sink"
SOURCE = "source"
SINK = auto()
SOURCE = auto()


class ConnectorStatusResponse(BaseModel):
Expand Down
19 changes: 9 additions & 10 deletions kpops/component_handlers/schema_handler/schema_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from functools import cached_property
from typing import TYPE_CHECKING, final

import httpx
import structlog
from schema_registry.client import AsyncSchemaRegistryClient
from schema_registry.client.schema import AvroSchema
Expand All @@ -29,7 +30,7 @@ class SchemaHandler:
def __init__(self, kpops_config: KpopsConfig) -> None:
self.schema_registry_client = AsyncSchemaRegistryClient(
str(kpops_config.schema_registry.url),
timeout=kpops_config.schema_registry.timeout, # pyright: ignore[reportArgumentType]
timeout=httpx.Timeout(kpops_config.schema_registry.timeout),
)

@cached_property
Expand All @@ -38,7 +39,7 @@ def schema_provider(self) -> SchemaProvider:
schema_provider_class = find_class(
Registry.iter_component_modules(), base=SchemaProvider
)
return schema_provider_class() # pyright: ignore[reportAbstractUsage]
return schema_provider_class()
except ClassNotFoundError as e:
msg = f"No schema provider found. Please implement the abstract method in {SchemaProvider.__module__}.{SchemaProvider.__name__}."
raise ValueError(msg) from e
Expand Down Expand Up @@ -127,29 +128,27 @@ async def __submit_schema(
)
)
else:
await self.schema_registry_client.register( # pyright: ignore[reportUnknownMemberType]
subject=subject, schema=schema
)
await self.schema_registry_client.register(subject=subject, schema=schema)
log.info(
"Schema submitted.",
subject=subject,
model=schema_class,
)

async def __subject_exists(self, subject: str) -> bool:
versions: list[SchemaVersion] = await self.schema_registry_client.get_versions( # pyright: ignore[reportUnknownMemberType]
versions: list[SchemaVersion] = await self.schema_registry_client.get_versions(
subject
)
return len(versions) > 0

async def __check_compatibility(
self, schema: Schema, schema_class: str, subject: str
) -> None:
registered_version = await self.schema_registry_client.check_version( # pyright: ignore[reportUnknownMemberType]
registered_version = await self.schema_registry_client.check_version(
subject, schema
)
if registered_version is None:
if not await self.schema_registry_client.test_compatibility( # pyright: ignore[reportUnknownMemberType]
if not await self.schema_registry_client.test_compatibility(
subject=subject, schema=schema
):
schema_str = (
Expand All @@ -163,7 +162,7 @@ async def __check_compatibility(
log.debug(
"Schema was already submitted. Therefore, the specified schema must be compatible.",
subject=subject,
version=registered_version.schema, # pyright: ignore[reportUnknownMemberType]
version=registered_version.schema,
)

log.info(
Expand All @@ -180,7 +179,7 @@ async def __delete_subject(self, subject: str, dry_run: bool) -> None:
else:
version_list: list[
SchemaVersion
] = await self.schema_registry_client.delete_subject(subject) # pyright: ignore[reportUnknownMemberType]
] = await self.schema_registry_client.delete_subject(subject)
log.info(
"Deleted subject.",
subject=subject,
Expand Down
30 changes: 16 additions & 14 deletions kpops/component_handlers/topic/model.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from enum import StrEnum
from enum import auto
from typing import Any, ClassVar

from pydantic import BaseModel, ConfigDict

from kpops.utils.enum import UpperStrEnum


class TopicSpec(BaseModel):
topic_name: str
Expand All @@ -28,15 +30,15 @@ class TopicResponse(BaseModel):
)


class KafkaTopicConfigSource(StrEnum):
DYNAMIC_TOPIC_CONFIG = "DYNAMIC_TOPIC_CONFIG"
DEFAULT_CONFIG = "DEFAULT_CONFIG"
STATIC_BROKER_CONFIG = "STATIC_BROKER_CONFIG"
DYNAMIC_CLUSTER_LINK_CONFIG = "DYNAMIC_CLUSTER_LINK_CONFIG"
DYNAMIC_BROKER_LOGGER_CONFIG = "DYNAMIC_BROKER_LOGGER_CONFIG"
DYNAMIC_BROKER_CONFIG = "DYNAMIC_BROKER_CONFIG"
DYNAMIC_DEFAULT_BROKER_CONFIG = "DYNAMIC_DEFAULT_BROKER_CONFIG"
UNKNOWN = "UNKNOWN"
class KafkaTopicConfigSource(UpperStrEnum):
DYNAMIC_TOPIC_CONFIG = auto()
DEFAULT_CONFIG = auto()
STATIC_BROKER_CONFIG = auto()
DYNAMIC_CLUSTER_LINK_CONFIG = auto()
DYNAMIC_BROKER_LOGGER_CONFIG = auto()
DYNAMIC_BROKER_CONFIG = auto()
DYNAMIC_DEFAULT_BROKER_CONFIG = auto()
UNKNOWN = auto()


class KafkaTopicConfigSynonyms(BaseModel):
Expand Down Expand Up @@ -68,10 +70,10 @@ class TopicConfigResponse(BaseModel):
)


class KafkaBrokerConfigSource(StrEnum):
STATIC_BROKER_CONFIG = "STATIC_BROKER_CONFIG"
DYNAMIC_BROKER_CONFIG = "DYNAMIC_BROKER_CONFIG"
DEFAULT_CONFIG = "DEFAULT_CONFIG"
class KafkaBrokerConfigSource(UpperStrEnum):
STATIC_BROKER_CONFIG = auto()
DYNAMIC_BROKER_CONFIG = auto()
DEFAULT_CONFIG = auto()


class KafkaBrokerConfigSynonyms(BaseModel):
Expand Down
6 changes: 3 additions & 3 deletions kpops/components/base_components/base_defaults_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class BaseDefaultsComponent(DescConfigModel, ABC):

model_config: ClassVar[ConfigDict] = ConfigDict(
arbitrary_types_allowed=True,
ignored_types=(cached_property, cached_classproperty), # pyright: ignore[reportArgumentType]
ignored_types=(cached_property, cached_classproperty), # ty: ignore[invalid-argument-type]
)
enrich: SkipJsonSchema[bool] = Field(
default=True,
Expand Down Expand Up @@ -83,15 +83,15 @@ def validate_component(self) -> Self:

@computed_field
@cached_classproperty
def type(cls: type[Self]) -> str: # pyright: ignore[reportGeneralTypeIssues]
def type(cls: type[Self]) -> str: # ty: ignore[invalid-type-form]
"""Return calling component's type.

:returns: Component class name in dash-case
"""
return to_dash(cls.__name__)

@cached_classproperty
def parents(cls: type[Self]) -> tuple[type[BaseDefaultsComponent], ...]: # pyright: ignore[reportGeneralTypeIssues]
def parents(cls: type[Self]) -> tuple[type[BaseDefaultsComponent], ...]: # ty: ignore[invalid-type-form]
"""Get parent components.

:return: All ancestor KPOps components
Expand Down
2 changes: 1 addition & 1 deletion kpops/components/base_components/helm_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class HelmApp(KubernetesApp):
diff_config: SkipGenerate[HelmDiffConfig] = HelmDiffConfig()
version: str | None = None
timeout: str | None = None
values: HelmAppValues # pyright: ignore[reportIncompatibleVariableOverride]
values: HelmAppValues

@cached_property
def _helm(self) -> Helm:
Expand Down
6 changes: 3 additions & 3 deletions kpops/components/base_components/models/from_section.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import StrEnum
from enum import StrEnum, auto
from typing import Any, ClassVar, NewType

from pydantic import ConfigDict, model_validator
Expand All @@ -14,8 +14,8 @@ class InputTopicTypes(StrEnum):
- PATTERN: extra-topic-pattern or input-topic-pattern
"""

INPUT = "input"
PATTERN = "pattern"
INPUT = auto()
PATTERN = auto()


class FromTopic(DescConfigModel):
Expand Down
6 changes: 3 additions & 3 deletions kpops/components/common/topic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from collections.abc import Iterable
from enum import StrEnum
from enum import StrEnum, auto
from typing import Annotated, Any, ClassVar

import pydantic
Expand All @@ -17,8 +17,8 @@ class OutputTopicTypes(StrEnum):
- ERROR: error topic
"""

OUTPUT = "output"
ERROR = "error"
OUTPUT = auto()
ERROR = auto()


class TopicConfig(DescConfigModel):
Expand Down
16 changes: 9 additions & 7 deletions kpops/components/streams_bootstrap/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
from kpops.utils.pydantic import SkipGenerate

if TYPE_CHECKING:
from kpops.components.streams_bootstrap_v2.base import StreamsBootstrapV2
from kpops.components.streams_bootstrap_v2.base import (
StreamsBootstrapV2, # ty: ignore[deprecated]
)

STREAMS_BOOTSTRAP_HELM_REPO = HelmRepoConfig(
repository_name="bakdata-streams-bootstrap",
Expand All @@ -43,9 +45,9 @@ class StreamsBootstrap(KafkaApp, HelmApp, ABC):
:param version: Helm chart version, defaults to "3.6.1"
"""

values: StreamsBootstrapValues # pyright: ignore[reportIncompatibleVariableOverride]
repo_config: SkipGenerate[HelmRepoConfig] = STREAMS_BOOTSTRAP_HELM_REPO # pyright: ignore[reportIncompatibleVariableOverride]
version: str = Field( # pyright: ignore[reportIncompatibleVariableOverride]
values: StreamsBootstrapValues
repo_config: SkipGenerate[HelmRepoConfig] = STREAMS_BOOTSTRAP_HELM_REPO
version: str = Field(
default=STREAMS_BOOTSTRAP_VERSION,
pattern=STREAMS_BOOTSTRAP_VERSION_PATTERN,
)
Expand Down Expand Up @@ -101,11 +103,11 @@ def manifest_destroy(self) -> tuple[KubernetesManifest, ...]:
class StreamsBootstrapCleaner(Cleaner, ABC):
"""Helm app for resetting and cleaning a streams-bootstrap app."""

from_: None = None # pyright: ignore[reportIncompatibleVariableOverride]
to: None = None # pyright: ignore[reportIncompatibleVariableOverride]
from_: None = None
to: None = None

@classmethod
def from_parent(cls, parent: StreamsBootstrap | StreamsBootstrapV2) -> Self:
def from_parent(cls, parent: StreamsBootstrap | StreamsBootstrapV2) -> Self: # ty: ignore[deprecated]
parent_kwargs = parent.model_dump(
by_alias=True,
exclude_none=True,
Expand Down
11 changes: 6 additions & 5 deletions kpops/components/streams_bootstrap/common/model.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from __future__ import annotations

from enum import StrEnum
from enum import auto
from typing import Any, ClassVar, Self

import pydantic
from pydantic import ConfigDict, Field

from kpops.components.common.kubernetes_model import ImagePullPolicy, Resources
from kpops.components.common.topic import KafkaTopic
from kpops.utils.enum import UpperStrEnum
from kpops.utils.pydantic import (
CamelCaseConfigModel,
DescConfigModel,
Expand All @@ -29,10 +30,10 @@ def serialize_labeled_input_topics(
}


class JmxRuleType(StrEnum):
GAUGE = "GAUGE"
COUNTER = "COUNTER"
UNTYPED = "UNTYPED"
class JmxRuleType(UpperStrEnum):
GAUGE = auto()
COUNTER = auto()
UNTYPED = auto()


class JMXRule(SerializeAsOptionalModel, CamelCaseConfigModel, DescConfigModel):
Expand Down
Loading
Loading