Skip to content

Commit

Permalink
Remove class var
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted committed Jan 26, 2023
1 parent 448cc68 commit e5d5c51
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions kpops/components/base_components/base_defaults_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections import deque
from collections.abc import Mapping, Sequence
from pathlib import Path
from typing import ClassVar, TypeVar
from typing import TypeVar

import typer
from pydantic import BaseConfig, BaseModel, Field, PrivateAttr
Expand All @@ -17,7 +17,7 @@


class BaseDefaultsComponent(BaseModel):
type: ClassVar[str] = Field(..., const=True) # component type discriminator
type: str = Field(..., const=True) # component type discriminator

enrich: bool = Field(default=False, exclude=True)
config: PipelineConfig = Field(default=..., exclude=True)
Expand Down
4 changes: 2 additions & 2 deletions kpops/components/base_components/kafka_app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import logging
from typing import ClassVar, Literal
from typing import Literal

from pydantic import BaseModel, Extra
from typing_extensions import override
Expand Down Expand Up @@ -38,7 +38,7 @@ class KafkaApp(KubernetesApp):
Producer or streaming apps should inherit from this class.
"""

type: ClassVar[Literal["kafka-app"]] = "kafka-app"
type: Literal["kafka-app"] = "kafka-app"
app: KafkaAppConfig

def __init__(self, **kwargs) -> None:
Expand Down
8 changes: 4 additions & 4 deletions kpops/components/base_components/kafka_connect.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import os
from abc import ABC
from typing import ClassVar, Literal, NoReturn
from typing import Literal, NoReturn

from typing_extensions import override

Expand All @@ -14,7 +14,7 @@


class KafkaConnector(PipelineComponent, ABC):
type: ClassVar[Literal["kafka-connect"]] = "kafka-connect"
type: Literal["kafka-connect"] = "kafka-connect"
app: KafkaConnectConfig

def __init__(self, **kwargs) -> None:
Expand Down Expand Up @@ -64,7 +64,7 @@ def clean(self, dry_run: bool) -> None:


class KafkaSourceConnector(KafkaConnector):
type: ClassVar[Literal["kafka-source-connector"]] = "kafka-source-connector"
type: Literal["kafka-source-connector"] = "kafka-source-connector"

@override
def apply_from_inputs(self, name: str, topic: FromTopic) -> NoReturn:
Expand All @@ -90,7 +90,7 @@ def __run_kafka_connect_resetter(self, dry_run: bool) -> None:


class KafkaSinkConnector(KafkaConnector):
type: ClassVar[Literal["kafka-sink-connector"]] = "kafka-sink-connector"
type: Literal["kafka-sink-connector"] = "kafka-sink-connector"

@override
def add_input_topics(self, topics: list[str]) -> None:
Expand Down
4 changes: 2 additions & 2 deletions kpops/components/base_components/kubernetes_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import re
from functools import cached_property
from typing import ClassVar, Literal
from typing import Literal

from pydantic import BaseModel
from typing_extensions import override
Expand Down Expand Up @@ -36,7 +36,7 @@ class Config(CamelCaseConfig):
class KubernetesApp(PipelineComponent):
"""Base kubernetes app"""

type: ClassVar[Literal["kubernetes-app"]] = "kubernetes-app"
type: Literal["kubernetes-app"] = "kubernetes-app"
app: KubernetesAppConfig

version: str | None = None
Expand Down
4 changes: 2 additions & 2 deletions kpops/components/streams_bootstrap/producer/producer_app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import ClassVar, Literal
from typing import Literal

from pydantic import BaseConfig, Extra
from typing_extensions import override
Expand All @@ -20,7 +20,7 @@ class ProducerApp(KafkaApp):
This producer holds configuration to use as values for the streams bootstrap produce helm chart.
"""

type: ClassVar[Literal["producer"]] = "producer"
type: Literal["producer"] = "producer"
app: ProducerValues

class Config(BaseConfig):
Expand Down
4 changes: 2 additions & 2 deletions kpops/components/streams_bootstrap/streams/streams_app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import ClassVar, Literal
from typing import Literal

from pydantic import BaseConfig, Extra
from typing_extensions import override
Expand All @@ -16,7 +16,7 @@ class StreamsApp(KafkaApp):
StreamsApp component that configures a streams bootstrap app
"""

type: ClassVar[Literal["streams-app"]] = "streams-app"
type: Literal["streams-app"] = "streams-app"
app: StreamsAppConfig

class Config(BaseConfig):
Expand Down
6 changes: 3 additions & 3 deletions tests/cli/test_registry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import ClassVar, Literal
from typing import Literal

import pytest
from pydantic import BaseModel
Expand All @@ -10,12 +10,12 @@


class SubComponent(PipelineComponent):
type: ClassVar[Literal["sub-component"]] = "sub-component"
type: Literal["sub-component"] = "sub-component"
pass


class SubSubComponent(SubComponent):
type: ClassVar[Literal["sub-sub-component"]] = "sub-sub-component"
type: Literal["sub-sub-component"] = "sub-sub-component"
pass


Expand Down
10 changes: 5 additions & 5 deletions tests/components/test_base_defaults_component.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from pathlib import Path
from typing import ClassVar, Literal
from typing import Literal
from unittest.mock import MagicMock

import pytest
Expand All @@ -17,22 +17,22 @@

class TestParentModel(BaseDefaultsComponent):
__test__ = False
type: ClassVar[Literal["parent"]] = "parent"
type: Literal["parent"] = "parent"
name: str | None = None
value: float | None = None
hard_coded: str = "hard_coded_value"


class TestChildModel(TestParentModel):
__test__ = False
type: ClassVar[Literal["child"]] = "child"
type: Literal["child"] = "child"
nice: dict | None = None
another_hard_coded: str = "another_hard_coded_value"


class TestGrandChildModel(TestChildModel):
__test__ = False
type: ClassVar[Literal["grand-child"]] = "grand-child"
type: Literal["grand-child"] = "grand-child"
grand_child: str | None = None


Expand Down Expand Up @@ -126,7 +126,7 @@ def test_env_var_substitution(
self, config: PipelineConfig, handlers: ComponentHandlers
):
class TestEnvVarModel(BaseDefaultsComponent):
type: ClassVar[Literal["env-var-test"]] = "env-var-test"
type: Literal["env-var-test"] = "env-var-test"
name: str | None = None

os.environ["pipeline_name"] = str(DEFAULTS_PATH)
Expand Down
4 changes: 2 additions & 2 deletions tests/components/test_streams_app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from typing import ClassVar, Literal
from typing import Literal
from unittest.mock import MagicMock

import pytest
Expand Down Expand Up @@ -72,7 +72,7 @@ def streams_app(

def test_set_topics(self, config: PipelineConfig, handlers: ComponentHandlers):
class AnotherType(StreamsApp):
type: ClassVar[Literal["test"]] = "test"
type: Literal["test"] = "test"

streams_app = AnotherType(
config=config,
Expand Down
10 changes: 5 additions & 5 deletions tests/pipeline/test_components/components.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, ClassVar, Literal
from typing import Any, Literal

from schema_registry.client.schema import AvroSchema
from typing_extensions import override
Expand All @@ -14,11 +14,11 @@


class ImportProducer(ProducerApp):
type: ClassVar[Literal["scheduled-producer"]] = "scheduled-producer"
type: Literal["scheduled-producer"] = "scheduled-producer"


class Converter(StreamsApp):
type: ClassVar[Literal["converter"]] = "converter"
type: Literal["converter"] = "converter"


class SubStreamsApp(StreamsApp):
Expand All @@ -28,11 +28,11 @@ class SubStreamsApp(StreamsApp):
class Filter(SubStreamsApp):
"""Subsubclass of StreamsApp to test inheritance."""

type: ClassVar[Literal["filter"]] = "filter"
type: Literal["filter"] = "filter"


class InflateStep(StreamsApp):
type: ClassVar[Literal["should-inflate"]] = "should-inflate"
type: Literal["should-inflate"] = "should-inflate"

@override
def inflate(self) -> list[PipelineComponent]:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import ClassVar, Literal
from typing import Literal

from typing_extensions import override

Expand All @@ -10,15 +10,15 @@


class ImportProducer(ProducerApp):
type: ClassVar[Literal["scheduled-producer"]] = "scheduled-producer"
type: Literal["scheduled-producer"] = "scheduled-producer"


class Converter(StreamsApp):
type: ClassVar[Literal["converter"]] = "converter"
type: Literal["converter"] = "converter"


class InflateStep(StreamsApp):
type: ClassVar[Literal["should-inflate"]] = "should-inflate"
type: Literal["should-inflate"] = "should-inflate"

@override
def inflate(self) -> list[PipelineComponent]:
Expand Down

0 comments on commit e5d5c51

Please sign in to comment.