Skip to content

Erroneous 'Too many arguments' error #4997

Closed
@willmcgugan

Description

@willmcgugan

It appears as though mypy treats argument unpacking as containing at least one element. Here's an example:

from typing import List

class Foo:
    pass

args: List[str] = []
packet = Foo(*args)
tbug.py:7: error: Too many arguments for "Foo"

I guess Mypy is assuming that you would never unpack zero arguments.

In my particular case I have a registry of 'packet classes' and a dynamic number of arguments parsed from the network. Some of those packet classes legitimately have 0 parameters, and Mypy gives me an error about each of them.

Running mypy 0.600 with no other flags.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions