Skip to content

Unable to use Unpack inside a Callable #16082

Closed
@shadycuz

Description

@shadycuz

Crash Report

I tried to use the Unpack inside of a callable.

Traceback

  File "mypy/semanal.py", line 808, in visit_func_def
  File "mypy/semanal.py", line 837, in analyze_func_def
  File "mypy/typeanal.py", line 865, in visit_callable_type
  File "mypy/typeanal.py", line 1391, in anal_array
  File "mypy/typeanal.py", line 1400, in anal_type
  File "mypy/types.py", line 1792, in accept
  File "mypy/typeanal.py", line 865, in visit_callable_type
  File "mypy/typeanal.py", line 1391, in anal_array
  File "mypy/typeanal.py", line 1400, in anal_type
  File "mypy/types.py", line 933, in accept
  File "mypy/typeanal.py", line 845, in visit_unpack_type
NotImplementedError


[6] Error running mypy in /workspaces/nvcloud: the mypy daemon crashed. This is probably a bug in mypy itself, see Output panel for details. The daemon will be restarted automatically.

To Reproduce

I tried to unpack a named tuple inside a callable.

class StackArgs(TypedDict):
    """The arguments that are passed to boto when creating or updating a stack.

    Args:
        StackName (str): The name of the stack to create, must be unique within the region.
        Capabilities (Sequence[CapabilityType]): A list of capabilities that the stack is granted.
        TemplateBody (Optional[str], optional): The Cloudformation template as a str. Defaults to None.
        TemplateURL (Optional[str], optional): A URL to the Cloudformation template. Defaults to None.
        Parameters (Optional[Sequence[ParameterTypeDef]], optional): The parameters to use when createing the stack.
        Defaults to None.
        Tags (Optional[Sequence[TagTypeDef]], optional): The tags to apply to the stack, which will get applied
        to all resources created by the stack. Defaults to None.
        EnableTerminationProtection (bool, optional): If enabled the stack is unable to be deleted until its removed.
        Defaults to False.
    """

    StackName: str
    TemplateBody: NotRequired[str]
    TemplateURL: NotRequired[str]
    Parameters: NotRequired[Sequence["ParameterTypeDef"]]
    DisableRollback: NotRequired[bool]
    RollbackConfiguration: NotRequired["RollbackConfigurationTypeDef"]
    TimeoutInMinutes: NotRequired[int]
    NotificationARNs: NotRequired[Sequence[str]]
    Capabilities: NotRequired[Sequence["CapabilityType"]]
    ResourceTypes: NotRequired[Sequence[str]]
    RoleARN: NotRequired[str]
    OnFailure: NotRequired["OnFailureType"]
    StackPolicyBody: NotRequired[str]
    StackPolicyURL: NotRequired[str]
    Tags: NotRequired[Sequence["TagTypeDef"]]
    ClientRequestToken: NotRequired[str]
    EnableTerminationProtection: NotRequired[bool]
    
class StackOperation(NamedTuple):
    name: str
    func: Callable[[Unpack[StackArgs]], "StackResource"]

Your Environment

  • Mypy version used: latest and 0.9X
  • Mypy command-line flags: None except path to file
  • Mypy configuration options from mypy.ini (and other config files): I have the experimental unpack feature turned on
  • Python version used: 3.10 and 11
  • Operating system and version: WSL

@ilevkivskyi

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions