Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stdlib/imp.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import types
from _typeshed import StrPath
from os import PathLike
from typing import IO, Any, List, Optional, Protocol, Tuple, TypeVar, Union

from _imp import (
Expand Down Expand Up @@ -57,7 +57,7 @@ def load_module(name: str, file: Optional[_FileLike], filename: str, details: Tu

# IO[Any] is a TextIOWrapper if name is a .py file, and a FileIO otherwise.
def find_module(
name: str, path: Union[None, List[str], List[os.PathLike[str]], List[StrPath]] = ...
name: str, path: Union[None, List[str], List[PathLike[str]], List[StrPath]] = ...
) -> Tuple[IO[Any], str, Tuple[str, str, int]]: ...
def reload(module: types.ModuleType) -> types.ModuleType: ...
def init_builtin(name: str) -> Optional[types.ModuleType]: ...
Expand Down
15 changes: 8 additions & 7 deletions stdlib/importlib/metadata.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import abc
import os
import pathlib
import sys
from _typeshed import StrPath
from email.message import Message
from importlib.abc import MetaPathFinder
from os import PathLike
from pathlib import Path
from typing import Any, Dict, Iterable, List, NamedTuple, Optional, Tuple, Union, overload
from typing import Any, Dict, Iterable, List, NamedTuple, Optional, Tuple, overload

if sys.version_info >= (3, 8):
class PackageNotFoundError(ModuleNotFoundError): ...
Expand All @@ -20,7 +21,7 @@ if sys.version_info >= (3, 8):
class PackagePath(pathlib.PurePosixPath):
def read_text(self, encoding: str = ...) -> str: ...
def read_binary(self) -> bytes: ...
def locate(self) -> os.PathLike[str]: ...
def locate(self) -> PathLike[str]: ...
# The following attributes are not defined on PackagePath, but are dynamically added by Distribution.files:
hash: Optional[FileHash]
size: Optional[int]
Expand All @@ -33,7 +34,7 @@ if sys.version_info >= (3, 8):
@abc.abstractmethod
def read_text(self, filename: str) -> Optional[str]: ...
@abc.abstractmethod
def locate_file(self, path: Union[os.PathLike[str], str]) -> os.PathLike[str]: ...
def locate_file(self, path: StrPath) -> PathLike[str]: ...
@classmethod
def from_name(cls, name: str) -> Distribution: ...
@overload
Expand All @@ -45,7 +46,7 @@ if sys.version_info >= (3, 8):
cls, *, context: None = ..., name: Optional[str] = ..., path: List[str] = ..., **kwargs: Any
) -> Iterable[Distribution]: ...
@staticmethod
def at(path: Union[str, os.PathLike[str]]) -> PathDistribution: ...
def at(path: StrPath) -> PathDistribution: ...
@property
def metadata(self) -> Message: ...
@property
Expand All @@ -69,8 +70,8 @@ if sys.version_info >= (3, 8):
def find_distributions(cls, context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ...
class PathDistribution(Distribution):
def __init__(self, path: Path) -> None: ...
def read_text(self, filename: Union[str, os.PathLike[str]]) -> str: ...
def locate_file(self, path: Union[str, os.PathLike[str]]) -> os.PathLike[str]: ...
def read_text(self, filename: StrPath) -> str: ...
def locate_file(self, path: StrPath) -> PathLike[str]: ...
def distribution(distribution_name: str) -> Distribution: ...
@overload
def distributions(*, context: DistributionFinder.Context) -> Iterable[Distribution]: ...
Expand Down
6 changes: 3 additions & 3 deletions stdlib/importlib/util.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import importlib.abc
import importlib.machinery
import os
import types
from typing import Any, Callable, List, Optional, Union
from _typeshed import AnyPath
from typing import Any, Callable, List, Optional

def module_for_loader(fxn: Callable[..., types.ModuleType]) -> Callable[..., types.ModuleType]: ...
def set_loader(fxn: Callable[..., types.ModuleType]) -> Callable[..., types.ModuleType]: ...
Expand All @@ -20,7 +20,7 @@ def spec_from_loader(
) -> Optional[importlib.machinery.ModuleSpec]: ...
def spec_from_file_location(
name: str,
location: Optional[Union[str, bytes, os.PathLike[str], os.PathLike[bytes]]] = ...,
location: Optional[AnyPath] = ...,
*,
loader: Optional[importlib.abc.Loader] = ...,
submodule_search_locations: Optional[List[str]] = ...,
Expand Down
6 changes: 3 additions & 3 deletions stdlib/mimetypes.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import sys
from typing import IO, Dict, List, Optional, Sequence, Tuple, Union
from _typeshed import StrPath
from typing import IO, Dict, List, Optional, Sequence, Tuple

if sys.version_info >= (3, 8):
from os import PathLike
def guess_type(url: Union[str, PathLike[str]], strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ...
def guess_type(url: StrPath, strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ...

else:
def guess_type(url: str, strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ...
Expand Down
9 changes: 5 additions & 4 deletions stdlib/os/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ from _typeshed import (
OpenBinaryModeUpdating,
OpenBinaryModeWriting,
OpenTextMode,
StrPath,
)
from builtins import OSError
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper as _TextIOWrapper
Expand Down Expand Up @@ -367,8 +368,8 @@ if sys.platform != "win32":
f_namemax: int

# ----- os function stubs -----
def fsencode(filename: Union[str, bytes, PathLike[Any]]) -> bytes: ...
def fsdecode(filename: Union[str, bytes, PathLike[Any]]) -> str: ...
def fsencode(filename: AnyPath) -> bytes: ...
def fsdecode(filename: AnyPath) -> str: ...
@overload
def fspath(path: str) -> str: ...
@overload
Expand Down Expand Up @@ -687,7 +688,7 @@ if sys.platform != "win32":
if sys.version_info >= (3, 7):
@overload
def fwalk(
top: Union[str, PathLike[str]] = ...,
top: StrPath = ...,
topdown: bool = ...,
onerror: Optional[_OnError] = ...,
*,
Expand All @@ -705,7 +706,7 @@ if sys.platform != "win32":
) -> Iterator[Tuple[bytes, List[bytes], List[bytes], int]]: ...
else:
def fwalk(
top: Union[str, PathLike[str]] = ...,
top: StrPath = ...,
topdown: bool = ...,
onerror: Optional[_OnError] = ...,
*,
Expand Down
4 changes: 2 additions & 2 deletions stdlib/sqlite3/dbapi2.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import sys
from _typeshed import AnyPath
from datetime import date, datetime, time
from typing import Any, Callable, Generator, Iterable, Iterator, List, Optional, Protocol, Tuple, Type, TypeVar, Union

Expand Down Expand Up @@ -66,7 +66,7 @@ def complete_statement(sql: str) -> bool: ...

if sys.version_info >= (3, 7):
def connect(
database: Union[bytes, str, os.PathLike[str]],
database: AnyPath,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked.

timeout: float = ...,
detect_types: int = ...,
isolation_level: Optional[str] = ...,
Expand Down
4 changes: 2 additions & 2 deletions stdlib/tokenize.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from _typeshed import AnyPath
from builtins import open as _builtin_open
from os import PathLike
from token import * # noqa: F403
from typing import (
Any,
Expand Down Expand Up @@ -62,7 +62,7 @@ def untokenize(iterable: Iterable[_Token]) -> Any: ...
def detect_encoding(readline: Callable[[], bytes]) -> Tuple[str, Sequence[bytes]]: ...
def tokenize(readline: Callable[[], bytes]) -> Generator[TokenInfo, None, None]: ...
def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo, None, None]: ... # undocumented
def open(filename: Union[str, bytes, int, PathLike[Any]]) -> TextIO: ...
def open(filename: Union[AnyPath, int]) -> TextIO: ...
def group(*choices: str) -> str: ... # undocumented
def any(*choices: str) -> str: ... # undocumented
def maybe(*choices: str) -> str: ... # undocumented
Expand Down
4 changes: 2 additions & 2 deletions stdlib/urllib/request.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import ssl
import sys
from _typeshed import AnyPath
from email.message import Message
from http.client import HTTPMessage, HTTPResponse, _HTTPConnectionProtocol
from http.cookiejar import CookieJar
Expand Down Expand Up @@ -271,7 +271,7 @@ class HTTPErrorProcessor(BaseHandler):

def urlretrieve(
url: str,
filename: Optional[Union[str, os.PathLike[Any]]] = ...,
filename: Optional[AnyPath] = ...,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked as well. Works with bytes.

reporthook: Optional[Callable[[int, int, int], None]] = ...,
data: Optional[bytes] = ...,
) -> Tuple[str, HTTPMessage]: ...
Expand Down
6 changes: 3 additions & 3 deletions stdlib/zoneinfo/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import typing
from _typeshed import StrPath
from datetime import tzinfo
from typing import Any, AnyStr, Iterable, Optional, Protocol, Sequence, Set, Type, Union
from typing import Any, Iterable, Optional, Protocol, Sequence, Set, Type

_T = typing.TypeVar("_T", bound="ZoneInfo")

Expand All @@ -23,7 +23,7 @@ class ZoneInfo(tzinfo):
# Note: Both here and in clear_cache, the types allow the use of `str` where
# a sequence of strings is required. This should be remedied if a solution
# to this typing bug is found: https://github.com/python/typing/issues/256
def reset_tzpath(to: Optional[Sequence[Union[os.PathLike[AnyStr], str]]] = ...) -> None: ...
def reset_tzpath(to: Optional[Sequence[StrPath]] = ...) -> None: ...
def available_timezones() -> Set[str]: ...

TZPATH: Sequence[str]
Expand Down