Skip to content

Use iscoroutinefunction from inspect#1551

Open
marpulli wants to merge 1 commit intolangfuse:mainfrom
marpulli:use-iscoroutinefunction-from-inspect
Open

Use iscoroutinefunction from inspect#1551
marpulli wants to merge 1 commit intolangfuse:mainfrom
marpulli:use-iscoroutinefunction-from-inspect

Conversation

@marpulli
Copy link

@marpulli marpulli commented Mar 3, 2026

iscoroutinefunction in asyncio is deprecated and it should be imported from inspect instead. In python 3.14, this the use of this function raises deprecation warnings. The function was added to inspect in python 3.5 so this change should be backwards compatible with previous python versions.


Important

Replace deprecated asyncio.iscoroutinefunction with inspect.iscoroutinefunction in langfuse/_client/observe.py for Python 3.14 compatibility.

  • Behavior:
    • Replace asyncio.iscoroutinefunction with inspect.iscoroutinefunction in decorator() in langfuse/_client/observe.py to avoid deprecation warnings in Python 3.14.
  • Compatibility:
    • Backward compatible with Python 3.5 and later.

This description was created by Ellipsis for bd0adbb. You can customize this summary. It will automatically update as commits are pushed.

Disclaimer: Experimental PR review

Greptile Summary

This PR replaces the deprecated asyncio.iscoroutinefunction with inspect.iscoroutinefunction in the decorator dispatch logic of LangfuseDecorator. The change is correct and forward-compatible — inspect.iscoroutinefunction has been available since Python 3.5, and inspect is already imported at the top of the module. The asyncio import is preserved because it is still needed for asyncio.create_task elsewhere in the file.

  • Single line changed in langfuse/_client/observe.py (line 198): asyncio.iscoroutinefunction(func)inspect.iscoroutinefunction(func)
  • No import changes required: inspect is already imported at line 3; asyncio remains necessary for other usages
  • Backwards compatible: inspect.iscoroutinefunction is available since Python 3.5, covering all supported versions
  • Addresses deprecation warning introduced in Python 3.14 for asyncio.iscoroutinefunction

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, semantically equivalent substitution that resolves a Python 3.14 deprecation warning.
  • The change is a one-line swap between two functions with identical semantics. Both modules are already imported at the top of the file, no new dependencies are introduced, and the asyncio import is correctly kept because it is still used elsewhere in the file. There are no logic, safety, or compatibility concerns. The change is backwards compatible with Python 3.5+.
  • No files require special attention

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["observe() decorator called with func"] --> B{"inspect.iscoroutinefunction(func)?"}
    B -- "True (async func)" --> C["self._async_observe(func, ...)"]
    B -- "False (sync func)" --> D["self._sync_observe(func, ...)"]
    C --> E["Returns async-wrapped decorator"]
    D --> F["Returns sync-wrapped decorator"]
Loading

Last reviewed commit: bd0adbb

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

@CLAassistant
Copy link

CLAassistant commented Mar 3, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@hassiebp hassiebp self-requested a review March 3, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants