# Path: pytest_bdd/parsers.py
# def get_parser(step_name: Any) -> StepParser:
#     """Get parser by given name."""
# 
#     if isinstance(step_name, StepParser):
#         return step_name
# 
#     return string(step_name)
# 
# Path: pytest_bdd/types.py
# GIVEN = "given"
# 
# THEN = "then"
# 
# WHEN = "when"
# 
# Path: pytest_bdd/utils.py
# def get_caller_module_locals(depth: int = 2) -> dict[str, Any]:
#     """Get the caller module locals dictionary.
# 
#     We use sys._getframe instead of inspect.stack(0) because the latter is way slower, since it iterates over
#     all the frames in the stack.
#     """
#     return _getframe(depth).f_locals


import typing
import pytest
from _pytest.fixtures import FixtureDef, FixtureRequest
from .parsers import get_parser
from .types import GIVEN, THEN, WHEN
from .utils import get_caller_module_locals
    from typing import Any, Callable
    :param target_fixture: Optional fixture name to replace by step definition

    :return: Decorator function for the step.
    """

    def decorator(func: Callable) -> Callable:
        step_func = func
        parser_instance = get_parser(step_name)
        parsed_step_name = parser_instance.name

        step_func.__name__ = str(parsed_step_name)

        def lazy_step_func() -> Callable:
            return step_func

        step_func.step_type = step_type
        lazy_step_func.step_type = step_type

        # Preserve the docstring
        lazy_step_func.__doc__ = func.__doc__

        step_func.parser = lazy_step_func.parser = parser_instance
        if converters:
            step_func.converters = lazy_step_func.converters = converters

        step_func.target_fixture = lazy_step_func.target_fixture = target_fixture

        lazy_step_func = pytest.fixture()(lazy_step_func)
        fixture_step_name = get_step_fixture_name(parsed_step_name, step_type)


# Path: pytest_bdd/parsers.py
# def get_parser(step_name: Any) -> StepParser:
#     """Get parser by given name."""
# 
#     if isinstance(step_name, StepParser):
#         return step_name
# 
#     return string(step_name)
# 
# Path: pytest_bdd/types.py
# GIVEN = "given"
# 
# THEN = "then"
# 
# WHEN = "when"
# 
# Path: pytest_bdd/utils.py
# def get_caller_module_locals(depth: int = 2) -> dict[str, Any]:
#     """Get the caller module locals dictionary.
# 
#     We use sys._getframe instead of inspect.stack(0) because the latter is way slower, since it iterates over
#     all the frames in the stack.
#     """
#     return _getframe(depth).f_locals


# Path: pytest_bdd/steps.py
import typing
import pytest
from _pytest.fixtures import FixtureDef, FixtureRequest
from .parsers import get_parser
from .types import GIVEN, THEN, WHEN
from .utils import get_caller_module_locals
    from typing import Any, Callable

    :param target_fixture: Optional fixture name to replace by step definition

    :return: Decorator function for the step.
    """

    def decorator(func: Callable) -> Callable:
        step_func = func
        parser_instance = get_parser(step_name)
        parsed_step_name = parser_instance.name

        step_func.__name__ = str(parsed_step_name)

        def lazy_step_func() -> Callable:
            return step_func

        step_func.step_type = step_type
        lazy_step_func.step_type = step_type

        # Preserve the docstring
        lazy_step_func.__doc__ = func.__doc__

        step_func.parser = lazy_step_func.parser = parser_instance
        if converters:
            step_func.converters = lazy_step_func.converters = converters

        step_func.target_fixture = lazy_step_func.target_fixture = target_fixture

        lazy_step_func = pytest.fixture()(lazy_step_func)
        fixture_step_name = get_step_fixture_name(parsed_step_name, step_type)


        caller_locals = get_caller_module_locals()