From d402f5533405781de632cc4ba7327ee33b27ddd3 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler Date: Wed, 16 Sep 2020 00:29:59 +0100 Subject: [PATCH] load*: Return Any instead of Dict-types (#4543) A plist file can contain more object types than dictionaries. --- stdlib/2and3/plistlib.pyi | 42 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/stdlib/2and3/plistlib.pyi b/stdlib/2and3/plistlib.pyi index 6a23e736d..3f462347b 100644 --- a/stdlib/2and3/plistlib.pyi +++ b/stdlib/2and3/plistlib.pyi @@ -9,29 +9,27 @@ if sys.version_info >= (3,): FMT_XML = PlistFormat.FMT_XML FMT_BINARY = PlistFormat.FMT_BINARY -mm = MutableMapping[str, Any] -_D = TypeVar("_D", bound=mm) _Path = Union[str, Text] if sys.version_info >= (3, 9): - @overload - def load(fp: IO[bytes], *, fmt: Optional[PlistFormat] = ...) -> DictT[str, Any]: ... - @overload - def load(fp: IO[bytes], *, fmt: Optional[PlistFormat] = ..., dict_type: Type[_D]) -> _D: ... - @overload - def loads(value: bytes, *, fmt: Optional[PlistFormat] = ...) -> DictT[str, Any]: ... - @overload - def loads(value: bytes, *, fmt: Optional[PlistFormat] = ..., dict_type: Type[_D]) -> _D: ... + def load(fp: IO[bytes], *, fmt: Optional[PlistFormat] = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... + def loads(value: bytes, *, fmt: Optional[PlistFormat] = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... elif sys.version_info >= (3, 4): - @overload - def load(fp: IO[bytes], *, fmt: Optional[PlistFormat] = ..., use_builtin_types: bool = ...) -> DictT[str, Any]: ... - @overload - def load(fp: IO[bytes], *, fmt: Optional[PlistFormat] = ..., use_builtin_types: bool = ..., dict_type: Type[_D]) -> _D: ... - @overload - def loads(value: bytes, *, fmt: Optional[PlistFormat] = ..., use_builtin_types: bool = ...) -> DictT[str, Any]: ... - @overload - def loads(value: bytes, *, fmt: Optional[PlistFormat] = ..., use_builtin_types: bool = ..., dict_type: Type[_D]) -> _D: ... + def load( + fp: IO[bytes], + *, + fmt: Optional[PlistFormat] = ..., + use_builtin_types: bool = ..., + dict_type: Type[MutableMapping[str, Any]] = ..., + ) -> Any: ... + def loads( + value: bytes, + *, + fmt: Optional[PlistFormat] = ..., + use_builtin_types: bool = ..., + dict_type: Type[MutableMapping[str, Any]] = ..., + ) -> Any: ... if sys.version_info >= (3, 4): def dump( @@ -40,15 +38,15 @@ if sys.version_info >= (3, 4): def dumps(value: Mapping[str, Any], *, fmt: PlistFormat = ..., skipkeys: bool = ..., sort_keys: bool = ...) -> bytes: ... if sys.version_info < (3, 9): - def readPlist(pathOrFile: Union[_Path, IO[bytes]]) -> DictT[str, Any]: ... + def readPlist(pathOrFile: Union[_Path, IO[bytes]]) -> Any: ... def writePlist(value: Mapping[str, Any], pathOrFile: Union[_Path, IO[bytes]]) -> None: ... - def readPlistFromBytes(data: bytes) -> DictT[str, Any]: ... + def readPlistFromBytes(data: bytes) -> Any: ... def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... if sys.version_info < (3,): - def readPlistFromResource(path: _Path, restype: str = ..., resid: int = ...) -> DictT[str, Any]: ... + def readPlistFromResource(path: _Path, restype: str = ..., resid: int = ...) -> Any: ... def writePlistToResource(rootObject: Mapping[str, Any], path: _Path, restype: str = ..., resid: int = ...) -> None: ... - def readPlistFromString(data: str) -> DictT[str, Any]: ... + def readPlistFromString(data: str) -> Any: ... def writePlistToString(rootObject: Mapping[str, Any]) -> str: ... if sys.version_info < (3, 7):