Use conditional overloads to simplify several stdlib functions (#7540)

This commit is contained in:
Alex Waygood
2022-03-25 08:47:03 +01:00
committed by GitHub
parent b69d64df60
commit b63c963077
4 changed files with 21 additions and 36 deletions

View File

@@ -732,20 +732,15 @@ class _ScandirIterator(Iterator[DirEntry[AnyStr]], AbstractContextManager[_Scand
def __exit__(self, *args: object) -> None: ...
def close(self) -> None: ...
@overload
def scandir(path: None = ...) -> _ScandirIterator[str]: ...
if sys.version_info >= (3, 7):
@overload
def scandir(path: None = ...) -> _ScandirIterator[str]: ...
@overload
def scandir(path: int) -> _ScandirIterator[str]: ...
@overload
def scandir(path: AnyStr | PathLike[AnyStr]) -> _ScandirIterator[AnyStr]: ...
else:
@overload
def scandir(path: None = ...) -> _ScandirIterator[str]: ...
@overload
def scandir(path: AnyStr | PathLike[AnyStr]) -> _ScandirIterator[AnyStr]: ...
@overload
def scandir(path: AnyStr | PathLike[AnyStr]) -> _ScandirIterator[AnyStr]: ...
def stat(path: _FdOrAnyPath, *, dir_fd: int | None = ..., follow_symlinks: bool = ...) -> stat_result: ...
if sys.version_info < (3, 7):