Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop deprecated sync context manager support #421

Merged
merged 7 commits into from
Oct 31, 2024
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
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)
Loading