Skip to content

Commit 3b26e36

Browse files
committed
WIP
1 parent d5ddb16 commit 3b26e36

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Lib/dataclasses.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,13 +1620,13 @@ def annotate_method(format):
16201620
for ann, t in annotations.items()
16211621
}
16221622

1623-
from typing import Any, _convert_to_source
1623+
from typing import Any
16241624
ann_dict = {
16251625
ann: Any if t is _ANY_MARKER else t
16261626
for ann, t in annotations.items()
16271627
}
1628-
if format == annotationlib.Format.SOURCE:
1629-
return _convert_to_source(ann_dict)
1628+
if format == annotationlib.Format.STRING:
1629+
return annotationlib.annotations_to_string(ann_dict)
16301630
return ann_dict
16311631

16321632
# Update 'ns' with the user-supplied namespace plus our calculated values.

Lib/test/test_dataclasses/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import types
1414
import weakref
1515
import traceback
16+
import sys
1617
import unittest
1718
from unittest.mock import Mock
1819
from typing import ClassVar, Any, List, Union, Tuple, Dict, Generic, TypeVar, Optional, Protocol, DefaultDict
@@ -4247,16 +4248,16 @@ def test_no_types_get_annotations(self):
42474248
)
42484249
self.assertEqual(
42494250
annotationlib.get_annotations(
4250-
C, format=annotationlib.Format.SOURCE),
4251+
C, format=annotationlib.Format.STRING),
42514252
{'x': 'typing.Any', 'y': 'int', 'z': 'typing.Any'},
42524253
)
42534254

42544255
def test_no_types_no_typing_import(self):
4255-
import sys
4256-
4257-
C = make_dataclass('C', ['x', ('y', int)])
4258-
42594256
with import_helper.CleanImport('typing'):
4257+
self.assertNotIn('typing', sys.modules)
4258+
C = make_dataclass('C', ['x', ('y', int)])
4259+
4260+
self.assertNotIn('typing', sys.modules)
42604261
self.assertEqual(
42614262
annotationlib.get_annotations(
42624263
C, format=annotationlib.Format.FORWARDREF),

0 commit comments

Comments
 (0)