Skip to content

Commit

Permalink
feat: define proper types for SchemaMetadata & SchemaRuleSet to facil…
Browse files Browse the repository at this point in the history
…itate future impl
  • Loading branch information
amstee committed Aug 2, 2024
1 parent c85f4aa commit 9c0f0ba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion karapace/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from enum import Enum, unique
from karapace.errors import InvalidVersion
from typing import ClassVar, Dict, List, Mapping, NewType, Sequence, Union
from typing import Any, ClassVar, Dict, List, Mapping, NewType, Sequence, Union
from typing_extensions import TypeAlias

import functools
Expand All @@ -23,6 +23,8 @@

Subject = NewType("Subject", str)
VersionTag = Union[str, int]
SchemaMetadata = NewType("SchemaMetadata", Dict[str, Any])
SchemaRuleSet = NewType("SchemaRuleSet", Dict[str, Any])

# note: the SchemaID is a unique id among all the schemas (and each version should be assigned to a different id)
# basically the same SchemaID refer always to the same TypedSchema.
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/schema_registry/test_jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from karapace.client import Client
from karapace.compatibility import CompatibilityModes
from karapace.schema_reader import SchemaType
from karapace.typing import SchemaMetadata, SchemaRuleSet
from tests.schemas.json_schemas import (
A_DINT_B_DINT_OBJECT_SCHEMA,
A_DINT_B_INT_OBJECT_SCHEMA,
Expand Down Expand Up @@ -97,7 +98,6 @@
TYPES_STRING_SCHEMA,
)
from tests.utils import new_random_name
from typing import Any, Dict

import json
import pytest
Expand Down Expand Up @@ -241,8 +241,8 @@ async def test_same_jsonschema_must_have_same_id(
registry_async_client: Client,
compatibility: CompatibilityModes,
trail: str,
metadata: Dict[str, Any],
rule_set: Dict[str, Any],
metadata: SchemaMetadata,
rule_set: SchemaRuleSet,
) -> None:
for schema in ALL_SCHEMAS:
subject = new_random_name("subject")
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_schema_protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from karapace.errors import InvalidTest
from karapace.protobuf.kotlin_wrapper import trim_margin
from karapace.schema_type import SchemaType
from karapace.typing import JsonData
from karapace.typing import JsonData, SchemaMetadata, SchemaRuleSet
from tests.base_testcase import BaseTestCase
from tests.utils import create_subject_name_factory
from typing import Any, Dict, List, Optional, Union
from typing import List, Optional, Union

import logging
import pytest
Expand Down Expand Up @@ -966,7 +966,7 @@ class ReferenceTestCase(BaseTestCase):
@pytest.mark.parametrize("metadata", [None, {}])
@pytest.mark.parametrize("rule_set", [None, {}])
async def test_references(
testcase: ReferenceTestCase, registry_async_client: Client, metadata: Dict[str, Any], rule_set: Dict[str, Any]
testcase: ReferenceTestCase, registry_async_client: Client, metadata: SchemaMetadata, rule_set: SchemaRuleSet
):
for testdata in testcase.schemas:
if isinstance(testdata, TestCaseSchema):
Expand Down

0 comments on commit 9c0f0ba

Please sign in to comment.