Skip to content

Commit

Permalink
⬆️ Prepare for Python 3.14
Browse files Browse the repository at this point in the history
Fixes #177
  • Loading branch information
eigenein committed Oct 14, 2024
1 parent bf21a9b commit 5883159
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- '3.11'
- '3.12'
- '3.13'
- '3.14-dev'

steps:
- name: "🗃 Cache"
Expand Down
11 changes: 8 additions & 3 deletions pure_protobuf/descriptors/record.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

from collections.abc import ByteString, Mapping
from dataclasses import dataclass
from enum import IntEnum
from types import GenericAlias
Expand Down Expand Up @@ -71,7 +70,7 @@ class RecordDescriptor(Generic[RecordT]):
merge: Merge[RecordT] = MergeLastOneWins()
"""Merge two values of the same field from different messages. Only called in a message merger."""

__PREDEFINED__: ClassVar[Mapping[Any, RecordDescriptor]]
__PREDEFINED__: ClassVar[dict[Any, RecordDescriptor]]
"""Pre-defined descriptors for primitive types."""

@classmethod
Expand Down Expand Up @@ -176,7 +175,6 @@ def _from_inner_type_hint(
bool: BOOL_DESCRIPTOR,
bytes: BYTES_DESCRIPTOR,
bytearray: BYTES_DESCRIPTOR,
ByteString: BYTES_DESCRIPTOR,
fixed32: UNSIGNED_INT32_DESCRIPTOR,
fixed64: UNSIGNED_INT64_DESCRIPTOR,
float: FLOAT_DESCRIPTOR,
Expand Down Expand Up @@ -206,3 +204,10 @@ def _from_inner_type_hint(
read=ReadMaybePacked[int](ReadCallback(ReadZigZagVarint()), WireType.VARINT),
),
}

try:
from collections.abc import ByteString
except ImportError:
pass
else:
RecordDescriptor.__PREDEFINED__[ByteString] = BYTES_DESCRIPTOR
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ exclude_lines = [

[tool.black]
line-length = 120
target-version = ["py39", "py310", "py311", "py312", "py313"]
target-version = ["py39", "py310", "py311", "py312", "py313", "py314"]

[tool.ruff]
line-length = 120
Expand Down Expand Up @@ -148,9 +148,7 @@ ignore = [
"PT013",
"RET505",
"TRY003",
"UP006", # 3.9
"UP007", # 3.10
"UP033", # 3.9
]

[tool.ruff.lint.per-file-ignores]
Expand Down

0 comments on commit 5883159

Please sign in to comment.