Skip to content

Commit

Permalink
Drop deprecated sync context manager support (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov authored Oct 31, 2024
1 parent 00fd343 commit a1111c2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 32 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,26 @@ jobs:
python -m pytest tests
python -m coverage xml
- name: Upload coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unit
fail_ci_if_error: false

test-summary:
if: always()
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- name: Test matrix status
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

deploy:
name: Deploy
runs-on: ubuntu-latest
needs: test
needs: test-summary
# Run only on pushing a tag
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
Expand Down
1 change: 1 addition & 0 deletions CHANGES/421.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop deprecated sync context manager support, use ``async with timeout(...): ...`` instead.
24 changes: 1 addition & 23 deletions async_timeout/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import asyncio
import enum
import sys
import warnings
from types import TracebackType
from typing import Optional, Type


from typing import final
from typing import Optional, Type, final


if sys.version_info >= (3, 11):
Expand Down Expand Up @@ -107,24 +103,6 @@ def __init__(
else:
self.update(deadline)

def __enter__(self) -> "Timeout":
warnings.warn(
"with timeout() is deprecated, use async with timeout() instead",
DeprecationWarning,
stacklevel=2,
)
self._do_enter()
return self

def __exit__(
self,
exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType],
) -> Optional[bool]:
self._do_exit(exc_type)
return None

async def __aenter__(self) -> "Timeout":
self._do_enter()
return self
Expand Down
7 changes: 0 additions & 7 deletions tests/test_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,3 @@ async def test_enter_twice() -> None:
with pytest.raises(RuntimeError, match="invalid state EXIT"):
async with t:
await asyncio.sleep(0)


@pytest.mark.asyncio
async def test_deprecated_with() -> None:
with pytest.warns(DeprecationWarning):
with timeout(1):
await asyncio.sleep(0)

0 comments on commit a1111c2

Please sign in to comment.