Skip to content

Replace asyncio.iscoroutinefunction with inspect.iscoroutinefunction#2066

Merged
frenck merged 1 commit into
frenck:mainfrom
mik-laj:replace-asyncio-iscoroutinefunction
May 20, 2026
Merged

Replace asyncio.iscoroutinefunction with inspect.iscoroutinefunction#2066
frenck merged 1 commit into
frenck:mainfrom
mik-laj:replace-asyncio-iscoroutinefunction

Conversation

@mik-laj
Copy link
Copy Markdown
Collaborator

@mik-laj mik-laj commented May 17, 2026

Summary

Replace deprecated asyncio.iscoroutinefunction() with inspect.iscoroutinefunction() to address Python 3.16 deprecation warnings.

Changes

  • Updated async_typer.py to use inspect.iscoroutinefunction()
  • Updated test_cli.py to use inspect.iscoroutinefunction() and removed unused asyncio import

Test plan

  • All pre-commit hooks pass
  • All tests pass

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Chores
    • Internal improvements to CLI command detection logic to enhance code reliability and maintainability.

Review Change Stack

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 17, 2026 04:00
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fb0133c7-86e6-42ab-9254-4ee2d9ee51cb

📥 Commits

Reviewing files that changed from the base of the PR and between 1bcfdf0 and e8482f7.

📒 Files selected for processing (2)
  • src/wled/cli/async_typer.py
  • tests/test_cli.py

📝 Walkthrough

Walkthrough

This PR replaces the async function detection method in the WLED CLI from asyncio.iscoroutinefunction to inspect.iscoroutinefunction across both the AsyncTyper implementation and its unit tests. No public signatures change; the wrapped behavior remains identical.

Changes

Async function detection refactor

Layer / File(s) Summary
AsyncTyper async detection
src/wled/cli/async_typer.py
Replace asyncio import with inspect and update coroutine detection in both the callback and command decorator methods from asyncio.iscoroutinefunction to inspect.iscoroutinefunction.
Test async detection assertions
tests/test_cli.py
Add inspect import and update all four unit tests (async command, sync command, async callback, sync callback) to verify wrapped functions using the new inspect.iscoroutinefunction predicate.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A simpler way to spot async's call,
From asyncio's check to inspect's thrall,
Commands and callbacks now properly known,
With tests that confirm the new seed is sown! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 46.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: replacing asyncio.iscoroutinefunction with inspect.iscoroutinefunction across the codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Replaces deprecated asyncio.iscoroutinefunction() calls with inspect.iscoroutinefunction() to address Python 3.16 deprecation warnings.

Changes:

  • Swap asyncio.iscoroutinefunction for inspect.iscoroutinefunction in async_typer.py.
  • Same swap in test_cli.py, replacing the asyncio import with inspect.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/wled/cli/async_typer.py Adds inspect import and uses inspect.iscoroutinefunction in callback and command decorators.
tests/test_cli.py Replaces asyncio import with inspect and updates four assertions accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mik-laj mik-laj added the maintenance Generic maintenance tasks. label May 17, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.29%. Comparing base (3e87d76) to head (e8482f7).
⚠️ Report is 606 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2066       +/-   ##
===========================================
+ Coverage   58.61%   97.29%   +38.68%     
===========================================
  Files           6        8        +2     
  Lines         662     1109      +447     
  Branches      143      112       -31     
===========================================
+ Hits          388     1079      +691     
+ Misses        270       20      -250     
- Partials        4       10        +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Owner

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Nice!👍

../Frenck

@frenck frenck merged commit 1d5066f into frenck:main May 20, 2026
22 of 23 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

maintenance Generic maintenance tasks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants