Skip to content

Commit 1bdc3a1

Browse files
Format the ClassVar test source with an inline f-string
Per review: interpolate the parameterized annotation directly into the module template instead of running str.replace over it. Signed-off-by: Charan Rathore <[email protected]>
1 parent ccc3a24 commit 1bdc3a1

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎tests/unit/test_struct.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,18 +2782,16 @@ def test_classvar(self, case, future_annotations):
27822782
@pytest.mark.parametrize("annotation", ["typing.ClassVar", "typing.ClassVar[int]"])
27832783
def test_wrong_classvar(self, annotation):
27842784
# See https://github.com/msgspec/msgspec/issues/1096 and #1221
2785-
source = """
2785+
source = f"""
27862786
from __future__ import annotations
27872787
from msgspec import Struct
27882788
27892789
class typing:
27902790
pass
27912791
27922792
class Ex(Struct):
2793-
a: typing.ClassVar
2793+
a: {annotation}
27942794
"""
2795-
2796-
source = source.replace("a: typing.ClassVar", f"a: {annotation}")
27972795
with pytest.raises(
27982796
AttributeError,
27992797
match="'typing' has no attribute 'ClassVar'",

0 commit comments

Comments
 (0)