def _find_parametrized_scope(argnames, arg2fixturedefs, indirect):
from _pytest.fixtures import scopes<EOL>if isinstance(indirect, (list, tuple)):<EOL><INDENT>all_arguments_are_fixtures = len(indirect) == len(argnames)<EOL><DEDENT>else:<EOL><INDENT>all_arguments_are_fixtures = bool(indirect)<EOL><DEDENT>if all_arguments_are_fixtures:<EOL><INDENT>fixturedefs = arg2fixturedefs or {}<EOL>used_scopes = [<EOL>fixturedef[<NUM_LIT:0>].scope<EOL>for name, fixturedef in fixturedefs.items()<EOL>if name in argnames<EOL>]<EOL>if used_scopes:<EOL><INDENT>for scope in reversed(scopes):<EOL><INDENT>if scope in used_scopes:<EOL><INDENT>return scope<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return "<STR_LIT>"<EOL>
Find the most appropriate scope for a parametrized call based on its arguments.

    When there's at least one direct argument, always use "function" scope.

    When a test function is parametrized and all its arguments are indirect
    (e.g. fixtures), return the most narrow scope based on the fixtures used.

    Related to issue #1832, based on code posted by @Kingdread.