Skip to content

Commit f90f78a

Browse files
authored
Fix #567: Fix test_locally_defined_class_with_type_hints() (#570)
Update the test for Python 3.14 beta 1. What's New in Python 3.14 says: "In previous releases, it was sometimes possible to access class annotations from an instance of an annotated class. This behavior was undocumented and accidental, and will no longer work in Python 3.14." https://docs.python.org/3.14/whatsnew/3.14.html#related-changes
1 parent c025de7 commit f90f78a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tests/cloudpickle_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2658,7 +2658,9 @@ def method(self, arg: type_) -> type_:
26582658
MyClass.__annotations__ = {"attribute": type_}
26592659

26602660
def check_annotations(obj, expected_type, expected_type_str):
2661-
assert obj.__annotations__["attribute"] == expected_type
2661+
# On Python 3.14, it's no longer possible to access class
2662+
# annotations from an instance, so use type().
2663+
assert type(obj).__annotations__["attribute"] == expected_type
26622664
assert obj.method.__annotations__["arg"] == expected_type
26632665
assert obj.method.__annotations__["return"] == expected_type
26642666
return "ok"

0 commit comments

Comments
 (0)