load*: Return Any instead of Dict-types (#4543)

A plist file can contain more object types than dictionaries.
This commit is contained in:
Nikolaus Waxweiler
2020-09-16 00:29:59 +01:00
committed by GitHub
parent 7409af9f79
commit d402f55334

View File

@@ -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):