cgi: various improvements (#3790)

- add max_num_fields to FieldStorage
- fix various types based on default values
This commit is contained in:
Shantanu
2020-02-29 05:18:06 -08:00
committed by GitHub
parent e4b4cd99c0
commit 558d88ef92
5 changed files with 10 additions and 12 deletions

View File

@@ -3,7 +3,7 @@ from typing import Any, AnyStr, Dict, IO, Iterable, List, Mapping, Optional, Tup
_T = TypeVar('_T', bound=FieldStorage)
def parse(fp: IO[Any] = ..., environ: Mapping[str, str] = ...,
def parse(fp: Optional[IO[Any]] = ..., environ: Mapping[str, str] = ...,
keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ...
if sys.version_info < (3, 8):
def parse_qs(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ...
@@ -12,7 +12,7 @@ if sys.version_info >= (3, 7):
def parse_multipart(fp: IO[Any], pdict: Mapping[str, bytes], encoding: str = ..., errors: str = ...) -> Dict[str, List[Any]]: ...
else:
def parse_multipart(fp: IO[Any], pdict: Mapping[str, bytes]) -> Dict[str, List[bytes]]: ...
def parse_header(s: str) -> Tuple[str, Dict[str, str]]: ...
def parse_header(line: str) -> Tuple[str, Dict[str, str]]: ...
def test(environ: Mapping[str, str] = ...) -> None: ...
def print_environ(environ: Mapping[str, str] = ...) -> None: ...
def print_form(form: Dict[str, Any]) -> None: ...
@@ -21,7 +21,7 @@ def print_environ_usage() -> None: ...
if sys.version_info < (3,):
def escape(s: AnyStr, quote: bool = ...) -> AnyStr: ...
elif sys.version_info < (3, 8):
def escape(s: str, quote: bool = ...) -> str: ...
def escape(s: str, quote: Optional[bool] = ...) -> str: ...
class MiniFieldStorage:
# The first five "Any" attributes here are always None, but mypy doesn't support that
@@ -64,10 +64,14 @@ class FieldStorage(object):
list: Optional[List[Any]]
value: Union[None, bytes, List[Any]]
if sys.version_info >= (3, 0):
def __init__(self, fp: IO[Any] = ..., headers: Mapping[str, str] = ..., outerboundary: bytes = ...,
if sys.version_info >= (3, 6):
def __init__(self, fp: Optional[IO[Any]] = ..., headers: Optional[Mapping[str, str]] = ..., outerboundary: bytes = ...,
environ: Mapping[str, str] = ..., keep_blank_values: int = ..., strict_parsing: int = ...,
limit: int = ..., encoding: str = ..., errors: str = ...) -> None: ...
limit: Optional[int] = ..., encoding: str = ..., errors: str = ..., max_num_fields: Optional[int] = ...) -> None: ...
elif sys.version_info >= (3, 0):
def __init__(self, fp: Optional[IO[Any]] = ..., headers: Optional[Mapping[str, str]] = ..., outerboundary: bytes = ...,
environ: Mapping[str, str] = ..., keep_blank_values: int = ..., strict_parsing: int = ...,
limit: Optional[int] = ..., encoding: str = ..., errors: str = ...) -> None: ...
else:
def __init__(self, fp: IO[Any] = ..., headers: Mapping[str, str] = ..., outerboundary: bytes = ...,
environ: Mapping[str, str] = ..., keep_blank_values: int = ..., strict_parsing: int = ...) -> None: ...