localstack-py-avro-schema 3.9.7__tar.gz → 3.9.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/PKG-INFO +1 -1
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/localstack_py_avro_schema.egg-info/PKG-INFO +1 -1
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/localstack_py_avro_schema.egg-info/SOURCES.txt +3 -1
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/py_avro_schema/_schemas.py +32 -1
- localstack_py_avro_schema-3.9.8/tests/models/__init__.py +0 -0
- localstack_py_avro_schema-3.9.8/tests/models/forward.py +9 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/tests/test_plain_class.py +37 -1
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/.editorconfig +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/.flake8 +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/.github/workflows/release-package.yml +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/.github/workflows/test-package.yml +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/.gitignore +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/.pre-commit-config.yaml +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/.readthedocs.yaml +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/LICENSE +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/LICENSE_HEADER.txt +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/README.md +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/docs/conf.py +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/docs/index.rst +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/docs/modules.rst +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/docs/py_avro_schema.rst +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/docs/tutorial.rst +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/docs/types.rst +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/pyproject.toml +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/setup.cfg +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/localstack_py_avro_schema.egg-info/dependency_links.txt +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/localstack_py_avro_schema.egg-info/requires.txt +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/localstack_py_avro_schema.egg-info/top_level.txt +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/py_avro_schema/__init__.py +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/py_avro_schema/_alias.py +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/py_avro_schema/_testing.py +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/py_avro_schema/_typing.py +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/py_avro_schema/py.typed +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/tests/test_avro_schema.py +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/tests/test_dataclass.py +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/tests/test_logicals.py +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/tests/test_primitives.py +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/tests/test_pydantic.py +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/tests/test_typed_dict.py +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/tests/test_typing.py +0 -0
- {localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: localstack-py-avro-schema
|
|
3
|
-
Version: 3.9.
|
|
3
|
+
Version: 3.9.8
|
|
4
4
|
Summary: Generate Apache Avro schemas for Python types including standard library data-classes and Pydantic data models.
|
|
5
5
|
Author-email: LocalStack Contributors <info@localstack.cloud>, "J.P. Morgan Chase & Co." <open_source@jpmorgan.com>
|
|
6
6
|
License: Apache License
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: localstack-py-avro-schema
|
|
3
|
-
Version: 3.9.
|
|
3
|
+
Version: 3.9.8
|
|
4
4
|
Summary: Generate Apache Avro schemas for Python types including standard library data-classes and Pydantic data models.
|
|
5
5
|
Author-email: LocalStack Contributors <info@localstack.cloud>, "J.P. Morgan Chase & Co." <open_source@jpmorgan.com>
|
|
6
6
|
License: Apache License
|
{localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/py_avro_schema/_schemas.py
RENAMED
|
@@ -33,6 +33,7 @@ from typing import (
|
|
|
33
33
|
Annotated,
|
|
34
34
|
Any,
|
|
35
35
|
Dict,
|
|
36
|
+
Final,
|
|
36
37
|
ForwardRef,
|
|
37
38
|
List,
|
|
38
39
|
Literal,
|
|
@@ -378,6 +379,31 @@ class LiteralSchema(Schema):
|
|
|
378
379
|
return self.literal_value_schema.data(names=names)
|
|
379
380
|
|
|
380
381
|
|
|
382
|
+
@register_schema
|
|
383
|
+
class FinalSchema(Schema):
|
|
384
|
+
"""An Avro schema for Python ``typing.Final``"""
|
|
385
|
+
|
|
386
|
+
def __init__(self, py_type: Type, namespace: Optional[str] = None, options: Option = Option(0)):
|
|
387
|
+
"""An Avro schema for Python ``typing.Final``"""
|
|
388
|
+
super().__init__(py_type, namespace, options)
|
|
389
|
+
py_type = _type_from_annotated(py_type)
|
|
390
|
+
try:
|
|
391
|
+
real_type = get_args(py_type)[0]
|
|
392
|
+
except IndexError:
|
|
393
|
+
raise TypeError("Can't generate Avro schema from Python typing.Final without a type parameter")
|
|
394
|
+
self.real_schema = _schema_obj(real_type, namespace=namespace, options=options)
|
|
395
|
+
|
|
396
|
+
def data(self, names: NamesType) -> JSONType:
|
|
397
|
+
"""Return the schema data"""
|
|
398
|
+
return self.real_schema.data(names=names)
|
|
399
|
+
|
|
400
|
+
@classmethod
|
|
401
|
+
def handles_type(cls, py_type: Type) -> bool:
|
|
402
|
+
"""Whether this schema class can represent a given Python class"""
|
|
403
|
+
py_type = _type_from_annotated(py_type)
|
|
404
|
+
return get_origin(py_type) is Final or py_type is Final
|
|
405
|
+
|
|
406
|
+
|
|
381
407
|
@register_schema
|
|
382
408
|
class DictAsJSONSchema(Schema):
|
|
383
409
|
"""An Avro string schema representing a Python Dict[str, Any] or List[Dict[str, Any]] assuming JSON serialization"""
|
|
@@ -1156,8 +1182,13 @@ class PlainClassSchema(RecordSchema):
|
|
|
1156
1182
|
super().__init__(py_type, namespace=namespace, options=options)
|
|
1157
1183
|
py_type = _type_from_annotated(py_type)
|
|
1158
1184
|
|
|
1185
|
+
# Try to get resolved type hints, but fall back to raw annotations if there are unresolved forward refs
|
|
1186
|
+
try:
|
|
1187
|
+
type_hints = get_type_hints(py_type, include_extras=True)
|
|
1188
|
+
except NameError:
|
|
1189
|
+
type_hints = py_type.__annotations__
|
|
1159
1190
|
self.py_fields: list[tuple[str, type]] = []
|
|
1160
|
-
for k, v in
|
|
1191
|
+
for k, v in type_hints.items():
|
|
1161
1192
|
self.py_fields.append((k, v))
|
|
1162
1193
|
# We store __init__ parameters with default values. They can be used as defaults for the record.
|
|
1163
1194
|
self.signature_fields = {
|
|
File without changes
|
{localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/tests/test_plain_class.py
RENAMED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
# specific language governing permissions and limitations under the License.
|
|
11
11
|
|
|
12
12
|
import re
|
|
13
|
-
from typing import Annotated
|
|
13
|
+
from typing import Annotated, Final
|
|
14
14
|
|
|
15
15
|
import pytest
|
|
16
16
|
|
|
@@ -143,3 +143,39 @@ def test_opaque_field():
|
|
|
143
143
|
|
|
144
144
|
expected = {"fields": [{"name": "details", "type": "string"}], "name": "PyType", "type": "record"}
|
|
145
145
|
assert_schema(PyType, expected)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def test_type_aliases():
|
|
149
|
+
Name = str
|
|
150
|
+
|
|
151
|
+
class PyClass:
|
|
152
|
+
name: Name
|
|
153
|
+
|
|
154
|
+
expected = {"fields": [{"name": "name", "type": "string"}], "name": "PyClass", "type": "record"}
|
|
155
|
+
assert_schema(PyClass, expected)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def test_type_aliases_future():
|
|
159
|
+
from tests.models.forward import PyClass
|
|
160
|
+
|
|
161
|
+
expected = {"fields": [{"name": "name", "type": "string"}], "name": "PyClass", "type": "record"}
|
|
162
|
+
assert_schema(PyClass, expected)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def test_typing_final():
|
|
166
|
+
|
|
167
|
+
class PyType:
|
|
168
|
+
var: Final[str]
|
|
169
|
+
field: Final[dict[str, int]]
|
|
170
|
+
|
|
171
|
+
def __init__(self):
|
|
172
|
+
self.var = "Hello World"
|
|
173
|
+
self.field = {"John": 123}
|
|
174
|
+
|
|
175
|
+
expected = {
|
|
176
|
+
"fields": [{"name": "var", "type": "string"}, {"name": "field", "type": {"type": "map", "values": "long"}}],
|
|
177
|
+
"name": "PyType",
|
|
178
|
+
"type": "record",
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
assert_schema(PyType, expected)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/py_avro_schema/__init__.py
RENAMED
|
File without changes
|
{localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/py_avro_schema/_alias.py
RENAMED
|
File without changes
|
{localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/py_avro_schema/_testing.py
RENAMED
|
File without changes
|
{localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/py_avro_schema/_typing.py
RENAMED
|
File without changes
|
{localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/src/py_avro_schema/py.typed
RENAMED
|
File without changes
|
{localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/tests/test_avro_schema.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/tests/test_primitives.py
RENAMED
|
File without changes
|
|
File without changes
|
{localstack_py_avro_schema-3.9.7 → localstack_py_avro_schema-3.9.8}/tests/test_typed_dict.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|