Skip to content

Commit 37d9b3c

Browse files
committed
Test we don't fix annotations on hand-written init functions
1 parent 7795c9b commit 37d9b3c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Lib/test/test_dataclasses/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,6 +2532,17 @@ class D:
25322532
{"d": "list[undefined]", "return": "None"}
25332533
)
25342534

2535+
# Check that __annotate__ is not replaced on non-generated __init__ functions
2536+
@dataclass
2537+
class E:
2538+
x: str
2539+
def __init__(self, x: int) -> None:
2540+
self.x = x
2541+
2542+
self.assertEqual(
2543+
annotationlib.get_annotations(E.__init__), {"x": int, "return": None}
2544+
)
2545+
25352546

25362547
class TestRepr(unittest.TestCase):
25372548
def test_repr(self):

0 commit comments

Comments
 (0)