From 56d557bbcd326d7d7bfe3590de8bf27b366680c8 Mon Sep 17 00:00:00 2001 From: Debjyoti Biswas <45293921+lladhibhutall@users.noreply.github.com> Date: Mon, 23 Mar 2020 00:20:48 +0530 Subject: [PATCH] Add support for PathLike to mimetypes.guess_types() (#3874) --- stdlib/2and3/mimetypes.pyi | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/stdlib/2and3/mimetypes.pyi b/stdlib/2and3/mimetypes.pyi index eb8302796..0d5a528d0 100644 --- a/stdlib/2and3/mimetypes.pyi +++ b/stdlib/2and3/mimetypes.pyi @@ -1,10 +1,16 @@ # Stubs for mimetypes -from typing import Dict, IO, List, Optional, Sequence, Text, Tuple +from typing import Dict, IO, List, Optional, Sequence, Text, Tuple, AnyStr, Union import sys -def guess_type(url: Text, - strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... +if sys.version_info >= (3, 8): + from os import PathLike + def guess_type(url: Union[Text, PathLike[str]], + strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... +else: + def guess_type(url: Text, + strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... + def guess_all_extensions(type: str, strict: bool = ...) -> List[str]: ... def guess_extension(type: str, strict: bool = ...) -> Optional[str]: ...