Skip to content
42 changes: 39 additions & 3 deletions stdlib/_csv.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,45 @@ class _writer:
def writerow(self, row: Iterable[Any]) -> Any: ...
def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ...

def writer(csvfile: SupportsWrite[str], dialect: _DialectLike = ..., **fmtparams: Any) -> _writer: ...
def reader(csvfile: Iterable[str], dialect: _DialectLike = ..., **fmtparams: Any) -> _reader: ...
def register_dialect(name: str, dialect: Any = ..., **fmtparams: Any) -> None: ...
def writer(
csvfile: SupportsWrite[str],
dialect: _DialectLike = ...,
*,
delimiter: str = ...,
quotechar: str | None = ...,
escapechar: str | None = ...,
doublequote: bool = ...,
skipinitialspace: bool = ...,
lineterminator: str = ...,
quoting: _QuotingType = ...,
strict: bool = ...,
) -> _writer: ...
def reader(
csvfile: Iterable[str],
dialect: _DialectLike = ...,
*,
delimiter: str = ...,
quotechar: str | None = ...,
escapechar: str | None = ...,
doublequote: bool = ...,
skipinitialspace: bool = ...,
lineterminator: str = ...,
quoting: _QuotingType = ...,
strict: bool = ...,
) -> _reader: ...
def register_dialect(
name: str,
dialect: Any = ...,
*,
delimiter: str = ...,
quotechar: str | None = ...,
escapechar: str | None = ...,
doublequote: bool = ...,
skipinitialspace: bool = ...,
lineterminator: str = ...,
quoting: _QuotingType = ...,
strict: bool = ...,
) -> None: ...
def unregister_dialect(name: str) -> None: ...
def get_dialect(name: str) -> Dialect: ...
def list_dialects() -> list[str]: ...
Expand Down
33 changes: 27 additions & 6 deletions stdlib/csv.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,15 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]):
restkey: str | None = ...,
restval: str | None = ...,
dialect: _DialectLike = ...,
*args: Any,
**kwds: Any,
*,
delimiter: str = ...,
quotechar: str | None = ...,
escapechar: str | None = ...,
doublequote: bool = ...,
skipinitialspace: bool = ...,
lineterminator: str = ...,
quoting: _QuotingType = ...,
strict: bool = ...,
) -> None: ...
@overload
def __init__(
Expand All @@ -102,8 +109,15 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]):
restkey: str | None = ...,
restval: str | None = ...,
dialect: _DialectLike = ...,
*args: Any,
**kwds: Any,
*,
delimiter: str = ...,
quotechar: str | None = ...,
escapechar: str | None = ...,
doublequote: bool = ...,
skipinitialspace: bool = ...,
lineterminator: str = ...,
quoting: _QuotingType = ...,
strict: bool = ...,
) -> None: ...
def __iter__(self: Self) -> Self: ...
def __next__(self) -> _DictReadMapping[_T, str]: ...
Expand All @@ -120,8 +134,15 @@ class DictWriter(Generic[_T]):
restval: Any | None = ...,
extrasaction: Literal["raise", "ignore"] = ...,
dialect: _DialectLike = ...,
*args: Any,
**kwds: Any,
*,
delimiter: str = ...,
quotechar: str | None = ...,
escapechar: str | None = ...,
doublequote: bool = ...,
skipinitialspace: bool = ...,
lineterminator: str = ...,
quoting: _QuotingType = ...,
strict: bool = ...,
) -> None: ...
if sys.version_info >= (3, 8):
def writeheader(self) -> Any: ...
Expand Down
2 changes: 2 additions & 0 deletions tests/stubtest_allowlists/py3_common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ csv.Dialect.doublequote
csv.Dialect.lineterminator
csv.Dialect.quoting
csv.Dialect.skipinitialspace
csv.DictReader.__init__ # runtime sig has *args but will error if more than 5 positional args are supplied
csv.DictWriter.__init__ # runtime sig has *args but will error if more than 5 positional args are supplied
ctypes.Array.__iter__ # mypy doesn't support using __getitem__ instead of __iter__ so this is here https://github.com/python/mypy/issues/2220
ctypes.Array._type_ # _type_ and _length_ are abstract, https://github.com/python/typeshed/pull/6361
ctypes.Array._length_
Expand Down