diff --git a/pytest_bdd/scenario.py b/pytest_bdd/scenario.py index b10606b..5299ea1 100644 --- a/pytest_bdd/scenario.py +++ b/pytest_bdd/scenario.py @@ -26,7 +26,7 @@ from .steps import get_step_fixture_name, inject_fixture from .utils import CONFIG_STACK, get_args, get_caller_module_locals, get_caller_module_path if typing.TYPE_CHECKING: - from typing import Any, Callable, Iterator + from typing import Any, Callable, Iterable from _pytest.mark.structures import ParameterSet @@ -179,7 +179,7 @@ def _get_scenario_decorator( # We need to tell pytest that the original function requires its fixtures, # otherwise indirect fixtures would not work. @pytest.mark.usefixtures(*func_args) - def scenario_wrapper(request: FixtureRequest, _pytest_bdd_example: dict[str, str]) -> Any | None: + def scenario_wrapper(request: FixtureRequest, _pytest_bdd_example: dict[str, str]) -> Any: scenario = templated_scenario.render(_pytest_bdd_example) _execute_scenario(feature, scenario, request) fixture_values = [request.getfixturevalue(arg) for arg in func_args] @@ -277,7 +277,7 @@ def make_string_literal(string: str) -> str: return "'{}'".format(string.replace("'", "\\'")) -def get_python_name_generator(name: str) -> Iterator[Iterator | Iterator[str]]: +def get_python_name_generator(name: str) -> Iterable[str]: """Generate a sequence of suitable python names out of given arbitrary string name.""" python_name = make_python_name(name) suffix = "" diff --git a/tests/feature/test_cucumber_json.py b/tests/feature/test_cucumber_json.py index 63262ed..7842da6 100644 --- a/tests/feature/test_cucumber_json.py +++ b/tests/feature/test_cucumber_json.py @@ -23,7 +23,7 @@ class OfType: def __init__(self, type: type = None) -> None: self.type = type - def __eq__(self, other: Union[int, str]) -> bool: + def __eq__(self, other: object) -> bool: return isinstance(other, self.type) if self.type else True diff --git a/tests/feature/test_report.py b/tests/feature/test_report.py index 9c6bcfd..fe8ea4c 100644 --- a/tests/feature/test_report.py +++ b/tests/feature/test_report.py @@ -14,7 +14,7 @@ class OfType: def __init__(self, type: type = None) -> None: self.type = type - def __eq__(self, other: float) -> bool: + def __eq__(self, other: object) -> bool: return isinstance(other, self.type) if self.type else True diff --git a/tests/utils.py b/tests/utils.py index 217a306..4ad5599 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -24,9 +24,9 @@ if PYTEST_6: errors: int = 0, xpassed: int = 0, xfailed: int = 0, - ) -> Any | None: + ) -> None: """Compatibility function for result.assert_outcomes""" - return result.assert_outcomes( + result.assert_outcomes( errors=errors, passed=passed, skipped=skipped, failed=failed, xpassed=xpassed, xfailed=xfailed ) @@ -34,15 +34,15 @@ else: def assert_outcomes( result: RunResult, - passed=0, - skipped=0, - failed=0, - errors=0, - xpassed=0, - xfailed=0, - ): + passed: int = 0, + skipped: int = 0, + failed: int = 0, + errors: int = 0, + xpassed: int = 0, + xfailed: int = 0, + ) -> None: """Compatibility function for result.assert_outcomes""" - return result.assert_outcomes( + result.assert_outcomes( error=errors, # Pytest < 6 uses the singular form passed=passed, skipped=skipped,