Skip to content

mypy not recognizing valid arguments to namedtuple constructor #2852

Closed
@sjaensch

Description

@sjaensch
from collections import namedtuple

class Test(namedtuple('BaseNamedTuple', ('field1', 'field2'))):
    def __new__(cls, field1, field2, new_arg):
        print('new_arg = ', new_arg)
        return super().__new__(cls, field1, field2)


Test(field1=1, field2=2, new_arg=False)

mypy error: Unexpected keyword argument "new_arg" for "Test"

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions