Fix generic NamedTuple class pattern matching by paulorochaoliveira · Pull Request #21140 · python/mypy
Fixes #21050
Description
Preserve named tuple field information when matching against generic class-based NamedTuples.
This updates class-pattern narrowing so a generic named tuple type object is normalized to its named tuple instance fallback before pattern analysis. That keeps keyword field lookup on the named tuple instance type instead of the tuple alias form, so field names and concrete type arguments are preserved.
Tests
Added regressions for:
- generic
NamedTuplewithGeneric[T]syntax in match class patterns - PEP 695 generic
NamedTuplesyntax in match class patterns