From d4b41f54b57caf316c41c3973ab82bd53a418ff8 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Tue, 18 Jan 2022 13:15:56 +0200 Subject: [PATCH] Drop deprecated 'loop' parameter from RWLock constructor --- CHANGES.rst | 1 + aiorwlock/__init__.py | 13 ++----------- tests/test_rwlock.py | 16 ---------------- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index ca92e76..bebf58b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,7 @@ Changes * Dropped Python 3.6 support * Python 3.10 is officially supported +* Drop deprecated `loop` parameter from `RWLock` constructor 1.2.0 (2021-11-09) diff --git a/aiorwlock/__init__.py b/aiorwlock/__init__.py index 72e45ba..ba7d5a0 100644 --- a/aiorwlock/__init__.py +++ b/aiorwlock/__init__.py @@ -238,17 +238,8 @@ class RWLock: core = _RWLockCore - def __init__(self, *, fast: bool = False, loop: OptLoop = None) -> None: - if loop is None: - loop = asyncio.get_event_loop() - else: - warnings.warn( - 'Passing "loop" argument ' - 'is deprecated since aiorwlock 1.0 and scheduled for removal ' - 'in aiorwlock 2.0', - DeprecationWarning, - stacklevel=2, - ) + def __init__(self, *, fast: bool = False) -> None: + loop = asyncio.get_running_loop() if not loop.is_running(): warnings.warn( 'Instantiation of RWLock outside of async function context ' diff --git a/tests/test_rwlock.py b/tests/test_rwlock.py index 9757a19..89d9449 100644 --- a/tests/test_rwlock.py +++ b/tests/test_rwlock.py @@ -48,22 +48,6 @@ async def _wait(): await asyncio.sleep(0.01) -def test_ctor_deprecated_implicit_not_running(loop): - with pytest.warns(DeprecationWarning): - RWLock() - - -def test_ctor_deprecated_explicit_non_running(loop): - with pytest.warns(DeprecationWarning): - RWLock(loop=loop) - - -@pytest.mark.asyncio -async def test_ctor_loop_deprecated_arg(loop): - with pytest.warns(DeprecationWarning): - RWLock(loop=loop) - - @pytest.mark.asyncio async def test_ctor_loop_reader(loop): rwlock = RWLock().reader_lock