Skip to content

Fix several deprecation warnings#297

Merged
mkmkme merged 1 commit intovalkey-io:mainfrom
kurtmckee:fix-several-warnings
Apr 4, 2026
Merged

Fix several deprecation warnings#297
mkmkme merged 1 commit intovalkey-io:mainfrom
kurtmckee:fix-several-warnings

Conversation

@kurtmckee
Copy link
Copy Markdown
Contributor

Description of change

This change fixes several warnings thrown during test suite execution [recent CI run examples, see the first two warnings]:

DeprecationWarning: Call to deprecated close.
(Use aclose() instead) -- Deprecated since version 5.0.0.

In one case, the .close() usage is incorrect and needed to be updated. In another, the .close() call is deliberately testing deprecated usage and simply needed the pytest.deprecated_call() context manager added.

DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated
and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead

inspect.iscoroutinefunction() was added in Python 3.8 and can be safely switched to.

Pull Request check-list

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?

This change fixes several warnings thrown during test suite execution:

```
DeprecationWarning: Call to deprecated close.
(Use aclose() instead) -- Deprecated since version 5.0.0.
```

In one case, the `.close()` usage is incorrect and needed to be updated.
In another, the `.close()` call is deliberately testing deprecated usage
and simply needed the `pytest.deprecated_call()` context manager added.

```
DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated
and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead
```

`inspect.iscoroutinefunction()` was added in Python 3.8
and can be safely switched to.

Signed-off-by: Kurt McKee <[email protected]>
@kurtmckee kurtmckee changed the title Fix several warnings Fix several deprecation warnings Apr 2, 2026
@mkmkme
Copy link
Copy Markdown
Collaborator

mkmkme commented Apr 2, 2026

Thanks! I've seen those warnings and meant to tackle them myself, but great to see your PR. If it doesn't break anything on the older Python versions, I don't see a reason for it not to be merged.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.39%. Comparing base (d3eb971) to head (794fd39).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #297      +/-   ##
==========================================
- Coverage   76.40%   76.39%   -0.02%     
==========================================
  Files         129      129              
  Lines       34065    34066       +1     
==========================================
- Hits        26029    26026       -3     
- Misses       8036     8040       +4     

☔ 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.

@kurtmckee
Copy link
Copy Markdown
Contributor Author

There's more warnings to address, but ResourceWarnings typically require a bit more time to hunt down, so this was what I was able to tackle this morning. 👍

@mkmkme mkmkme requested a review from Copilot April 4, 2026 04:48
Copy link
Copy Markdown

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

Note

Copilot was unable to run its full agentic suite in this review.

Fixes deprecation warnings seen during the test suite run by updating deprecated async close usage and replacing the deprecated asyncio.iscoroutinefunction helper.

Changes:

  • Replace asyncio.iscoroutinefunction() with inspect.iscoroutinefunction() in the asyncio connection logic.
  • Update a test to use aclose() instead of the deprecated close().
  • Wrap an intentional deprecated close() call in pytest.deprecated_call().

Reviewed changes

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

File Description
valkey/asyncio/connection.py Switch coroutine function detection away from deprecated asyncio.iscoroutinefunction.
tests/test_asyncio/test_cwe_404.py Update test cleanup to use aclose() to avoid deprecated close().
tests/test_asyncio/test_cluster.py Explicitly assert the deprecation warning when calling deprecated close().

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

@mkmkme mkmkme merged commit b713132 into valkey-io:main Apr 4, 2026
86 checks passed
@mkmkme
Copy link
Copy Markdown
Collaborator

mkmkme commented Apr 4, 2026

Thanks again!

@kurtmckee kurtmckee deleted the fix-several-warnings branch April 4, 2026 13:44
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.

4 participants