Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for Python 3.10 #561

Merged
merged 8 commits into from
Dec 12, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/actions/update-docs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ runs:
- name: Install Python and set up Poetry
uses: bakdata/ci-templates/actions/python-setup-poetry@v1.5.2
with:
python-version: "3.11"
poetry-version: "1.5.1"
python-version: "3.10"

- name: Install docs dependencies
shell: bash
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
os:
- ubuntu-22.04
- windows-2022
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.11", "3.12"]
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -32,8 +32,8 @@ jobs:
- name: Install Python and set up Poetry
uses: bakdata/ci-templates/actions/python-setup-poetry@v1.5.3
with:
poetry-version: "1.7.1"
python-version: ${{ matrix.python-version }}
poetry-version: "1.7.1"

- name: Check Poetry lock file consistency
run: poetry lock --check
Expand All @@ -43,7 +43,7 @@ jobs:

- name: Lint (ruff)
run: |
if [[ "$RUNNER_OS" == "Linux" && "${{ matrix.python-version }}" == "3.10" ]]
if [[ "$RUNNER_OS" == "Linux" && "${{ matrix.python-version }}" == "3.11" ]]
then
poetry run ruff check . --config pyproject.toml --output-format=github --no-fix
else
Expand All @@ -55,7 +55,7 @@ jobs:

- name: Typing (pyright)
run: |
if [[ "$RUNNER_OS" == "Linux" && "${{ matrix.python-version }}" == "3.10" ]]
if [[ "$RUNNER_OS" == "Linux" && "${{ matrix.python-version }}" == "3.11" ]]
then
echo "::add-matcher::.github/pyright-matcher.json"
poetry run pre-commit run pyright --all-files
Expand Down Expand Up @@ -93,6 +93,7 @@ jobs:
needs: [test]
uses: bakdata/ci-templates/.github/workflows/python-poetry-publish-snapshot.yaml@1.40.4
with:
python-version: "3.11"
poetry-version: "1.7.1"
secrets:
pypi-token: ${{ secrets.TEST_PYPI_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
uses: bakdata/ci-templates/.github/workflows/python-poetry-publish-pypi.yaml@1.40.4
with:
publish-to-test: false
python-version: "3.11"
poetry-version: "1.7.1"
secrets:
pypi-token: "${{ secrets.PYPI_TOKEN }}"
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
name: Release
with:
release-type: ${{ inputs.release-type }}
python-version: "3.11"
poetry-version: "1.7.1"
changelog: true
changelog-config: "./.github/changelog-config.json"
Expand Down
4 changes: 2 additions & 2 deletions hooks/gen_docs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Documentation generation."""

from collections.abc import Iterator
from enum import Enum
from enum import StrEnum


class IterableStrEnum(str, Enum):
class IterableStrEnum(StrEnum):
"""Polyfill that also introduces dict-like behavior.

Introduces constructors that return a ``Iterator`` object
Expand Down
6 changes: 2 additions & 4 deletions hooks/gen_docs/gen_docs_env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dataclasses import dataclass
from pathlib import Path
from textwrap import fill
from typing import Any
from typing import Any, Self

from pydantic_core import PydanticUndefined
from pytablewriter import MarkdownTableWriter
Expand Down Expand Up @@ -70,9 +70,7 @@ class EnvVar:
corresponding_setting_name: str | None

@classmethod
def from_record(
cls, record: dict[str, Any]
) -> EnvVar: # TODO: typing.Self for Python 3.11+
def from_record(cls, record: dict[str, Any]) -> Self:
"""Construct an ``EnvVar`` instance from a specific dict.

Reads a dict that contains keys equivalent to the
Expand Down
4 changes: 2 additions & 2 deletions kpops/api/options.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from __future__ import annotations

from enum import Enum
from enum import StrEnum
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from kpops.components.base_components.pipeline_component import PipelineComponent
from kpops.pipeline import ComponentFilterPredicate


class FilterType(str, Enum):
class FilterType(StrEnum):
INCLUDE = "include"
EXCLUDE = "exclude"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import logging
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Self

from kpops.component_handlers.kafka_connect.connect_wrapper import ConnectWrapper
from kpops.component_handlers.kafka_connect.exception import (
Expand All @@ -12,11 +12,6 @@
from kpops.utils.dict_differ import render_diff

if TYPE_CHECKING:
try:
from typing import Self # pyright: ignore[reportAttributeAccessIssue]
except ImportError:
from typing_extensions import Self

from kpops.component_handlers.kafka_connect.model import KafkaConnectorConfig
from kpops.config import KpopsConfig

Expand Down
4 changes: 2 additions & 2 deletions kpops/component_handlers/kafka_connect/model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import Enum
from enum import StrEnum
from typing import Any

import pydantic
Expand All @@ -21,7 +21,7 @@
)


class KafkaConnectorType(str, Enum):
class KafkaConnectorType(StrEnum):
SINK = "sink"
SOURCE = "source"

Expand Down
6 changes: 3 additions & 3 deletions kpops/component_handlers/topic/model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import Enum
from enum import StrEnum
from typing import Any

from pydantic import BaseModel, ConfigDict
Expand Down Expand Up @@ -28,7 +28,7 @@ class TopicResponse(BaseModel):
)


class KafkaTopicConfigSource(str, Enum):
class KafkaTopicConfigSource(StrEnum):
DYNAMIC_TOPIC_CONFIG = "DYNAMIC_TOPIC_CONFIG"
DEFAULT_CONFIG = "DEFAULT_CONFIG"
STATIC_BROKER_CONFIG = "STATIC_BROKER_CONFIG"
Expand Down Expand Up @@ -68,7 +68,7 @@ class TopicConfigResponse(BaseModel):
)


class KafkaBrokerConfigSource(str, Enum):
class KafkaBrokerConfigSource(StrEnum):
STATIC_BROKER_CONFIG = "STATIC_BROKER_CONFIG"
DYNAMIC_BROKER_CONFIG = "DYNAMIC_BROKER_CONFIG"
DEFAULT_CONFIG = "DEFAULT_CONFIG"
Expand Down
7 changes: 1 addition & 6 deletions kpops/components/base_components/base_defaults_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dataclasses import asdict
from functools import cached_property
from pathlib import Path
from typing import Any, TypeVar
from typing import Any, Self, TypeVar

import pydantic
import typer
Expand All @@ -34,11 +34,6 @@
from kpops.utils.types import JsonType
from kpops.utils.yaml import load_yaml_file, substitute_nested

try:
from typing import Self # pyright: ignore[reportAttributeAccessIssue]
except ImportError:
from typing_extensions import Self

log = logging.getLogger("BaseDefaultsComponent")


Expand Down
7 changes: 1 addition & 6 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, Literal, NoReturn
from typing import Any, Literal, NoReturn, Self

import pydantic
from pydantic import Field, PrivateAttr, ValidationInfo, computed_field, field_validator
Expand All @@ -27,11 +27,6 @@
from kpops.utils.docstring import describe_attr
from kpops.utils.pydantic import CamelCaseConfigModel

try:
from typing import Self # pyright: ignore[reportAttributeAccessIssue]
except ImportError:
from typing_extensions import Self

log = logging.getLogger("KafkaConnector")


Expand Down
4 changes: 2 additions & 2 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 Enum
from enum import StrEnum
from typing import Any, NewType

from pydantic import ConfigDict, Field, model_validator
Expand All @@ -8,7 +8,7 @@
from kpops.utils.pydantic import DescConfigModel


class InputTopicTypes(str, Enum):
class InputTopicTypes(StrEnum):
"""Input topic types.

- INPUT: input topic
Expand Down
4 changes: 2 additions & 2 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 Enum
from enum import StrEnum
from typing import Annotated, Any

import pydantic
Expand All @@ -11,7 +11,7 @@
from kpops.utils.pydantic import DescConfigModel, to_str


class OutputTopicTypes(str, Enum):
class OutputTopicTypes(StrEnum):
"""Types of output topic.

- OUTPUT: output topic
Expand Down
8 changes: 1 addition & 7 deletions kpops/components/streams_bootstrap/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import re
from abc import ABC
from typing import TYPE_CHECKING
from typing import Self

import pydantic
from pydantic import Field
Expand All @@ -17,12 +17,6 @@
from kpops.manifests.strimzi.kafka_topic import StrimziKafkaTopic
from kpops.utils.docstring import describe_attr

if TYPE_CHECKING:
try:
from typing import Self # pyright: ignore[reportAttributeAccessIssue]
except ImportError:
from typing_extensions import Self

STREAMS_BOOTSTRAP_HELM_REPO = HelmRepoConfig(
repository_name="bakdata-streams-bootstrap",
url="https://bakdata.github.io/streams-bootstrap/",
Expand Down
8 changes: 1 addition & 7 deletions kpops/components/streams_bootstrap_v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import logging
from abc import ABC
from typing import TYPE_CHECKING, Any
from typing import Any, Self

import pydantic
from pydantic import AliasChoices, ConfigDict, Field
Expand All @@ -20,12 +20,6 @@
exclude_defaults,
)

if TYPE_CHECKING:
try:
from typing import Self # pyright: ignore[reportAttributeAccessIssue]
except ImportError:
from typing_extensions import Self

STREAMS_BOOTSTRAP_HELM_REPO = HelmRepoConfig(
repository_name="bakdata-streams-bootstrap",
url="https://bakdata.github.io/streams-bootstrap/",
Expand Down
10 changes: 3 additions & 7 deletions kpops/components/streams_bootstrap_v2/streams/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Any
from typing import Any, Self

import pydantic
from pydantic import BaseModel, ConfigDict, Field, model_validator
Expand Down Expand Up @@ -194,9 +194,7 @@ class StreamsAppAutoScaling(CamelCaseConfigModel, DescConfigModel):
model_config = ConfigDict(extra="allow")

@model_validator(mode="after")
def validate_mandatory_fields_are_set(
self: StreamsAppAutoScaling,
) -> StreamsAppAutoScaling: # TODO: typing.Self for Python 3.11+
def validate_mandatory_fields_are_set(self) -> Self:
if self.enabled and (self.consumer_group is None or self.lag_threshold is None):
msg = (
"If app.autoscaling.enabled is set to true, "
Expand Down Expand Up @@ -228,9 +226,7 @@ class PersistenceConfig(BaseModel):
)

@model_validator(mode="after")
def validate_mandatory_fields_are_set(
self: PersistenceConfig,
) -> PersistenceConfig: # TODO: typing.Self for Python 3.11+
def validate_mandatory_fields_are_set(self) -> Self:
if self.enabled and self.size is None:
msg = (
"If app.persistence.enabled is set to true, "
Expand Down
4 changes: 2 additions & 2 deletions kpops/const/file_type.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import annotations

from enum import Enum
from enum import StrEnum

FILE_EXTENSION = ".yaml"


class KpopsFileType(str, Enum):
class KpopsFileType(StrEnum):
"""Enum representing different types of KPOps file naming conventions.

Attributes:
Expand Down
9 changes: 4 additions & 5 deletions kpops/manifests/kubernetes.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from collections.abc import Iterator
from typing import Any
from typing import Any, Self

import pydantic
import yaml
from pydantic import ConfigDict, Field
from typing_extensions import override
from yaml.loader import Loader

from kpops.utils.pydantic import CamelCaseConfigModel, by_alias

Expand Down Expand Up @@ -56,10 +57,8 @@ class KubernetesManifest(CamelCaseConfigModel):
model_config = ConfigDict(extra="allow")

@classmethod
def from_yaml(
cls, /, content: str
) -> Iterator["KubernetesManifest"]: # TODO: typing.Self for Python 3.11+
manifests: Iterator[dict[str, Any]] = yaml.load_all(content, yaml.Loader)
def from_yaml(cls, /, content: str) -> Iterator[Self]:
manifests: Iterator[dict[str, Any]] = yaml.load_all(content, Loader)
for manifest in manifests:
yield cls(**manifest)

Expand Down
8 changes: 1 addition & 7 deletions kpops/manifests/strimzi/kafka_topic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Any
from typing import Any, Self

from pydantic import ConfigDict, Field, model_validator

Expand All @@ -11,12 +11,6 @@
from kpops.utils.docstring import describe_attr
from kpops.utils.pydantic import CamelCaseConfigModel

if TYPE_CHECKING:
try:
from typing import Self # pyright: ignore[reportAttributeAccessIssue]
except ImportError:
from typing_extensions import Self


class TopicSpec(CamelCaseConfigModel):
"""Specification of a Kafka topic.
Expand Down
Loading