| 938 | |
| 939 | |
| 940 | def _eval_scope_callable( |
| 941 | scope_callable: "Callable[[str, Config], _ScopeName]", |
| 942 | fixture_name: str, |
| 943 | config: Config, |
| 944 | ) -> "_ScopeName": |
| 945 | try: |
| 946 | # Type ignored because there is no typing mechanism to specify |
| 947 | # keyword arguments, currently. |
| 948 | result = scope_callable(fixture_name=fixture_name, config=config) # type: ignore[call-arg] |
| 949 | except Exception as e: |
| 950 | raise TypeError( |
| 951 | "Error evaluating {} while defining fixture '{}'.\n" |
| 952 | "Expected a function with the signature (*, fixture_name, config)".format( |
| 953 | scope_callable, fixture_name |
| 954 | ) |
| 955 | ) from e |
| 956 | if not isinstance(result, str): |
| 957 | fail( |
| 958 | "Expected {} to return a 'str' while defining fixture '{}', but it returned:\n" |
| 959 | "{!r}".format(scope_callable, fixture_name, result), |
| 960 | pytrace=False, |
| 961 | ) |
| 962 | return result |
| 963 | |
| 964 | |
| 965 | @final |