Skip to content

Allow ParamSpec in NamedTuple and TypedDict#21044

Open
A5rocks wants to merge 1 commit intopython:masterfrom
A5rocks:paramspec-more-places
Open

Allow ParamSpec in NamedTuple and TypedDict#21044
A5rocks wants to merge 1 commit intopython:masterfrom
A5rocks:paramspec-more-places

Conversation

@A5rocks
Copy link
Collaborator

@A5rocks A5rocks commented Mar 19, 2026

Fixes #21039. These were TODOs and I'm not completely sure we should expose this, but obviously there's demand.

def __len__(self) -> int: ...
def count(self, obj: object) -> int: ...

class _ItemsView(Iterable[Tuple[KT, VT]]): ...
Copy link
Collaborator Author

@A5rocks A5rocks Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting this error:

  tmp/builtins.pyi:54: error: Class builtins._ItemsView has abstract attributes "__iter__" (diff)
  tmp/builtins.pyi:54: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metacl[snipped]

due to how full typing + this were interacting. I didn't feel like investigating, so I just inlined this type.

@A5rocks
Copy link
Collaborator Author

A5rocks commented Mar 19, 2026

Looks like a flakey test failure?

@github-actions
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Classes inheriting from NamedTuple can't have ParamSpec as generic type parameter

1 participant