Skip to content

Commit a1111c2

Browse files
authored
Drop deprecated sync context manager support (#421)
1 parent 00fd343 commit a1111c2

File tree

4 files changed

+14
-32
lines changed

4 files changed

+14
-32
lines changed

Diff for: .github/workflows/ci.yml

+12-2
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,26 @@ jobs:
8585
python -m pytest tests
8686
python -m coverage xml
8787
- name: Upload coverage
88-
uses: codecov/codecov-action@v3
88+
uses: codecov/codecov-action@v4
8989
with:
9090
file: ./coverage.xml
9191
flags: unit
9292
fail_ci_if_error: false
9393

94+
test-summary:
95+
if: always()
96+
needs: [lint, test]
97+
runs-on: ubuntu-latest
98+
steps:
99+
- name: Test matrix status
100+
uses: re-actors/alls-green@release/v1
101+
with:
102+
jobs: ${{ toJSON(needs) }}
103+
94104
deploy:
95105
name: Deploy
96106
runs-on: ubuntu-latest
97-
needs: test
107+
needs: test-summary
98108
# Run only on pushing a tag
99109
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
100110
steps:

Diff for: CHANGES/421.removal.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Drop deprecated sync context manager support, use ``async with timeout(...): ...`` instead.

Diff for: async_timeout/__init__.py

+1-23
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import asyncio
22
import enum
33
import sys
4-
import warnings
54
from types import TracebackType
6-
from typing import Optional, Type
7-
8-
9-
from typing import final
5+
from typing import Optional, Type, final
106

117

128
if sys.version_info >= (3, 11):
@@ -107,24 +103,6 @@ def __init__(
107103
else:
108104
self.update(deadline)
109105

110-
def __enter__(self) -> "Timeout":
111-
warnings.warn(
112-
"with timeout() is deprecated, use async with timeout() instead",
113-
DeprecationWarning,
114-
stacklevel=2,
115-
)
116-
self._do_enter()
117-
return self
118-
119-
def __exit__(
120-
self,
121-
exc_type: Optional[Type[BaseException]],
122-
exc_val: Optional[BaseException],
123-
exc_tb: Optional[TracebackType],
124-
) -> Optional[bool]:
125-
self._do_exit(exc_type)
126-
return None
127-
128106
async def __aenter__(self) -> "Timeout":
129107
self._do_enter()
130108
return self

Diff for: tests/test_timeout.py

-7
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,3 @@ async def test_enter_twice() -> None:
360360
with pytest.raises(RuntimeError, match="invalid state EXIT"):
361361
async with t:
362362
await asyncio.sleep(0)
363-
364-
365-
@pytest.mark.asyncio
366-
async def test_deprecated_with() -> None:
367-
with pytest.warns(DeprecationWarning):
368-
with timeout(1):
369-
await asyncio.sleep(0)

0 commit comments

Comments
 (0)