Skip to content

Commit 3aa74ea

Browse files
committed
Use getattr to avoid #type:ignore
1 parent 2811114 commit 3aa74ea

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

testing/test_pathlib.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ class Data:
460460
)
461461

462462
module = import_path(fn, mode="importlib", root=tmp_path)
463-
Data: Any = module.Data # type: ignore[attr-defined]
463+
Data: Any = getattr(module, "Data")
464464
data = Data(value="foo")
465465
assert data.value == "foo"
466466
assert data.__module__ == "src.tests.test_dataclass"
@@ -486,7 +486,8 @@ def round_trip():
486486
)
487487

488488
module = import_path(fn, mode="importlib", root=tmp_path)
489-
action: Any = module.round_trip() # type: ignore[attr-defined]
489+
round_trip = getattr(module, "round_trip")
490+
action = round_trip()
490491
assert action() == 42
491492

492493

@@ -532,10 +533,10 @@ def round_trip(obj):
532533
return pickle.loads(s)
533534

534535
module = import_path(fn1, mode="importlib", root=tmp_path)
535-
Data1 = module.Data # type: ignore[attr-defined]
536+
Data1 = getattr(module, "Data")
536537

537538
module = import_path(fn2, mode="importlib", root=tmp_path)
538-
Data2 = module.Data # type: ignore[attr-defined]
539+
Data2 = getattr(module, "Data")
539540

540541
assert round_trip(Data1(20)) == Data1(20)
541542
assert round_trip(Data2("hello")) == Data2("hello")

0 commit comments

Comments
 (0)