diff --git a/narwhals/utils.py b/narwhals/utils.py index cd9eb00e44..e3d71e7867 100644 --- a/narwhals/utils.py +++ b/narwhals/utils.py @@ -1277,11 +1277,8 @@ def dtype_matches_time_unit_and_time_zone( def _hasattr_static(obj: Any, attr: str) -> bool: - try: - getattr_static(obj, attr) - except AttributeError: - return False - return True + sentinel = object() + return getattr_static(obj, attr, sentinel) is not sentinel def is_compliant_dataframe(obj: Any) -> TypeIs[CompliantDataFrame]: