mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
Update stub for csv (#1398)
This commit is contained in:
committed by
Matthias Kramm
parent
5d1aacfed3
commit
1c8498228d
@@ -1,84 +0,0 @@
|
||||
from typing import Any, Dict, Iterable, List, Sequence, Type, Union
|
||||
|
||||
# Public interface of _csv.reader's return type
|
||||
class _Reader(Iterable[List[str]]):
|
||||
dialect = ... # type: Dialect
|
||||
line_num = ... # type: int
|
||||
|
||||
def next(self) -> List[str]: ...
|
||||
|
||||
_Row = Sequence[Any] # May contain anything: csv calls str() on the elements that are not None
|
||||
|
||||
# Public interface of _csv.writer's return type
|
||||
class _Writer:
|
||||
dialect = ... # type: Dialect
|
||||
|
||||
def writerow(self, row: _Row) -> None: ...
|
||||
def writerows(self, rows: Iterable[_Row]) -> None: ...
|
||||
|
||||
QUOTE_ALL = ... # type: int
|
||||
QUOTE_MINIMAL = ... # type: int
|
||||
QUOTE_NONE = ... # type: int
|
||||
QUOTE_NONNUMERIC = ... # type: int
|
||||
|
||||
class Error(Exception): ...
|
||||
|
||||
_Dialect = Union[str, Dialect, Type[Dialect]]
|
||||
|
||||
def writer(csvfile: Any, dialect: _Dialect = ..., **fmtparams) -> _Writer: ...
|
||||
def reader(csvfile: Iterable[str], dialect: _Dialect = ..., **fmtparams) -> _Reader: ...
|
||||
def register_dialect(name, dialect=..., **fmtparams): ...
|
||||
def unregister_dialect(name): ...
|
||||
def get_dialect(name: str) -> Dialect: ...
|
||||
def list_dialects(): ...
|
||||
def field_size_limit(new_limit: int = ...) -> int: ...
|
||||
|
||||
class Dialect:
|
||||
delimiter = ... # type: str
|
||||
quotechar = ... # type: str
|
||||
escapechar = ... # type: str
|
||||
doublequote = ... # type: bool
|
||||
skipinitialspace = ... # type: bool
|
||||
lineterminator = ... # type: str
|
||||
quoting = ... # type: int
|
||||
def __init__(self) -> None: ...
|
||||
|
||||
class excel(Dialect):
|
||||
pass
|
||||
|
||||
class excel_tab(excel):
|
||||
pass
|
||||
|
||||
class unix_dialect(Dialect):
|
||||
pass
|
||||
|
||||
class DictReader(Iterable):
|
||||
restkey = ... # type: Any
|
||||
restval = ... # type: Any
|
||||
reader = ... # type: Any
|
||||
dialect = ... # type: _Dialect
|
||||
line_num = ... # type: int
|
||||
fieldnames = ... # type: Sequence[Any]
|
||||
def __init__(self, f: Iterable[str], fieldnames: Sequence[Any] = ..., restkey=...,
|
||||
restval=..., dialect: _Dialect = ..., *args, **kwds) -> None: ...
|
||||
def __iter__(self): ...
|
||||
def next(self): ...
|
||||
|
||||
_DictRow = Dict[Any, Union[str, int]]
|
||||
|
||||
class DictWriter:
|
||||
fieldnames = ... # type: Any
|
||||
restval = ... # type: Any
|
||||
extrasaction = ... # type: Any
|
||||
writer = ... # type: Any
|
||||
def __init__(self, f: Any, fieldnames: Sequence[Any], restval=..., extrasaction: str = ...,
|
||||
dialect: _Dialect = ..., *args, **kwds) -> None: ...
|
||||
def writeheader(self) -> None: ...
|
||||
def writerow(self, rowdict: _DictRow) -> None: ...
|
||||
def writerows(self, rowdicts: Iterable[_DictRow]) -> None: ...
|
||||
|
||||
class Sniffer:
|
||||
preferred = ... # type: Any
|
||||
def __init__(self) -> None: ...
|
||||
def sniff(self, sample: str, delimiters: str = ...) -> Dialect: ...
|
||||
def has_header(self, sample: str) -> bool: ...
|
||||
45
stdlib/2and3/_csv.pyi
Normal file
45
stdlib/2and3/_csv.pyi
Normal file
@@ -0,0 +1,45 @@
|
||||
import sys
|
||||
|
||||
from typing import Any, Iterable, Iterator, List, Optional, Sequence
|
||||
|
||||
QUOTE_ALL = ... # type: int
|
||||
QUOTE_MINIMAL = ... # type: int
|
||||
QUOTE_NONE = ... # type: int
|
||||
QUOTE_NONNUMERIC = ... # type: int
|
||||
|
||||
class Error(Exception): ...
|
||||
|
||||
class Dialect:
|
||||
delimiter = ... # type: str
|
||||
quotechar = ... # type: Optional[str]
|
||||
escapechar = ... # type: Optional[str]
|
||||
doublequote = ... # type: bool
|
||||
skipinitialspace = ... # type: bool
|
||||
lineterminator = ... # type: str
|
||||
quoting = ... # type: int
|
||||
strict = ... # type: int
|
||||
def __init__(self) -> None: ...
|
||||
|
||||
class _reader(Iterator[List[str]]):
|
||||
dialect = ... # type: Dialect
|
||||
line_num = ... # type: int
|
||||
|
||||
class _writer:
|
||||
dialect = ... # type: Dialect
|
||||
|
||||
if sys.version_info >= (3, 5):
|
||||
def writerow(self, row: Iterable[Any]) -> None: ...
|
||||
def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ...
|
||||
else:
|
||||
def writerow(self, row: Sequence[Any]) -> None: ...
|
||||
def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ...
|
||||
|
||||
|
||||
# TODO: precise type
|
||||
def writer(csvfile: Any, dialect: Any = ..., **fmtparams: Any) -> _writer: ...
|
||||
def reader(csvfile: Iterator[str], dialect: Any = ..., **fmtparams: Any) -> _reader: ...
|
||||
def register_dialect(name: str, dialect: Any = ..., **fmtparams: Any) -> None: ...
|
||||
def unregister_dialect(name: str) -> None: ...
|
||||
def get_dialect(name: str) -> Dialect: ...
|
||||
def list_dialects() -> List[str]: ...
|
||||
def field_size_limit(new_limit: int = ...) -> int: ...
|
||||
73
stdlib/2and3/csv.pyi
Normal file
73
stdlib/2and3/csv.pyi
Normal file
@@ -0,0 +1,73 @@
|
||||
from collections import OrderedDict
|
||||
import sys
|
||||
from typing import Any, Dict, Iterable, Iterator, List, Optional, Sequence, Union
|
||||
|
||||
from _csv import _reader, _writer, reader as reader, writer as writer, register_dialect as register_dialect, unregister_dialect as unregister_dialect, get_dialect as get_dialect, list_dialects as list_dialects, field_size_limit as field_size_limit, QUOTE_ALL as QUOTE_ALL, QUOTE_MINIMAL as QUOTE_MINIMAL, QUOTE_NONE as QUOTE_NONE, QUOTE_NONNUMERIC as QUOTE_NONNUMERIC, Error as Error
|
||||
|
||||
_Dialect = Union[str, Dialect]
|
||||
_DictRow = Dict[str, Any]
|
||||
|
||||
class Dialect:
|
||||
delimiter = ... # type: str
|
||||
quotechar = ... # type: Optional[str]
|
||||
escapechar = ... # type: Optional[str]
|
||||
doublequote = ... # type: bool
|
||||
skipinitialspace = ... # type: bool
|
||||
lineterminator = ... # type: str
|
||||
quoting = ... # type: int
|
||||
def __init__(self) -> None: ...
|
||||
|
||||
class excel(Dialect):
|
||||
delimiter = ... # type: str
|
||||
quotechar = ... # type: str
|
||||
doublequote = ... # type: bool
|
||||
skipinitialspace = ... # type: bool
|
||||
lineterminator = ... # type: str
|
||||
quoting = ... # type: int
|
||||
|
||||
class excel_tab(excel):
|
||||
delimiter = ... # type: str
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
class unix_dialect(Dialect):
|
||||
delimiter = ... # type: str
|
||||
quotechar = ... # type: str
|
||||
doublequote = ... # type: bool
|
||||
skipinitialspace = ... # type: bool
|
||||
lineterminator = ... # type: str
|
||||
quoting = ... # type: int
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
class DictReader(Iterator[OrderedDict[str, str]]):
|
||||
restkey = ... # type: Optional[str]
|
||||
restval = ... # type: Optional[str]
|
||||
reader = ... # type: _reader
|
||||
dialect = ... # type: _Dialect
|
||||
line_num = ... # type: int
|
||||
fieldnames = ... # type: Sequence[str]
|
||||
def __init__(self, f: Iterator[str], fieldnames: Sequence[str] = ..., restkey: Optional[str] = ..., restval: Optional[str] = ..., dialect: _Dialect = ..., *args: Any, **kwds: Any) -> None: ...
|
||||
else:
|
||||
class DictReader(Iterator[Dict[str, str]]):
|
||||
restkey = ... # type: Optional[str]
|
||||
restval = ... # type: Optional[str]
|
||||
reader = ... # type: _reader
|
||||
dialect = ... # type: _Dialect
|
||||
line_num = ... # type: int
|
||||
fieldnames = ... # type: Sequence[str]
|
||||
def __init__(self, f: Iterator[str], fieldnames: Sequence[str] = ..., restkey: Optional[str] = ..., restval: Optional[str] = ..., dialect: _Dialect = ..., *args: Any, **kwds: Any) -> None: ...
|
||||
|
||||
class DictWriter:
|
||||
fieldnames = ... # type: Sequence[str]
|
||||
restval = ... # type: Optional[Any]
|
||||
extrasaction = ... # type: str
|
||||
writer = ... # type: _writer
|
||||
def __init__(self, f: Any, fieldnames: Sequence[str], restval: Optional[Any], extrasaction: str = ..., dialect: _Dialect = ..., *args: Any, **kwds: Any) -> None: ...
|
||||
def writeheader(self) -> None: ...
|
||||
def writerow(self, rowdict: _DictRow) -> None: ...
|
||||
def writerows(self, rowdicts: Iterable[_DictRow]) -> None: ...
|
||||
|
||||
class Sniffer:
|
||||
preferred = ... # type: List[str]
|
||||
def __init__(self) -> None: ...
|
||||
def sniff(self, sample: str, delimiters: Optional[str] = ...) -> Dialect: ...
|
||||
def has_header(self, sample: str) -> bool: ...
|
||||
@@ -1,73 +0,0 @@
|
||||
from typing import Any, Iterable
|
||||
|
||||
QUOTE_ALL = ... # type: int
|
||||
QUOTE_MINIMAL = ... # type: int
|
||||
QUOTE_NONE = ... # type: int
|
||||
QUOTE_NONNUMERIC = ... # type: int
|
||||
|
||||
class Error(Exception): ...
|
||||
|
||||
def writer(csvfile, dialect=..., **fmtparams): ...
|
||||
def reader(csvfile, dialect=..., **fmtparams): ...
|
||||
def register_dialect(name, dialect=..., **fmtparams): ...
|
||||
def unregister_dialect(name): ...
|
||||
def get_dialect(name): ...
|
||||
def list_dialects(): ...
|
||||
def field_size_limit(new_limit=...): ...
|
||||
|
||||
class Dialect:
|
||||
delimiter = ... # type: Any
|
||||
quotechar = ... # type: Any
|
||||
escapechar = ... # type: Any
|
||||
doublequote = ... # type: Any
|
||||
skipinitialspace = ... # type: Any
|
||||
lineterminator = ... # type: Any
|
||||
quoting = ... # type: Any
|
||||
def __init__(self) -> None: ...
|
||||
|
||||
class excel(Dialect):
|
||||
delimiter = ... # type: Any
|
||||
quotechar = ... # type: Any
|
||||
doublequote = ... # type: Any
|
||||
skipinitialspace = ... # type: Any
|
||||
lineterminator = ... # type: Any
|
||||
quoting = ... # type: Any
|
||||
|
||||
class excel_tab(excel):
|
||||
delimiter = ... # type: Any
|
||||
|
||||
class unix_dialect(Dialect):
|
||||
delimiter = ... # type: Any
|
||||
quotechar = ... # type: Any
|
||||
doublequote = ... # type: Any
|
||||
skipinitialspace = ... # type: Any
|
||||
lineterminator = ... # type: Any
|
||||
quoting = ... # type: Any
|
||||
|
||||
class DictReader(Iterable):
|
||||
restkey = ... # type: Any
|
||||
restval = ... # type: Any
|
||||
reader = ... # type: Any
|
||||
dialect = ... # type: Any
|
||||
line_num = ... # type: Any
|
||||
fieldnames = ... # type: Any # Actually a property
|
||||
def __init__(self, f, fieldnames=..., restkey=..., restval=..., dialect=...,
|
||||
*args, **kwds): ...
|
||||
def __iter__(self): ...
|
||||
def __next__(self): ...
|
||||
|
||||
class DictWriter:
|
||||
fieldnames = ... # type: Any
|
||||
restval = ... # type: Any
|
||||
extrasaction = ... # type: Any
|
||||
writer = ... # type: Any
|
||||
def __init__(self, f, fieldnames, restval=..., extrasaction=..., dialect=..., *args, **kwds) -> None: ...
|
||||
def writeheader(self): ...
|
||||
def writerow(self, rowdict): ...
|
||||
def writerows(self, rowdicts): ...
|
||||
|
||||
class Sniffer:
|
||||
preferred = ... # type: Any
|
||||
def __init__(self) -> None: ...
|
||||
def sniff(self, sample, delimiters=...): ...
|
||||
def has_header(self, sample): ...
|
||||
Reference in New Issue
Block a user