Skip to content

collections.namedtuple: support passing typename and field_names by keyword argument #2549

@AlexWaygood

Description

@AlexWaygood

Pyright supports this, so ideally I think we would too (though mypy and pyrefly do not):

from collections import namedtuple

NT = namedtuple(typename="NT", field_names="x y")
NT(x=1, y=2)

Note that these can only be passed by keyword for collections.namedtuple, not for typing.NamedTuple.

Cc. @charliermarsh

Metadata

Metadata

Assignees

Labels

namedtuplesruntime semanticsAccurate modeling of how Python's semantics work at runtime

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions