Skip to content

Commit

Permalink
Merge pull request #972 from Aiven-Open/jjaakola-aiven-remove-python-3.8
Browse files Browse the repository at this point in the history
Remove python 3.8 support
  • Loading branch information
jlprat authored Oct 8, 2024
2 parents a4030fe + 646fb93 commit 18b46fd
Show file tree
Hide file tree
Showing 96 changed files with 232 additions and 281 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
python-version: [ '3.9', '3.10', '3.11', '3.12' ]
env:
PYTEST_ADDOPTS: >-
--log-dir=/tmp/ci-logs
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repos:
rev: v3.4.0
hooks:
- id: pyupgrade
args: [ --py38-plus ]
args: [ --py39-plus ]

- repo: https://github.com/pycqa/autoflake
rev: v2.1.1
Expand Down
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SHELL := /usr/bin/env bash
VENV_DIR ?= $(CURDIR)/venv
PIP ?= pip3 --disable-pip-version-check --no-input --require-virtualenv
PYTHON ?= python3
PYTHON_VERSION ?= 3.8
PYTHON_VERSION ?= 3.9

define PIN_VERSIONS_COMMAND
pip install pip-tools && \
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[mypy]
mypy_path = $MYPY_CONFIG_FILE_DIR/stubs
python_version = 3.8
python_version = 3.9
packages = karapace
show_error_codes = True
pretty = True
Expand Down
3 changes: 1 addition & 2 deletions performance-test/schema-registry-schema-post.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from dataclasses import dataclass, field
from locust import FastHttpUser, task
from locust.contrib.fasthttp import ResponseContextManager
from typing import Dict

import json
import random
Expand All @@ -17,7 +16,7 @@
@dataclass
class TestData:
count: int = 0
schemas: Dict[uuid.UUID, SchemaId] = field(default_factory=dict)
schemas: dict[uuid.UUID, SchemaId] = field(default_factory=dict)


SUBJECTS = ["test-subject-1", "test-subject-2"]
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "karapace"
requires-python = ">= 3.8"
requires-python = ">= 3.9"
dynamic = ["version"]
readme = "README.rst"
license = {file = "LICENSE"}
Expand Down Expand Up @@ -49,7 +49,6 @@ classifiers=[
"Intended Audience :: Information Technology",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down Expand Up @@ -107,5 +106,5 @@ include-package-data = true
version_file = "src/karapace/version.py"

[tool.black]
target-version = ["py38"]
target-version = ["py39"]
line-length = 125
13 changes: 2 additions & 11 deletions requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# make pin-requirements
Expand Down Expand Up @@ -93,10 +93,6 @@ idna==3.8
# yarl
importlib-metadata==8.4.0
# via flask
importlib-resources==6.4.4
# via
# jsonschema
# jsonschema-specifications
iniconfig==2.0.0
# via pytest
isodate==0.6.1
Expand Down Expand Up @@ -135,8 +131,6 @@ packaging==24.1
# pytest
pdbpp==0.10.3
# via karapace (/karapace/pyproject.toml)
pkgutil-resolve-name==1.3.10
# via jsonschema
pluggy==1.5.0
# via pytest
prometheus-client==0.20.0
Expand Down Expand Up @@ -215,7 +209,6 @@ typing-extensions==4.12.2
# via
# anyio
# karapace (/karapace/pyproject.toml)
# rich
ujson==5.10.0
# via karapace (/karapace/pyproject.toml)
urllib3==2.2.2
Expand All @@ -238,9 +231,7 @@ yarl==1.12.1
# aiohttp
# karapace (/karapace/pyproject.toml)
zipp==3.20.1
# via
# importlib-metadata
# importlib-resources
# via importlib-metadata
zope-event==5.0
# via gevent
zope-interface==7.0.2
Expand Down
11 changes: 1 addition & 10 deletions requirements/requirements-typing.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# make pin-requirements
Expand Down Expand Up @@ -45,10 +45,6 @@ idna==3.10
# via
# anyio
# yarl
importlib-resources==6.4.5
# via
# jsonschema
# jsonschema-specifications
isodate==0.6.1
# via karapace (/karapace/pyproject.toml)
jsonschema==4.23.0
Expand All @@ -73,8 +69,6 @@ networkx==3.1
# via karapace (/karapace/pyproject.toml)
packaging==24.1
# via aiokafka
pkgutil-resolve-name==1.3.10
# via jsonschema
prometheus-client==0.20.0
# via karapace (/karapace/pyproject.toml)
protobuf==3.20.3
Expand Down Expand Up @@ -122,7 +116,6 @@ typing-extensions==4.12.2
# karapace (/karapace/pyproject.toml)
# multidict
# mypy
# rich
ujson==5.10.0
# via karapace (/karapace/pyproject.toml)
urllib3==2.2.2
Expand All @@ -135,7 +128,5 @@ yarl==1.12.1
# via
# aiohttp
# karapace (/karapace/pyproject.toml)
zipp==3.20.2
# via importlib-resources
zstandard==0.23.0
# via karapace (/karapace/pyproject.toml)
11 changes: 1 addition & 10 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# make pin-requirements
Expand Down Expand Up @@ -43,10 +43,6 @@ idna==3.8
# via
# anyio
# yarl
importlib-resources==6.4.4
# via
# jsonschema
# jsonschema-specifications
isodate==0.6.1
# via karapace (/karapace/pyproject.toml)
jsonschema==4.23.0
Expand All @@ -67,8 +63,6 @@ networkx==3.1
# via karapace (/karapace/pyproject.toml)
packaging==24.1
# via aiokafka
pkgutil-resolve-name==1.3.10
# via jsonschema
prometheus-client==0.20.0
# via karapace (/karapace/pyproject.toml)
protobuf==3.20.3
Expand Down Expand Up @@ -103,7 +97,6 @@ typing-extensions==4.12.2
# via
# anyio
# karapace (/karapace/pyproject.toml)
# rich
ujson==5.10.0
# via karapace (/karapace/pyproject.toml)
watchfiles==0.23.0
Expand All @@ -114,7 +107,5 @@ yarl==1.12.1
# via
# aiohttp
# karapace (/karapace/pyproject.toml)
zipp==3.20.1
# via importlib-resources
zstandard==0.23.0
# via karapace (/karapace/pyproject.toml)
2 changes: 1 addition & 1 deletion runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.8.16
python-3.9.20
10 changes: 5 additions & 5 deletions src/karapace/anonymize_schemas/anonymize_avro.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Copyright (c) 2023 Aiven Ltd
See LICENSE for details
"""
from typing import Any, Dict, List, Union
from typing import Any, Union
from typing_extensions import TypeAlias

import hashlib
Expand Down Expand Up @@ -95,7 +95,7 @@ def anonymize_element(m: re.Match) -> str:
return NAME_ANONYMIZABLE_PATTERN.sub(anonymize_element, name)


Schema: TypeAlias = Union[str, Dict[str, Any], List[Any]]
Schema: TypeAlias = Union[str, dict[str, Any], list[Any]]


def anonymize(input_schema: Schema) -> Schema:
Expand All @@ -105,10 +105,10 @@ def anonymize(input_schema: Schema) -> Schema:
if input_schema in ALL_TYPES:
return input_schema
return anonymize_name(input_schema)
elif isinstance(input_schema, List):
elif isinstance(input_schema, list):
return [anonymize(value) for value in input_schema]
elif isinstance(input_schema, Dict):
output_schema: Dict[str, Any] = {}
elif isinstance(input_schema, dict):
output_schema: dict[str, Any] = {}
for key, value in input_schema.items():
if key in KEYWORDS:
output_schema[key] = anonymize(value)
Expand Down
8 changes: 2 additions & 6 deletions src/karapace/avro_dataclasses/introspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@
from __future__ import annotations

from .schema import AvroType, EnumType, FieldSchema, MapType, RecordSchema
from collections.abc import Mapping
from collections.abc import Mapping, Sequence
from dataclasses import Field, fields, is_dataclass, MISSING
from enum import Enum
from functools import lru_cache
from typing import Final, Sequence, TYPE_CHECKING, TypeVar, Union

# Note: It's important get_args and get_origin are imported from typing_extensions
# until support for Python 3.8 is dropped.
from typing_extensions import get_args, get_origin
from typing import Final, get_args, get_origin, TYPE_CHECKING, TypeVar, Union

import datetime
import uuid
Expand Down
3 changes: 2 additions & 1 deletion src/karapace/avro_dataclasses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
from __future__ import annotations

from .introspect import record_schema
from collections.abc import Iterable, Mapping
from dataclasses import asdict, fields, is_dataclass
from enum import Enum
from functools import lru_cache, partial
from typing import Callable, cast, IO, Iterable, Mapping, TYPE_CHECKING, TypeVar, Union
from typing import Callable, cast, IO, TYPE_CHECKING, TypeVar, Union
from typing_extensions import get_args, get_origin, Self

import avro
Expand Down
4 changes: 2 additions & 2 deletions src/karapace/backup/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from .poll_timeout import PollTimeout
from .topic_configurations import ConfigSource, get_topic_configurations
from aiokafka.errors import KafkaError, TopicAlreadyExistsError
from collections.abc import Sized
from collections.abc import Iterator, Mapping, Sized
from concurrent.futures import Future
from confluent_kafka import Message, TopicPartition
from enum import Enum
Expand All @@ -42,7 +42,7 @@
from pathlib import Path
from rich.console import Console
from tenacity import retry, retry_if_exception_type, RetryCallState, stop_after_delay, wait_fixed
from typing import Callable, Iterator, Literal, Mapping, NewType, TypeVar
from typing import Callable, Literal, NewType, TypeVar

import contextlib
import datetime
Expand Down
3 changes: 2 additions & 1 deletion src/karapace/backup/backends/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
"""
from __future__ import annotations

from collections.abc import Generator, Iterator, Mapping, Sequence
from karapace.dataclasses import default_dataclass
from karapace.typing import JsonData, JsonObject
from pathlib import Path
from typing import Callable, ClassVar, Final, Generator, IO, Iterator, Mapping, Optional, Sequence, TypeVar, Union
from typing import Callable, ClassVar, Final, IO, Optional, TypeVar, Union
from typing_extensions import TypeAlias

import abc
Expand Down
5 changes: 3 additions & 2 deletions src/karapace/backup/backends/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
"""
from __future__ import annotations

from collections.abc import Generator
from karapace.backup.backends.reader import BaseItemsBackupReader
from karapace.utils import json_decode
from typing import Generator, IO, List
from typing import IO


class SchemaBackupV1Reader(BaseItemsBackupReader):
@staticmethod
def items_from_file(fp: IO[str]) -> Generator[list[str], None, None]:
raw_msg = fp.read()
values = json_decode(raw_msg, List[List[str]])
values = json_decode(raw_msg, list[list[str]])
if not values:
return
yield from values
7 changes: 4 additions & 3 deletions src/karapace/backup/backends/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"""
from __future__ import annotations

from collections.abc import Generator, Sequence
from karapace.anonymize_schemas import anonymize_avro
from karapace.backup.backends.reader import BaseItemsBackupReader
from karapace.backup.backends.writer import BaseKVBackupWriter, StdOut
from karapace.utils import json_decode, json_encode
from pathlib import Path
from typing import Any, ClassVar, Dict, Final, Generator, IO, Sequence
from typing import Any, ClassVar, Final, IO

import base64
import contextlib
Expand Down Expand Up @@ -61,8 +62,8 @@ def serialize_record(
# Check that the message has key `schema` and type is Avro schema.
# The Avro schemas may have `schemaType` key, if not present the schema is Avro.

key = json_decode(key_bytes, Dict[str, str])
value = json_decode(value_bytes, Dict[str, str])
key = json_decode(key_bytes, dict[str, str])
value = json_decode(value_bytes, dict[str, str])

if value and "schema" in value and value.get("schemaType", "AVRO") == "AVRO":
original_schema: Any = json_decode(value["schema"])
Expand Down
3 changes: 2 additions & 1 deletion src/karapace/backup/backends/v3/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .readers import read_metadata, read_records
from .schema import ChecksumAlgorithm, DataFile, Header, Metadata, Record
from .writers import write_metadata, write_record
from collections.abc import Generator, Iterator, Mapping, Sequence
from confluent_kafka import Message
from dataclasses import dataclass
from karapace.backup.backends.reader import BaseBackupReader, Instruction, ProducerSend, RestoreTopic
Expand All @@ -18,7 +19,7 @@
from karapace.utils import assert_never
from karapace.version import __version__
from pathlib import Path
from typing import Callable, ContextManager, Final, Generator, IO, Iterator, Mapping, Sequence, TypeVar
from typing import Callable, ContextManager, Final, IO, TypeVar
from typing_extensions import TypeAlias

import datetime
Expand Down
3 changes: 2 additions & 1 deletion src/karapace/backup/backends/v3/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
from .constants import V3_MARKER
from .errors import InvalidChecksum, InvalidHeader, TooFewRecords, TooManyRecords, UnexpectedEndOfData
from .schema import Metadata, Record
from collections.abc import Generator
from karapace.avro_dataclasses.models import AvroModel
from typing import Generator, IO, TypeVar
from typing import IO, TypeVar

import io
import struct
Expand Down
Loading

0 comments on commit 18b46fd

Please sign in to comment.