fix: pin pytest-asyncio default fixture loop scope (#189) - #234
Merged
Conversation
pytest-asyncio's `asyncio_default_fixture_loop_scope` is currently unset and will default to "function" in a future release. Setting it explicitly now pins the behaviour and silences the original deprecation warning that prompted #189. (The literal warning text no longer fires in pytest-asyncio 1.3.0, but the behaviour-drift risk remains until the value is explicit.)
Contributor
There was a problem hiding this comment.
Pull request overview
Pins pytest-asyncio’s default event loop scope for async fixtures to avoid future behavior changes when pytest-asyncio flips its default.
Changes:
- Add a
[tool.pytest.ini_options]block inpyproject.toml. - Set
asyncio_default_fixture_loop_scope = "function"explicitly to prevent future default drift.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
asyncio_default_fixture_loop_scope = "function"in a new[tool.pytest.ini_options]block.Context
The literal deprecation warning text in #189 no longer fires in
pytest-asyncio1.3.0 (verified locally withpytest -W error::DeprecationWarning— silent). But the underlying behaviour-drift risk is still real:asyncio_default_fixture_loop_scopewas unset, and pytest-asyncio's CHANGELOG warns it will default to"function"in a future release. Setting it now means our test setup is immune to that flip whenever it lands.Verified locally —
pytestheader now reads:(was
=Nonebefore this change).Because this PR touches
pyproject.toml, merging will trigger.github/workflows/release.yml(which haspaths: pyproject.toml). The tag-exists guard (workflow line 48-54) catches it — version is still1.2.1, tagv1.2.1exists, the step exits 1 — so no release will be cut, but the workflow run will show as red on the merge commit. Wanted to flag this rather than have it surprise you.(Long-term fix: scope
paths:to only fire when the version actually changes, e.g. via aif: contains(github.event.head_commit.modified, 'pyproject.toml') && ...check or by gating on a release PR label. Out of scope for this PR.)Test plan
pytest— 21 tests passruff check— cleanruff format --check— cleanNot addressed in this PR
Issue #189 also suggests adopting
pytest-github-actions-annotate-failuresso warnings surface in the Actions UI. That's a separate, additive change — left for a follow-up if you want it.🤖 Generated with Claude Code