diff --git a/ibis/common/typing.py b/ibis/common/typing.py index 33da104f4150..79f5fba6c420 100644 --- a/ibis/common/typing.py +++ b/ibis/common/typing.py @@ -60,7 +60,11 @@ class properties. if include_properties: for name in dir(obj): - attr = getattr(obj, name) + try: + attr = getattr(obj, name) + except AttributeError: + # What else can be done besides skipping and continuing? + continue if isinstance(attr, property): annots = _get_type_hints(attr.fget, include_extras=include_extras) if return_annot := annots.get("return"): diff --git a/ibis/tests/test_typing.py b/ibis/tests/test_typing.py new file mode 100644 index 000000000000..5db9fe180d35 --- /dev/null +++ b/ibis/tests/test_typing.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +from typing import Any + +from ibis.common.typing import get_type_hints + + +class TestClass: + a: int + + @property + def b(self) -> str: + return "test" + + @property + def c(self) -> Any: + raise AttributeError("Property 'c' raises AttributeError") + + +def test_get_type_hints_with_attribute_error(): + hints = get_type_hints(TestClass, include_properties=True) + assert hints == {"a": int, "b": str}