Skip to content

Commit 8ac3e46

Browse files
authored
Add type annotations for Pathlike arguments (#3864)
* Add type annotations for Pathlike arguments * Add version checks * Change version * Change to PathLike
1 parent 66c20e6 commit 8ac3e46

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

stdlib/2and3/filecmp.pyi

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,29 @@
22
import sys
33
from typing import AnyStr, Callable, Dict, Generic, Iterable, List, Optional, Sequence, Tuple, Union, Text
44

5+
if sys.version_info >= (3, 6):
6+
from os import PathLike
7+
58
DEFAULT_IGNORES: List[str]
69

7-
def cmp(f1: Union[bytes, Text], f2: Union[bytes, Text], shallow: Union[int, bool] = ...) -> bool: ...
8-
def cmpfiles(a: AnyStr, b: AnyStr, common: Iterable[AnyStr],
9-
shallow: Union[int, bool] = ...) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ...
10+
if sys.version_info >= (3, 6):
11+
def cmp(f1: Union[bytes, Text, PathLike[AnyStr]], f2: Union[bytes, Text, PathLike[AnyStr]], shallow: Union[int, bool] = ...) -> bool: ...
12+
def cmpfiles(a: Union[AnyStr, PathLike[AnyStr]], b: Union[AnyStr, PathLike[AnyStr]], common: Iterable[AnyStr],
13+
shallow: Union[int, bool] = ...) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ...
14+
else:
15+
def cmp(f1: Union[bytes, Text], f2: Union[bytes, Text], shallow: Union[int, bool] = ...) -> bool: ...
16+
def cmpfiles(a: AnyStr, b: AnyStr, common: Iterable[AnyStr],
17+
shallow: Union[int, bool] = ...) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ...
1018

1119
class dircmp(Generic[AnyStr]):
12-
def __init__(self, a: AnyStr, b: AnyStr,
13-
ignore: Optional[Sequence[AnyStr]] = ...,
14-
hide: Optional[Sequence[AnyStr]] = ...) -> None: ...
20+
if sys.version_info >= (3, 6):
21+
def __init__(self, a: Union[AnyStr, PathLike[AnyStr]], b: Union[AnyStr, PathLike[AnyStr]],
22+
ignore: Optional[Sequence[AnyStr]] = ...,
23+
hide: Optional[Sequence[AnyStr]] = ...) -> None: ...
24+
else:
25+
def __init__(self, a: AnyStr, b: AnyStr,
26+
ignore: Optional[Sequence[AnyStr]] = ...,
27+
hide: Optional[Sequence[AnyStr]] = ...) -> None: ...
1528

1629
left: AnyStr
1730
right: AnyStr

0 commit comments

Comments
 (0)