mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-26 05:41:11 +08:00
make os.scandir work as a context manager (#1787)
Rework of #1583. Fixes #1573. See documentation in https://docs.python.org/3/library/os.html#os.scandir.
This commit is contained in:
committed by
Matthias Kramm
parent
2a30532f8d
commit
4ee508a032
@@ -6,7 +6,7 @@ from io import TextIOWrapper as _TextIOWrapper
|
||||
import sys
|
||||
from typing import (
|
||||
Mapping, MutableMapping, Dict, List, Any, Tuple, IO, Iterable, Iterator, overload, Union, AnyStr,
|
||||
Optional, Generic, Set, Callable, Text, Sequence, NamedTuple, TypeVar
|
||||
Optional, Generic, Set, Callable, Text, Sequence, NamedTuple, TypeVar, ContextManager
|
||||
)
|
||||
from . import path as path
|
||||
from mypy_extensions import NoReturn
|
||||
@@ -487,10 +487,12 @@ if sys.version_info >= (3, 3):
|
||||
else:
|
||||
def rmdir(path: _PathType) -> None: ...
|
||||
if sys.version_info >= (3, 6):
|
||||
class _ScandirIterator(Iterator[DirEntry[AnyStr]], ContextManager[_ScandirIterator[AnyStr]]):
|
||||
def close(self) -> None: ...
|
||||
@overload
|
||||
def scandir() -> Iterator[DirEntry[str]]: ...
|
||||
def scandir() -> _ScandirIterator[str]: ...
|
||||
@overload
|
||||
def scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> Iterator[DirEntry[AnyStr]]: ...
|
||||
def scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> _ScandirIterator[AnyStr]: ...
|
||||
elif sys.version_info >= (3, 5):
|
||||
@overload
|
||||
def scandir() -> Iterator[DirEntry[str]]: ...
|
||||
|
||||
Reference in New Issue
Block a user