Skip to content

False negative when NamedTuple subclass redefines field in covariant manner #5700

Closed as not planned

Description

The following currently type checks without error.

# pyright: strict
from typing import NamedTuple

class NT1(NamedTuple):
    number: float

class NT2(NT1):
    number: int

x1 = NT1(1.2)
x2 = NT2(1.2) # Should generate an error.

This is related to mypy issue python/mypy#8663.

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

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions