Skip to content

Commit f474bf4

Browse files
committed
reproduce
1 parent cf07b83 commit f474bf4

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/py_avro_schema/_testing.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"""
1414
Test functions
1515
"""
16+
from __future__ import annotations
17+
1618
import dataclasses
1719
import difflib
1820
from typing import Dict, Type, Union
@@ -57,3 +59,10 @@ class PyType:
5759
"""For testing"""
5860

5961
field_a: str
62+
63+
Name = str
64+
65+
class PyClass:
66+
"""For testing"""
67+
68+
name: Name

tests/test_plain_class.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from py_avro_schema._alias import Alias, Opaque, register_type_aliases
1919
from py_avro_schema._testing import assert_schema
2020

21-
2221
def test_plain_class_with_type_hints():
2322
@register_type_aliases(aliases=["test_plain_class.OldPyType"])
2423
class PyType:
@@ -143,3 +142,20 @@ class PyType:
143142

144143
expected = {"fields": [{"name": "details", "type": "string"}], "name": "PyType", "type": "record"}
145144
assert_schema(PyType, expected)
145+
146+
147+
def test_type_aliases():
148+
Name = str
149+
150+
class PyClass:
151+
name: Name
152+
153+
expected = {"fields": [{"name": "name", "type": "string"}], "name": "PyClass", "type": "record"}
154+
assert_schema(PyClass, expected)
155+
156+
157+
def test_type_aliases_future():
158+
from py_avro_schema._testing import PyClass
159+
160+
expected = {"fields": [{"name": "name", "type": "string"}], "name": "PyType", "type": "record"}
161+
assert_schema(PyClass, expected)

0 commit comments

Comments
 (0)