8000 GH-130798: Add type hints to pathlib.types by ap-- · Pull Request #131639 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-130798: Add type hints to pathlib.types #131639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
< 8000 /details-toggle>
Prev Previous commit
Next Next commit
Iterator type for .glob and .iterdir
  • Loading branch information
ap-- committed Mar 24, 2025
commit 310c245d8bda2b414333bc0674140a456d40e88f
6 changes: 3 additions & 3 deletions Lib/pathlib/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pathlib._os import magic_open, ensure_distinct_paths, ensure_different_files, copyfileobj
from pathlib import PurePath, Path
from typing import (
Any, BinaryIO, Callable, Generator, Optional, Protocol, Sequence, TypeVar, Union,
Any, BinaryIO, Callable, Generator, Iterator, Optional, Protocol, Sequence, TypeVar, Union,
runtime_checkable,
)

Expand Down Expand Up @@ -283,15 +283,15 @@ def read_text(
return f.read()

@abstractmethod
def iterdir(self: _RP) -> Generator[_RP, None, None]:
def iterdir(self: _RP) -> Iterator[_RP]:
"""Yield path objects of the directory contents.

The children are yielded in arbitrary order, and the
special entries '.' and '..' are not included.
"""
raise NotImplementedError

def glob(self: _RP, pattern: Union[_RP, str], *, recurse_symlinks: bool = True) -> Generator[_RP, None, None]:
def glob(self: _RP, pattern: Union[_RP, str], *, recurse_symlinks: bool = True) -> Iterator[_RP]:
"""Iterate over this subtree and yield all existing files (of any
kind, including directories) matching the given relative pattern.
"""
Expand Down
Loading
0