Skip to content

Commit

Permalink
Merge pull request #919 from Aiven-Open/jjaakola-aiven-update-for-pyt…
Browse files Browse the repository at this point in the history
…hon-3.12

chore: update for Python 3.12
  • Loading branch information
nosahama authored Jul 25, 2024
2 parents 8afd513 + 888b171 commit 89d50c8
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/setup-python@v5
with:
cache: pip
python-version: '3.11'
python-version: '3.12'
- name: Install libsnappy-dev
run: sudo apt install libsnappy-dev
# required for pylint
Expand All @@ -42,7 +42,7 @@ jobs:
- uses: actions/setup-python@v5
with:
cache: pip
python-version: '3.11'
python-version: '3.12'
- name: Install libsnappy-dev
run: sudo apt install libsnappy-dev
- run: pip install -r requirements/requirements.txt -r requirements/requirements-typing.txt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"
cache: pip
cache-dependency-path:
requirements.txt
Expand Down
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' ]
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
env:
PYTEST_ADDOPTS: >-
--log-dir=/tmp/ci-logs
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
entry: ./copyright.sh

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.2
rev: v0.10.0.1
hooks:
- id: shellcheck

Expand Down Expand Up @@ -56,7 +56,7 @@ repos:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.1.0
hooks:
- id: flake8

Expand All @@ -73,6 +73,6 @@ repos:
- repo: https://github.com/PyCQA/pylint
# Note: pre-commit autoupdate changes to an alpha version. Instead, manually find the
# latest stable version here: https://github.com/pylint-dev/pylint/releases
rev: v2.17.4
rev: v3.2.6
hooks:
- id: pylint
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ disable=
duplicate-code,
fixme,
import-outside-toplevel,
invalid-field-call,
invalid-name,
missing-docstring,
too-few-public-methods,
Expand Down
3 changes: 2 additions & 1 deletion karapace/backup/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +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 concurrent.futures import Future
from confluent_kafka import Message, TopicPartition
from enum import Enum
Expand All @@ -41,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, Sized, TypeVar
from typing import Callable, Iterator, Literal, Mapping, NewType, TypeVar

import contextlib
import datetime
Expand Down
5 changes: 4 additions & 1 deletion karapace/backup/backends/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def safe_writer(
) -> Generator[IO[str], None, None]:
with super().safe_writer(target, allow_overwrite) as buffer:
buffer.write(V2_MARKER.decode())
yield buffer
try:
yield buffer
finally:
pass


class SchemaBackupV2Writer(_BaseV2Writer):
Expand Down
9 changes: 6 additions & 3 deletions karapace/backup/safe_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ def str_writer(
safe_context = _safe_temporary_descriptor(target.absolute(), allow_overwrite)

with safe_context as fd, open(fd, "w") as buffer:
yield buffer
buffer.flush()
os.fsync(fd)
try:
yield buffer
buffer.flush()
os.fsync(fd)
finally:
pass


def _check_destination_directory(destination: Path) -> None:
Expand Down
2 changes: 1 addition & 1 deletion karapace/protobuf/known_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def static_init(cls: Any) -> object:
return cls


@static_init
@static_init # pylint: disable=used-before-assignment
class KnownDependency:
index: Dict = dict()
index_simple: Dict = dict()
Expand Down
2 changes: 1 addition & 1 deletion karapace/protobuf/message_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def to_schema(self) -> str:
return "".join(result)

def compare(self, other: TypeElement, result: CompareResult, types: CompareTypes) -> None:
from karapace.protobuf.compare_type_lists import compare_type_lists
from karapace.protobuf.compare_type_lists import compare_type_lists # pylint: disable=cyclic-import

if not isinstance(other, MessageElement):
result.add_modification(Modification.TYPE_ALTER)
Expand Down
2 changes: 1 addition & 1 deletion karapace/protobuf/proto_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def static_init(cls) -> object:
return cls


@static_init
@static_init # pylint: disable=used-before-assignment
class ProtoType:
@property
def simple_name(self) -> str:
Expand Down
3 changes: 1 addition & 2 deletions karapace/protobuf/syntax_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def read_quoted_string(self) -> str:
self.newline()

self.unexpected("unterminated string")
return ""

def read_numeric_escape(self, radix: int, length: int) -> str:
value = -1
Expand Down Expand Up @@ -180,7 +179,7 @@ def read_word(self) -> str:
self.expect(start < self.pos, "expected a word")
return self.data[start : self.pos]

def read_int(self) -> int: # pylint: disable=inconsistent-return-statements
def read_int(self) -> int:
"""Reads an integer and returns it."""
tag: str = self.read_word()
try:
Expand Down
2 changes: 2 additions & 0 deletions karapace/schema_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ async def subject_delete_local(self, subject: Subject, permanent: bool) -> list[
version_list = list(schema_versions_live)
if version_list:
latest_version_id = version_list[-1]
else:
return []

referenced_by = self.schema_reader.get_referenced_by(subject, latest_version_id)
if referenced_by and len(referenced_by) > 0:
Expand Down
2 changes: 1 addition & 1 deletion karapace/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def convert_to_int(object_: dict, key: str, content_type: str) -> None:
try:
object_[key] = int(object_[key])
except ValueError:
from karapace.rapu import http_error
from karapace.rapu import http_error # pylint: disable=cyclic-import

http_error(
message=f"{key} is not a valid int: {object_[key]}",
Expand Down

0 comments on commit 89d50c8

Please sign in to comment.