Skip to content

csv.DictReader and DictWriter not subscriptable at runtime #92391

Closed
@cdce8p

Description

@cdce8p

Feature or enhancement

Add PEP 585 style __class_getitem__ to csv.DictReader and csv.DictWriter.

Pitch

With PEP 585 most generic stdlib types are now subscriptable at runtime. Both DictReader and DictWriter are generic in typeshed but don't yet implement __class_getitem__.

from csv import DictWriter
from typing import IO

def f(fp: IO[str]) -> DictWriter[str]:
    return DictWriter(fp, ["id", "name"])

Previous discussion

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-typingtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions