Skip to content

Commit df5fda9

Browse files
committed
Address review
1 parent 8a32156 commit df5fda9

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

Lib/dataclasses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import abc
1010
import _thread
1111
from types import FunctionType, GenericAlias
12-
from typing import ForwardRef
1312

1413

1514
__all__ = ['dataclass',
@@ -453,6 +452,7 @@ def _field_init(f, frozen, globals, self_name, slots, module):
453452
# initialize this field.
454453

455454
if f.init and isinstance(f.type, str):
455+
from typing import ForwardRef # `typing` is a heavy import
456456
# We need to resolve this string type into a real `ForwardRef` object,
457457
# because otherwise we might end up with unsolvable annotations.
458458
# For example:

Lib/test/dataclass_textanno2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Foo: # matching name with `dataclass_testanno.Foo`
1818

1919

2020
@dataclasses.dataclass
21-
class WithMatchinNameOverride(dataclass_textanno.Bar):
21+
class WithMatchingNameOverride(dataclass_textanno.Bar):
2222
foo: Foo # Existing `foo` annotation should be overridden
2323

2424

Lib/test/test_dataclasses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3227,12 +3227,12 @@ def test_dataclass_proxy_modules_matching_name_override(self):
32273227
from dataclasses import dataclass
32283228

32293229
@dataclass
3230-
class Default(dataclass_textanno2.WithMatchinNameOverride):
3230+
class Default(dataclass_textanno2.WithMatchingNameOverride):
32313231
pass
32323232

32333233
classes = [
32343234
Default,
3235-
dataclass_textanno2.WithMatchinNameOverride
3235+
dataclass_textanno2.WithMatchingNameOverride
32363236
]
32373237
for klass in classes:
32383238
with self.subTest(klass=klass):

0 commit comments

Comments
 (0)