Use self-type for parent[s] properties too (#667)

This is possible now that python/mypy#2404 has landed.
This commit is contained in:
Guido van Rossum
2016-11-06 11:21:45 -08:00
committed by GitHub
parent 341c4edc37
commit 49a8a28c29

View File

@@ -10,8 +10,6 @@ class PurePath:
drive = ... # type: str
root = ... # type: str
anchor = ... # type: str
parents = ... # type: Sequence[PurePath]
parent = ... # type: PurePath
name = ... # type: str
suffix = ... # type: str
suffixes = ... # type: List[str]
@@ -33,6 +31,8 @@ class PurePath:
def with_name(self: _P, name: str) -> _P: ...
def with_suffix(self: _P, suffix: str) -> _P: ...
def joinpath(self: _P, *other: Union[str, PurePath]) -> _P: ...
def parents(self: _P) -> Sequence[_P]: ...
def parent(self: _P) -> _P: ...
class PurePosixPath(PurePath): ...
class PureWindowsPath(PurePath): ...
@@ -83,11 +83,6 @@ class Path(PurePath):
def write_text(self, data: str, encoding: Optional[str] = ...,
errors: Optional[str] = ...) -> int: ...
# The following are repeated here even though they only actually exist in the base
# class so that they return Path when used on a Path, rather than returning PurePath.
parents = ... # type: Sequence[Path]
parent = ... # type: Path
class PosixPath(Path, PurePosixPath): ...
class WindowsPath(Path, PureWindowsPath): ...