Skip to content

Commit 7b77bef

Browse files
committed
fix plain classes using __future__ annotations
1 parent a83d2f5 commit 7b77bef

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

src/py_avro_schema/_testing.py

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

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

tests/models/__init__.py

Whitespace-only changes.

tests/models/forward.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from __future__ import annotations
2+
3+
Name = str
4+
5+
6+
class PyClass:
7+
"""For testing imports with future annotations"""
8+
9+
name: Name

tests/test_plain_class.py

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

21+
2122
def test_plain_class_with_type_hints():
2223
@register_type_aliases(aliases=["test_plain_class.OldPyType"])
2324
class PyType:
@@ -155,7 +156,7 @@ class PyClass:
155156

156157

157158
def test_type_aliases_future():
158-
from py_avro_schema._testing import PyClass
159+
from tests.models.forward import PyClass
159160

160161
expected = {"fields": [{"name": "name", "type": "string"}], "name": "PyClass", "type": "record"}
161162
assert_schema(PyClass, expected)

0 commit comments

Comments
 (0)