Skip to content

Commit

Permalink
update helper
Browse files Browse the repository at this point in the history
  • Loading branch information
InvincibleRMC committed Dec 5, 2024
1 parent 259ce93 commit 7e380e2
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions tests/test_pytypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,13 +1104,7 @@ def test_dict_ranges(tested_dict, expected):


def get_annotations_helper(o):
# Taken from __annotations__ docs
# https://docs.python.org/3/howto/annotations.html#accessing-the-annotations-dict-of-an-object-in-python-3-9-and-older
if isinstance(o, type):
ann = o.__dict__.get("__annotations__", None)
else:
ann = getattr(o, "__annotations__", None)
return ann
return getattr(o, "__annotations__", None)


def test_module_attribute_types() -> None:
Expand All @@ -1124,7 +1118,7 @@ def test_class_attribute_types() -> None:
empty_annotations = get_annotations_helper(m.EmptyAnnotationClass)
annotations = get_annotations_helper(m.Point)

assert empty_annotations is None
assert empty_annotations == {}
assert annotations["x"] == "float"
assert annotations["dict_str_int"] == "dict[str, int]"

Expand Down

0 comments on commit 7e380e2

Please sign in to comment.