diff --git a/pyproject.toml b/pyproject.toml index 24e7dc56..b89c24da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,10 +68,44 @@ write_to = "pytest_asyncio/_version.py" [tool.ruff] line-length = 88 +format.docstring-code-format = true lint.select = [ - "E", # pycodestyle - "F", # pyflakes - "W", # pycodestyle + "B", # bugbear + "D", # pydocstyle + "E", # pycodestyle + "F", # pyflakes + "FA100", # add future annotations + "PGH004", # pygrep-hooks - Use specific rule codes when using noqa + "PIE", # flake8-pie + "PLE", # pylint error + "PYI", # flake8-pyi + "RUF", # ruff + "T100", # flake8-debugger + "UP", # pyupgrade + "W", # pycodestyle +] + +lint.ignore = [ + # bugbear ignore + "B028", # No explicit `stacklevel` keyword argument found + # pydocstyle ignore + "D100", # Missing docstring in public module + "D101", # Missing docstring in public class + "D102", # Missing docstring in public method + "D103", # Missing docstring in public function + "D104", # Missing docstring in public package + "D105", # Missing docstring in magic method + "D106", # Missing docstring in public nested class + "D107", # Missing docstring in `__init__` + "D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible + "D205", # 1 blank line required between summary line and description + "D209", # [*] Multi-line docstring closing quotes should be on a separate line + "D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible. + "D400", # First line should end with a period + "D401", # First line of docstring should be in imperative mood + "D402", # First line should not be the function's signature + "D404", # First word of the docstring should not be "This" + "D415", # First line should end with a period, question mark, or exclamation point ] [tool.pytest.ini_options] diff --git a/pytest_asyncio/__init__.py b/pytest_asyncio/__init__.py index 08dca478..c25c1bf1 100644 --- a/pytest_asyncio/__init__.py +++ b/pytest_asyncio/__init__.py @@ -1,6 +1,8 @@ """The main point for importing pytest-asyncio items.""" -from ._version import version as __version__ # noqa +from __future__ import annotations + +from ._version import version as __version__ # noqa: F401 from .plugin import fixture, is_async_test __all__ = ("fixture", "is_async_test") diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py index b2a8fef5..1c81fee5 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -1,5 +1,7 @@ """pytest-asyncio implementation.""" +from __future__ import annotations + import asyncio import contextlib import enum @@ -8,23 +10,20 @@ import socket import warnings from asyncio import AbstractEventLoopPolicy -from textwrap import dedent -from typing import ( - Any, +from collections.abc import ( AsyncIterator, Awaitable, - Callable, - Dict, Generator, Iterable, Iterator, - List, - Literal, Mapping, - Optional, Sequence, - Set, - Type, +) +from textwrap import dedent +from typing import ( + Any, + Callable, + Literal, TypeVar, Union, overload, @@ -112,16 +111,16 @@ def pytest_addoption(parser: Parser, pluginmanager: PytestPluginManager) -> None def fixture( fixture_function: FixtureFunction, *, - scope: "Union[_ScopeName, Callable[[str, Config], _ScopeName]]" = ..., - loop_scope: Union[_ScopeName, None] = ..., - params: Optional[Iterable[object]] = ..., + scope: _ScopeName | Callable[[str, Config], _ScopeName] = ..., + loop_scope: _ScopeName | None = ..., + params: Iterable[object] | None = ..., autouse: bool = ..., - ids: Union[ - Iterable[Union[str, float, int, bool, None]], - Callable[[Any], Optional[object]], - None, - ] = ..., - name: Optional[str] = ..., + ids: ( + Iterable[str | float | int | bool | None] + | Callable[[Any], object | None] + | None + ) = ..., + name: str | None = ..., ) -> FixtureFunction: ... @@ -129,24 +128,24 @@ def fixture( def fixture( fixture_function: None = ..., *, - scope: "Union[_ScopeName, Callable[[str, Config], _ScopeName]]" = ..., - loop_scope: Union[_ScopeName, None] = ..., - params: Optional[Iterable[object]] = ..., + scope: _ScopeName | Callable[[str, Config], _ScopeName] = ..., + loop_scope: _ScopeName | None = ..., + params: Iterable[object] | None = ..., autouse: bool = ..., - ids: Union[ - Iterable[Union[str, float, int, bool, None]], - Callable[[Any], Optional[object]], - None, - ] = ..., - name: Optional[str] = None, + ids: ( + Iterable[str | float | int | bool | None] + | Callable[[Any], object | None] + | None + ) = ..., + name: str | None = None, ) -> FixtureFunctionMarker: ... def fixture( - fixture_function: Optional[FixtureFunction] = None, - loop_scope: Union[_ScopeName, None] = None, + fixture_function: FixtureFunction | None = None, + loop_scope: _ScopeName | None = None, **kwargs: Any, -) -> Union[FixtureFunction, FixtureFunctionMarker]: +) -> FixtureFunction | FixtureFunctionMarker: if fixture_function is not None: _make_asyncio_fixture_function(fixture_function, loop_scope) return pytest.fixture(fixture_function, **kwargs) @@ -165,9 +164,7 @@ def _is_asyncio_fixture_function(obj: Any) -> bool: return getattr(obj, "_force_asyncio_fixture", False) -def _make_asyncio_fixture_function( - obj: Any, loop_scope: Union[_ScopeName, None] -) -> None: +def _make_asyncio_fixture_function(obj: Any, loop_scope: _ScopeName | None) -> None: if hasattr(obj, "__func__"): # instance method, check the function object obj = obj.__func__ @@ -185,11 +182,11 @@ def _get_asyncio_mode(config: Config) -> Mode: val = config.getini("asyncio_mode") try: return Mode(val) - except ValueError: + except ValueError as e: modes = ", ".join(m.value for m in Mode) raise pytest.UsageError( f"{val!r} is not a valid asyncio_mode. Valid modes: {modes}." - ) + ) from e _DEFAULT_FIXTURE_LOOP_SCOPE_UNSET = """\ @@ -215,7 +212,7 @@ def pytest_configure(config: Config) -> None: @pytest.hookimpl(tryfirst=True) -def pytest_report_header(config: Config) -> List[str]: +def pytest_report_header(config: Config) -> list[str]: """Add asyncio config to pytest header.""" mode = _get_asyncio_mode(config) default_loop_scope = config.getini("asyncio_default_fixture_loop_scope") @@ -224,7 +221,7 @@ def pytest_report_header(config: Config) -> List[str]: def _preprocess_async_fixtures( collector: Collector, - processed_fixturedefs: Set[FixtureDef], + processed_fixturedefs: set[FixtureDef], ) -> None: config = collector.config default_loop_scope = config.getini("asyncio_default_fixture_loop_scope") @@ -268,9 +265,7 @@ def _preprocess_async_fixtures( def _synchronize_async_fixture(fixturedef: FixtureDef) -> None: - """ - Wraps the fixture function of an async fixture in a synchronous function. - """ + """Wraps the fixture function of an async fixture in a synchronous function.""" if inspect.isasyncgenfunction(fixturedef.func): _wrap_asyncgen_fixture(fixturedef) elif inspect.iscoroutinefunction(fixturedef.func): @@ -279,10 +274,10 @@ def _synchronize_async_fixture(fixturedef: FixtureDef) -> None: def _add_kwargs( func: Callable[..., Any], - kwargs: Dict[str, Any], + kwargs: dict[str, Any], event_loop: asyncio.AbstractEventLoop, request: FixtureRequest, -) -> Dict[str, Any]: +) -> dict[str, Any]: sig = inspect.signature(func) ret = kwargs.copy() if "request" in sig.parameters: @@ -292,7 +287,7 @@ def _add_kwargs( return ret -def _perhaps_rebind_fixture_func(func: _T, instance: Optional[Any]) -> _T: +def _perhaps_rebind_fixture_func(func: _T, instance: Any | None) -> _T: if instance is not None: # The fixture needs to be bound to the actual request.instance # so it is bound to the same object as the test method. @@ -392,9 +387,7 @@ class PytestAsyncioFunction(Function): """Base class for all test functions managed by pytest-asyncio.""" @classmethod - def item_subclass_for( - cls, item: Function, / - ) -> Union[Type["PytestAsyncioFunction"], None]: + def item_subclass_for(cls, item: Function, /) -> type[PytestAsyncioFunction] | None: """ Returns a subclass of PytestAsyncioFunction if there is a specialized subclass for the specified function item. @@ -522,17 +515,15 @@ def runtest(self) -> None: super().runtest() -_HOLDER: Set[FixtureDef] = set() +_HOLDER: set[FixtureDef] = set() # The function name needs to start with "pytest_" # see https://github.com/pytest-dev/pytest/issues/11307 @pytest.hookimpl(specname="pytest_pycollect_makeitem", tryfirst=True) def pytest_pycollect_makeitem_preprocess_async_fixtures( - collector: Union[pytest.Module, pytest.Class], name: str, obj: object -) -> Union[ - pytest.Item, pytest.Collector, List[Union[pytest.Item, pytest.Collector]], None -]: + collector: pytest.Module | pytest.Class, name: str, obj: object +) -> pytest.Item | pytest.Collector | list[pytest.Item | pytest.Collector] | None: """A pytest hook to collect asyncio coroutines.""" if not collector.funcnamefilter(name): return None @@ -544,7 +535,7 @@ def pytest_pycollect_makeitem_preprocess_async_fixtures( # see https://github.com/pytest-dev/pytest/issues/11307 @pytest.hookimpl(specname="pytest_pycollect_makeitem", hookwrapper=True) def pytest_pycollect_makeitem_convert_async_functions_to_subclass( - collector: Union[pytest.Module, pytest.Class], name: str, obj: object + collector: pytest.Module | pytest.Class, name: str, obj: object ) -> Generator[None, pluggy.Result, None]: """ Converts coroutines and async generators collected as pytest.Functions @@ -552,12 +543,9 @@ def pytest_pycollect_makeitem_convert_async_functions_to_subclass( """ hook_result = yield try: - node_or_list_of_nodes: Union[ - pytest.Item, - pytest.Collector, - List[Union[pytest.Item, pytest.Collector]], - None, - ] = hook_result.get_result() + node_or_list_of_nodes: ( + pytest.Item | pytest.Collector | list[pytest.Item | pytest.Collector] | None + ) = hook_result.get_result() except BaseException as e: hook_result.force_exception(e) return @@ -585,7 +573,7 @@ def pytest_pycollect_makeitem_convert_async_functions_to_subclass( _event_loop_fixture_id = StashKey[str]() -_fixture_scope_by_collector_type: Mapping[Type[pytest.Collector], _ScopeName] = { +_fixture_scope_by_collector_type: Mapping[type[pytest.Collector], _ScopeName] = { Class: "class", # Package is a subclass of module and the dict is used in isinstance checks # Therefore, the order matters and Package needs to appear before Module @@ -596,7 +584,7 @@ def pytest_pycollect_makeitem_convert_async_functions_to_subclass( # A stack used to push package-scoped loops during collection of a package # and pop those loops during collection of a Module -__package_loop_stack: List[Union[FixtureFunctionMarker, FixtureFunction]] = [] +__package_loop_stack: list[FixtureFunctionMarker | FixtureFunction] = [] @pytest.hookimpl @@ -872,7 +860,7 @@ def _provide_clean_event_loop() -> None: def _get_event_loop_no_warn( - policy: Optional[AbstractEventLoopPolicy] = None, + policy: AbstractEventLoopPolicy | None = None, ) -> asyncio.AbstractEventLoop: with warnings.catch_warnings(): warnings.simplefilter("ignore", DeprecationWarning) @@ -883,7 +871,7 @@ def _get_event_loop_no_warn( @pytest.hookimpl(tryfirst=True, hookwrapper=True) -def pytest_pyfunc_call(pyfuncitem: Function) -> Optional[object]: +def pytest_pyfunc_call(pyfuncitem: Function) -> object | None: """ Pytest hook called before a test case is run. @@ -910,9 +898,10 @@ def pytest_pyfunc_call(pyfuncitem: Function) -> Optional[object]: def wrap_in_sync( func: Callable[..., Awaitable[Any]], ): - """Return a sync wrapper around an async function executing it in the - current event loop.""" - + """ + Return a sync wrapper around an async function executing it in the + current event loop. + """ # if the function is already wrapped, we rewrap using the original one # not using __wrapped__ because the original function may already be # a wrapped one @@ -1002,7 +991,7 @@ def _get_marked_loop_scope(asyncio_marker: Mark) -> _ScopeName: return scope -def _retrieve_scope_root(item: Union[Collector, Item], scope: str) -> Collector: +def _retrieve_scope_root(item: Collector | Item, scope: str) -> Collector: node_type_by_scope = { "class": Class, "module": Module, diff --git a/tests/async_fixtures/test_async_fixtures.py b/tests/async_fixtures/test_async_fixtures.py index 40012962..16478539 100644 --- a/tests/async_fixtures/test_async_fixtures.py +++ b/tests/async_fixtures/test_async_fixtures.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import asyncio import unittest.mock diff --git a/tests/async_fixtures/test_async_fixtures_scope.py b/tests/async_fixtures/test_async_fixtures_scope.py index a25934a8..7fbed781 100644 --- a/tests/async_fixtures/test_async_fixtures_scope.py +++ b/tests/async_fixtures/test_async_fixtures_scope.py @@ -3,6 +3,8 @@ module-scoped too. """ +from __future__ import annotations + import asyncio import pytest diff --git a/tests/async_fixtures/test_async_fixtures_with_finalizer.py b/tests/async_fixtures/test_async_fixtures_with_finalizer.py index 8efc8fc4..199ecbca 100644 --- a/tests/async_fixtures/test_async_fixtures_with_finalizer.py +++ b/tests/async_fixtures/test_async_fixtures_with_finalizer.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import asyncio import functools diff --git a/tests/async_fixtures/test_async_gen_fixtures.py b/tests/async_fixtures/test_async_gen_fixtures.py index 2b198f2b..ddc2f5be 100644 --- a/tests/async_fixtures/test_async_gen_fixtures.py +++ b/tests/async_fixtures/test_async_gen_fixtures.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import unittest.mock import pytest diff --git a/tests/async_fixtures/test_nested.py b/tests/async_fixtures/test_nested.py index da7ee3a1..72b5129a 100644 --- a/tests/async_fixtures/test_nested.py +++ b/tests/async_fixtures/test_nested.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import asyncio import pytest diff --git a/tests/async_fixtures/test_parametrized_loop.py b/tests/async_fixtures/test_parametrized_loop.py index 2bdbe5e8..ca2cb5c7 100644 --- a/tests/async_fixtures/test_parametrized_loop.py +++ b/tests/async_fixtures/test_parametrized_loop.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/async_fixtures/test_shared_module_fixture.py b/tests/async_fixtures/test_shared_module_fixture.py index 9b0ad540..3295c83a 100644 --- a/tests/async_fixtures/test_shared_module_fixture.py +++ b/tests/async_fixtures/test_shared_module_fixture.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/conftest.py b/tests/conftest.py index 4aa8c89a..76e2026f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import asyncio import pytest diff --git a/tests/hypothesis/test_base.py b/tests/hypothesis/test_base.py index 176c9aee..4b185f62 100644 --- a/tests/hypothesis/test_base.py +++ b/tests/hypothesis/test_base.py @@ -1,7 +1,10 @@ -"""Tests for the Hypothesis integration, which wraps async functions in a +""" +Tests for the Hypothesis integration, which wraps async functions in a sync shim for Hypothesis. """ +from __future__ import annotations + from textwrap import dedent import pytest diff --git a/tests/loop_fixture_scope/conftest.py b/tests/loop_fixture_scope/conftest.py index 6b9a7649..4e8b06de 100644 --- a/tests/loop_fixture_scope/conftest.py +++ b/tests/loop_fixture_scope/conftest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import asyncio import pytest diff --git a/tests/loop_fixture_scope/test_loop_fixture_scope.py b/tests/loop_fixture_scope/test_loop_fixture_scope.py index eb4be8c9..eb1bae58 100644 --- a/tests/loop_fixture_scope/test_loop_fixture_scope.py +++ b/tests/loop_fixture_scope/test_loop_fixture_scope.py @@ -1,5 +1,7 @@ """Unit tests for overriding the event loop with a larger scoped one.""" +from __future__ import annotations + import asyncio import pytest diff --git a/tests/markers/test_class_scope.py b/tests/markers/test_class_scope.py index edce31f6..4bddb4b8 100644 --- a/tests/markers/test_class_scope.py +++ b/tests/markers/test_class_scope.py @@ -1,5 +1,7 @@ """Test if pytestmark works when defined on a class.""" +from __future__ import annotations + import asyncio from textwrap import dedent diff --git a/tests/markers/test_function_scope.py b/tests/markers/test_function_scope.py index 75487b5d..c17a6225 100644 --- a/tests/markers/test_function_scope.py +++ b/tests/markers/test_function_scope.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/markers/test_invalid_arguments.py b/tests/markers/test_invalid_arguments.py index a4f4b070..89a1ac64 100644 --- a/tests/markers/test_invalid_arguments.py +++ b/tests/markers/test_invalid_arguments.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent import pytest diff --git a/tests/markers/test_module_scope.py b/tests/markers/test_module_scope.py index 12515f23..7dbdbb7f 100644 --- a/tests/markers/test_module_scope.py +++ b/tests/markers/test_module_scope.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/markers/test_package_scope.py b/tests/markers/test_package_scope.py index bd3e4ac7..204238a4 100644 --- a/tests/markers/test_package_scope.py +++ b/tests/markers/test_package_scope.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/markers/test_session_scope.py b/tests/markers/test_session_scope.py index 3bc38a4f..70e191b2 100644 --- a/tests/markers/test_session_scope.py +++ b/tests/markers/test_session_scope.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/modes/test_auto_mode.py b/tests/modes/test_auto_mode.py index f41c9d1a..21c48d87 100644 --- a/tests/modes/test_auto_mode.py +++ b/tests/modes/test_auto_mode.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/modes/test_strict_mode.py b/tests/modes/test_strict_mode.py index b8232d05..c5a7351a 100644 --- a/tests/modes/test_strict_mode.py +++ b/tests/modes/test_strict_mode.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/test_asyncio_fixture.py b/tests/test_asyncio_fixture.py index 4bdabce2..91e5d8d4 100644 --- a/tests/test_asyncio_fixture.py +++ b/tests/test_asyncio_fixture.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import asyncio from textwrap import dedent diff --git a/tests/test_asyncio_mark.py b/tests/test_asyncio_mark.py index 20ac173d..e22be989 100644 --- a/tests/test_asyncio_mark.py +++ b/tests/test_asyncio_mark.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/test_dependent_fixtures.py b/tests/test_dependent_fixtures.py index dc70fe9c..2e53700a 100644 --- a/tests/test_dependent_fixtures.py +++ b/tests/test_dependent_fixtures.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import asyncio import pytest diff --git a/tests/test_doctest.py b/tests/test_doctest.py index 3795a4d7..d175789e 100644 --- a/tests/test_doctest.py +++ b/tests/test_doctest.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/test_event_loop_fixture.py b/tests/test_event_loop_fixture.py index aaf591c9..21785075 100644 --- a/tests/test_event_loop_fixture.py +++ b/tests/test_event_loop_fixture.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/test_event_loop_fixture_finalizer.py b/tests/test_event_loop_fixture_finalizer.py index 4306c33d..17cc85b9 100644 --- a/tests/test_event_loop_fixture_finalizer.py +++ b/tests/test_event_loop_fixture_finalizer.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/test_event_loop_fixture_override_deprecation.py b/tests/test_event_loop_fixture_override_deprecation.py index 683f0963..04859ef7 100644 --- a/tests/test_event_loop_fixture_override_deprecation.py +++ b/tests/test_event_loop_fixture_override_deprecation.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/test_explicit_event_loop_fixture_request.py b/tests/test_explicit_event_loop_fixture_request.py index 382fbf7c..c685ad84 100644 --- a/tests/test_explicit_event_loop_fixture_request.py +++ b/tests/test_explicit_event_loop_fixture_request.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/test_fixture_loop_scopes.py b/tests/test_fixture_loop_scopes.py index f0271e59..a9ce4b35 100644 --- a/tests/test_fixture_loop_scopes.py +++ b/tests/test_fixture_loop_scopes.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent import pytest diff --git a/tests/test_import.py b/tests/test_import.py index f1bf3caf..2272704a 100644 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/test_is_async_test.py b/tests/test_is_async_test.py index d69a54f6..f99dc0d9 100644 --- a/tests/test_is_async_test.py +++ b/tests/test_is_async_test.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/test_multiloop.py b/tests/test_multiloop.py index c3713cc9..e6c852b9 100644 --- a/tests/test_multiloop.py +++ b/tests/test_multiloop.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/test_port_factories.py b/tests/test_port_factories.py index cbbd47b4..713d747e 100644 --- a/tests/test_port_factories.py +++ b/tests/test_port_factories.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/test_simple.py b/tests/test_simple.py index c40a6809..b8a34fb2 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -1,5 +1,7 @@ """Quick'n'dirty unit tests for provided fixtures and markers.""" +from __future__ import annotations + import asyncio from textwrap import dedent @@ -75,8 +77,10 @@ class TestMarkerInClassBasedTests: @pytest.mark.asyncio async def test_asyncio_marker_with_implicit_loop_fixture(self): - """Test the "asyncio" marker works on a method in - a class-based test with implicit loop fixture.""" + """ + Test the "asyncio" marker works on a method in + a class-based test with implicit loop fixture. + """ ret = await async_coro() assert ret == "ok" diff --git a/tests/test_skips.py b/tests/test_skips.py index 96582ac0..d32273cd 100644 --- a/tests/test_skips.py +++ b/tests/test_skips.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from textwrap import dedent from pytest import Pytester diff --git a/tests/test_subprocess.py b/tests/test_subprocess.py index 3d91e7b1..c32ba964 100644 --- a/tests/test_subprocess.py +++ b/tests/test_subprocess.py @@ -1,5 +1,7 @@ """Tests for using subprocesses in tests.""" +from __future__ import annotations + import asyncio.subprocess import sys diff --git a/tools/get-version.py b/tools/get-version.py index c29081b9..9d24b6a5 100644 --- a/tools/get-version.py +++ b/tools/get-version.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json import sys from importlib import metadata