Skip to content

Commit

Permalink
ci(ruff-type-checking): Add "TCH001" with proper config
Browse files Browse the repository at this point in the history
  • Loading branch information
sujuka99 committed Sep 27, 2023
1 parent 25b0c08 commit 0b9f26c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 deletions.
7 changes: 3 additions & 4 deletions kpops/component_handlers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

from typing import TYPE_CHECKING

from kpops.component_handlers.kafka_connect.kafka_connect_handler import (
KafkaConnectHandler,
)

if TYPE_CHECKING:
from kpops.component_handlers.kafka_connect.kafka_connect_handler import (
KafkaConnectHandler,
)
from kpops.component_handlers.schema_handler.schema_handler import SchemaHandler
from kpops.component_handlers.topic.handler import TopicHandler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
ConnectorNotFoundException,
ConnectorStateException,
)
from kpops.component_handlers.kafka_connect.model import KafkaConnectorConfig
from kpops.component_handlers.kafka_connect.timeout import timeout
from kpops.utils.colorify import magentaify
from kpops.utils.dict_differ import render_diff
Expand All @@ -20,6 +19,7 @@
from typing_extensions import Self

from kpops.cli.pipeline_config import PipelineConfig
from kpops.component_handlers.kafka_connect.model import KafkaConnectorConfig

log = logging.getLogger("KafkaConnectHandler")

Expand Down
7 changes: 5 additions & 2 deletions kpops/component_handlers/schema_handler/schema_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@
import json
import logging
from functools import cached_property
from typing import TYPE_CHECKING

from schema_registry.client import SchemaRegistryClient
from schema_registry.client.schema import AvroSchema

from kpops.cli.exception import ClassNotFoundError
from kpops.cli.pipeline_config import PipelineConfig
from kpops.cli.registry import find_class
from kpops.component_handlers.schema_handler.schema_provider import (
Schema,
SchemaProvider,
)
from kpops.components.base_components.models.to_section import ToSection
from kpops.utils.colorify import greenify, magentaify

log = logging.getLogger("SchemaHandler")

if TYPE_CHECKING:
from kpops.cli.pipeline_config import PipelineConfig
from kpops.components.base_components.models.to_section import ToSection


class SchemaHandler:
def __init__(self, url: str, components_module: str | None):
Expand Down
7 changes: 4 additions & 3 deletions kpops/component_handlers/schema_handler/schema_provider.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from typing import TypeAlias
from typing import TYPE_CHECKING, TypeAlias

from schema_registry.client.schema import AvroSchema, JsonSchema

from kpops.components.base_components.models import ModelName, ModelVersion

Schema: TypeAlias = AvroSchema | JsonSchema

if TYPE_CHECKING:
from kpops.components.base_components.models import ModelName, ModelVersion


class SchemaProvider(ABC):
@abstractmethod
Expand Down
6 changes: 4 additions & 2 deletions kpops/components/base_components/kafka_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from abc import ABC
from functools import cached_property
from typing import Any, NoReturn
from typing import TYPE_CHECKING, Any, NoReturn

from pydantic import Field, validator
from typing_extensions import override
Expand All @@ -25,11 +25,13 @@
KafkaConnectResetterValues,
)
from kpops.components.base_components.base_defaults_component import deduplicate
from kpops.components.base_components.models.from_section import FromTopic
from kpops.components.base_components.pipeline_component import PipelineComponent
from kpops.utils.colorify import magentaify
from kpops.utils.docstring import describe_attr

if TYPE_CHECKING:
from kpops.components.base_components.models.from_section import FromTopic

log = logging.getLogger("KafkaConnector")


Expand Down
7 changes: 4 additions & 3 deletions kpops/pipeline_generator/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
from rich.console import Console
from rich.syntax import Syntax

from kpops.cli.pipeline_config import PipelineConfig
from kpops.cli.registry import Registry
from kpops.component_handlers import ComponentHandlers
from kpops.components.base_components.pipeline_component import PipelineComponent
from kpops.utils.dict_ops import generate_substitution, update_nested_pair
from kpops.utils.environment import ENV
Expand All @@ -23,6 +20,10 @@
from collections.abc import Iterator
from pathlib import Path

from kpops.cli.pipeline_config import PipelineConfig
from kpops.cli.registry import Registry
from kpops.component_handlers import ComponentHandlers

log = logging.getLogger("PipelineGenerator")


Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ ignore = [
"RET506", # Unnecessary {branch} after raise statement -- Lots of false positives
"RET507", # Unnecessary {branch} after continue statement -- Lots of false positives
"RET508", # Unnecessary {branch} after break statement -- Lots of false positives
"TCH001", # Move application import {} into a type-checking block -- Breaks KPOps
# "TCH001", # Move application import {} into a type-checking block -- Breaks KPOps
"PLR09", # upper bound on number of arguments, functions, etc. -- Inconvenient to enforce
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable -- Inconvenient to enforce
"PLW2901", # `for` loop variable `{var}` overwritten by assignment target -- Inconvenient to enforce
Expand Down Expand Up @@ -155,6 +155,9 @@ exclude = ["tests/*snapshots/*"]
[tool.ruff.flake8-bugbear]
extend-immutable-calls = ["typer.Argument"]

[tool.ruff.flake8-type-checking]
runtime-evaluated-base-classes = ["pydantic.BaseModel", "kpops.components.base_components.kafka_app.KafkaApp"]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

0 comments on commit 0b9f26c

Please sign in to comment.