Skip to content

Commit ceaa59c

Browse files
committed
Rearrange for better inference
1 parent 71d47f3 commit ceaa59c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

trio_typing/plugin.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,15 +453,16 @@ def start_soon(
453453
454454
"""
455455
try:
456+
if not ctx.arg_types or len(ctx.arg_types[0]) != 1:
457+
raise ValueError("must be used as a decorator")
458+
459+
fn_type = get_proper_type(ctx.arg_types[0][0])
456460
if (
457-
not ctx.arg_types
458-
or len(ctx.arg_types[0]) != 1
459-
or not isinstance(get_proper_type(ctx.arg_types[0][0]), CallableType)
461+
not isinstance(fn_type, CallableType)
460462
or not isinstance(get_proper_type(ctx.default_return_type), CallableType)
461463
):
462464
raise ValueError("must be used as a decorator")
463465

464-
fn_type = get_proper_type(ctx.arg_types[0][0]) # type: CallableType
465466
callable_idx = -1 # index in function arguments of the callable
466467
callable_args_idx = -1 # index in callable arguments of the StarArgs
467468
callable_ty = None # type: Optional[CallableType]

0 commit comments

Comments
 (0)