Skip to content

Commit

Permalink
Add support for python 3.10 and 3.11 (#16)
Browse files Browse the repository at this point in the history
* Add support for python 3.10 and 3.11
* move kafka tests, update their README
  • Loading branch information
marktengi authored Sep 22, 2023
1 parent 82e158c commit 9b7f686
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, macos-latest]
python-version: [3.7, 3.8, 3.9]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
3.11.4
3.10.12
3.9.7
3.8.12
3.7.12
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = aws-glue-schema-registry
version = 1.1.2
version = 1.1.3
description = Use the AWS Glue Schema Registry.
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down Expand Up @@ -34,7 +34,8 @@ install_requires =
boto3>=1.17.102
typing-extensions>=3.7.4.3;python_version<"3.8"
fastavro>=1.4.5
orjson~=3.6.0
orjson~=3.6.0;python_version<"3.11"
orjson>=3.7.7;python_version>="3.11"
fastjsonschema~=2.15
setup_requires =
setuptools
Expand Down
2 changes: 1 addition & 1 deletion src/aws_schema_registry/adapter/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
https://pypi.org/project/kafka-python/
"""

from kafka import Serializer, Deserializer
from kafka.serializer import Serializer, Deserializer

from aws_schema_registry import (
KafkaSerializer as _KafkaSerializer,
Expand Down
8 changes: 4 additions & 4 deletions src/aws_schema_registry/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import time
import random
import string
from typing import ContextManager, Mapping
from typing import ContextManager, Mapping, Optional
from uuid import UUID

from aws_schema_registry.schema import (
Expand Down Expand Up @@ -138,7 +138,7 @@ def get_or_register_schema_version(
schema_name: str,
data_format: DataFormat,
compatibility_mode: CompatibilityMode = DEFAULT_COMPATIBILITY_MODE,
metadata: Mapping[str, str] = None
metadata: Optional[Mapping[str, str]] = None
) -> SchemaVersion:
"""Get Schema Version ID by following below steps:
Expand Down Expand Up @@ -193,7 +193,7 @@ def register_schema_version(
self,
definition: str,
schema_name: str,
metadata: Mapping[str, str] = None
metadata: Optional[Mapping[str, str]] = None
) -> UUID:
"""Register a new version to an existing schema.
Expand Down Expand Up @@ -281,7 +281,7 @@ def create_schema(
data_format: DataFormat,
definition: str,
compatibility_mode: CompatibilityMode = DEFAULT_COMPATIBILITY_MODE,
metadata: Mapping[str, str] = None
metadata: Optional[Mapping[str, str]] = None
) -> UUID:
"""Create a new schema and return the version id."""
try:
Expand Down
7 changes: 0 additions & 7 deletions tests/integration/kafka/README.md

This file was deleted.

7 changes: 7 additions & 0 deletions tests/integration/kafka_test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Kafka integration tests

Tests that the serializer and deserializer works correctly with a real Kafka cluster.

Requires [Docker](https://www.docker.com/). Tested with Docker v20.

Run `docker compose -f tests/integration/kafka_test/docker-compose.yml up -d` before running these tests. Destroy the docker stack with `docker compose -f tests/integration/kafka_test/docker-compose.yml down`.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 6 additions & 3 deletions tests/test_jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ def test_validation():
]
}""")

with pytest.raises(ValidationError, match=re.escape(
"data must contain ['name', 'age'] properties"
)):
with pytest.raises(
ValidationError,
# fastjsonschema>=2.18.0 reports only missing properties, so it will
# exclude 'name'
match=r"data must contain \[('name', )?'age'\] properties"
):
s.validate({'name': 'Obi-Wan'})
with pytest.raises(ValidationError, match=re.escape(
"data.name must be string"
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[tox]
envlist = flake8,mypy,py37,py38,py39
envlist = flake8,mypy,py37,py38,py39,py310,py311

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311

[testenv]
deps = pytest
Expand Down

0 comments on commit 9b7f686

Please sign in to comment.