Skip to content

Overriding methods on NamedTuple does not work #934

@ndmitchell

Description

@ndmitchell

Describe the Bug

from typing import *

class ReadWrites(NamedTuple):
    field: int

    def __iter__(self) -> Iterator[str]:
        ...

def f(rw: ReadWrites):
    for k in rw:
        reveal_type(k) # reveals int, but should reveal str

Sandbox Link

https://pyrefly.org/sandbox/?code=GYJw9gtgBALgngBwJYDsDmUkQWEMoBUAUEQMYA2AhgM7VQBKAppQCYDqISMj1AFAHKUIjFgBUArgnKMAlAC4iUJVGBJG5FnMwoYJZVBaNgUAPomujEGd7V1wGVAC0APigBJbiEoxcAbWowIAC6Cvr6AHSRJIbGwLwgAO5aTKwcFtTyisrAuFAA1tpQiaFhSiCMAG7M5CbwCIy8eTJEQA&version=3.12

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions