Files
typeshed/stdlib/csv.pyi
Akuli 24afb531ff stubtest_stdlib: get rid of --ignore-missing-stub (#6491)
* get rid of --ignore-missing-stub

* update allowlists based on github actions logs, with script

import re

platforms = ["linux", "win32", "darwin"]
versions = ["py36", "py37", "py38", "py39", "py310"]

entries_by_pv = {}
for p in platforms:
    for v in versions:
        p_name = {"linux": "ubuntu", "darwin": "macos", "win32": "windows"}[p]
        v_name = "3." + v.replace("py3", "")
        if v_name == "3.9":
            v_name = "3.9.7"

        entries = set()
        with open(f"la/Check stdlib with stubtest ({p_name}-latest, {v_name})/6_Run stubtest.txt") as file:
            for line in file:
                m = re.search(r"error: (.*) is not present in stub$", line.strip())
                if m:
                    entries.add(m.group(1))
        entries_by_pv[p, v] = entries

def remove_intersection(sets):
    sets = list(sets)
    result = set(sets[0])
    for s in sets[1:]:
        result &= s
    for s in sets:
        for r in result:
            s.remove(r)
    return result

common_to_all = remove_intersection(entries_by_pv.values())

common_to_version = {}
for v in versions:
    common_to_version[v] = remove_intersection([
        entries
        for (p, v2), entries in entries_by_pv.items()
        if v == v2
    ])

common_to_platform = {}
for p in platforms:
    common_to_platform[p] = remove_intersection([
        entries
        for (p2, v), entries in entries_by_pv.items()
        if p == p2
    ])

def write(fname, entries):
    with open(f"tests/stubtest_allowlists/{fname}.txt", "a") as file:
        file.write("\n# Exists at runtime, but missing from stubs\n")
        for i in sorted(entries):
            file.write(i + "\n")

write("py3_common", common_to_all)
for v, entries in common_to_version.items():
    write(v, entries)
for p, entries in common_to_platform.items():
    write(p, entries)
for (p, v), entries in entries_by_pv.items():
    write(p + "-" + v, entries)

* Manually combine __main__ attributes into a single entry

* move and comment entries manually
2021-12-04 16:58:44 -08:00

108 lines
2.8 KiB
Python

import sys
from _csv import (
QUOTE_ALL as QUOTE_ALL,
QUOTE_MINIMAL as QUOTE_MINIMAL,
QUOTE_NONE as QUOTE_NONE,
QUOTE_NONNUMERIC as QUOTE_NONNUMERIC,
Dialect as Dialect,
Error as Error,
_DialectLike,
_reader,
_writer,
field_size_limit as field_size_limit,
get_dialect as get_dialect,
list_dialects as list_dialects,
reader as reader,
register_dialect as register_dialect,
unregister_dialect as unregister_dialect,
writer as writer,
)
from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence
from typing import Any, Generic, Type, TypeVar, overload
if sys.version_info >= (3, 8):
from typing import Dict as _DictReadMapping
else:
from collections import OrderedDict as _DictReadMapping
_T = TypeVar("_T")
class excel(Dialect):
delimiter: str
quotechar: str
doublequote: bool
skipinitialspace: bool
lineterminator: str
quoting: int
class excel_tab(excel):
delimiter: str
class unix_dialect(Dialect):
delimiter: str
quotechar: str
doublequote: bool
skipinitialspace: bool
lineterminator: str
quoting: int
class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]):
fieldnames: Sequence[_T] | None
restkey: str | None
restval: str | None
reader: _reader
dialect: _DialectLike
line_num: int
@overload
def __init__(
self,
f: Iterable[str],
fieldnames: Sequence[_T],
restkey: str | None = ...,
restval: str | None = ...,
dialect: _DialectLike = ...,
*args: Any,
**kwds: Any,
) -> None: ...
@overload
def __init__(
self: DictReader[str],
f: Iterable[str],
fieldnames: Sequence[str] | None = ...,
restkey: str | None = ...,
restval: str | None = ...,
dialect: _DialectLike = ...,
*args: Any,
**kwds: Any,
) -> None: ...
def __iter__(self) -> DictReader[_T]: ...
def __next__(self) -> _DictReadMapping[_T, str]: ...
class DictWriter(Generic[_T]):
fieldnames: Collection[_T]
restval: Any | None
extrasaction: str
writer: _writer
def __init__(
self,
f: Any,
fieldnames: Collection[_T],
restval: Any | None = ...,
extrasaction: str = ...,
dialect: _DialectLike = ...,
*args: Any,
**kwds: Any,
) -> None: ...
if sys.version_info >= (3, 8):
def writeheader(self) -> Any: ...
else:
def writeheader(self) -> None: ...
def writerow(self, rowdict: Mapping[_T, Any]) -> Any: ...
def writerows(self, rowdicts: Iterable[Mapping[_T, Any]]) -> None: ...
class Sniffer(object):
preferred: list[str]
def __init__(self) -> None: ...
def sniff(self, sample: str, delimiters: str | None = ...) -> Type[Dialect]: ...
def has_header(self, sample: str) -> bool: ...