Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ repos:
- id: no-commit-to-branch
args: [--branch, dev, --branch, int, --branch, main]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
rev: v0.7.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
491 changes: 236 additions & 255 deletions lock/requirements-dev.txt

Large diffs are not rendered by default.

235 changes: 108 additions & 127 deletions lock/requirements.txt

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/ghga_service_commons/utils/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@
async def asyncnullcontext(
yield_value: YieldValue,
) -> AsyncGenerator[YieldValue, None]:
"""Async version of contextlib.nullcontext but with a custom yield value."""
"""Async version of contextlib.nullcontext but with a custom yield value.

Note that you can just use contextlib.nullcontext instead since Python 3.10.
"""
yield yield_value
2 changes: 1 addition & 1 deletion tests/integration/test_mock_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def fails():
def fails_also(): # will only get passed to error if we set handle_exception_subclasses
raise TestValueError()

httpx_mock.add_callback(callback=throwaway.handle_request)
httpx_mock.add_callback(callback=throwaway.handle_request, is_reusable=True)

with httpx.Client(base_url=BASE_URL) as client:
client.get("/gotohandler")
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/utils/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

"""Test context utils."""

import sys
from contextlib import nullcontext

import pytest

from ghga_service_commons.utils.context import asyncnullcontext
Expand All @@ -26,5 +29,13 @@ async def test_asyncnullcontext():
"""Test the asyncnullcontext context manager."""
value = "test"

modern_python = sys.version_info >= (3, 10)

try:
async with nullcontext(value) as test:
assert test == value
except AttributeError:
assert not modern_python, "nullcontext should work with async"

async with asyncnullcontext(value) as test:
assert test == value
Loading