Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion langfuse/_utils/error_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def class_decorator(cls: type) -> type:
for attr_name, attr_value in cls.__dict__.items():
if exclude and attr_name in exclude:
continue
if callable(attr_value):
# staticmethod is callable on Python >=3.10; keep its descriptor type.
if callable(attr_value) and not isinstance(attr_value, staticmethod):
# Wrap callable attributes (methods) with the decorator
setattr(cls, attr_name, decorator(attr_value))
elif isinstance(attr_value, classmethod):
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_error_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,11 @@ def test_auto_decorate_class_methods(caplog):
# Test the excluded instance method that should raise an error
with pytest.raises(ValueError, match="Error in instance method."):
test_obj.excluded_instance_method()


def test_auto_decorate_staticmethod_on_instance_access(caplog):
# A decorated staticmethod must stay a staticmethod: instance access must not
# bind `self` into its arguments.
assert isinstance(TestClass.__dict__["static_method"], staticmethod)
TestClass().static_method()
assert "Error in static method." in caplog.text