`csv.DictReader` and `DictWriter` not subscriptable at runtime · Issue #92391 · python/cpython · GitHub
Skip to content

csv.DictReader and DictWriter not subscriptable at runtime #92391

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-typingtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions