Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit99ddc67

Browse files
committed
ReplaceGenerator in type hints withIterator
1 parentb67e76f commit99ddc67

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

‎userland/core/io.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
importos
22
importsys
3-
fromtypingimportAny,Generator,IO
3+
fromtypingimportAny,IO,Iterator
44

55

66
defperror(*errors:Any)->None:
@@ -10,20 +10,20 @@ def perror(*errors: Any) -> None:
1010
)
1111

1212

13-
defreadwords_stdin()->Generator[str]:
13+
defreadwords_stdin()->Iterator[str]:
1414
forlineinsys.stdin:
1515
yieldfromline.split()
1616

1717

18-
defreadwords_stdin_raw()->Generator[bytes]:
18+
defreadwords_stdin_raw()->Iterator[bytes]:
1919
forlineinsys.stdin.buffer:
2020
yieldfromline.split()
2121

2222

2323
defget_lines_by_delimiter[T: (
2424
str,
2525
bytes,
26-
)](stream:IO[T],delimiter:T)->Generator[T]:
26+
)](stream:IO[T],delimiter:T)->Iterator[T]:
2727
joiner=type(delimiter)()
2828
line= []
2929

‎userland/core/paths.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
importsys
22
frompathlibimportPath
3-
fromtypingimportGenerator,Iterable,Literal
3+
fromtypingimportIterable,Iterator,Literal
44

55

66
deftraverse_files(
77
filenames:Iterable[str],
88
recurse_mode:Literal["L","H","P"]|None=None,
99
preserve_root:bool=False,
10-
)->Generator[Path|None]:
10+
)->Iterator[Path|None]:
1111
ifnotrecurse_mode:
1212
yieldfrommap(Path,filenames)
1313
return
1414

15-
deftraverse(file:Path)->Generator[Path]:
15+
deftraverse(file:Path)->Iterator[Path]:
1616
forchildinfile.iterdir():
1717
ifchild.is_dir(follow_symlinks=recurse_mode=="L"):
1818
yieldfromtraverse(child)

‎userland/utilities/cat.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
importitertools
22
importsys
33
fromioimportBufferedReader
4-
fromtypingimportGenerator,Iterable
4+
fromtypingimportIterable,Iterator
55

66
from ..importcore
77

88

9-
defsqueeze_blank_lines(stream:Iterable[bytes])->Generator[bytes]:
9+
defsqueeze_blank_lines(stream:Iterable[bytes])->Iterator[bytes]:
1010
was_blank=False
1111

1212
forlineinstream:
@@ -19,12 +19,12 @@ def squeeze_blank_lines(stream: Iterable[bytes]) -> Generator[bytes]:
1919
was_blank=is_blank
2020

2121

22-
defnumber_lines(stream:Iterable[bytes])->Generator[bytes]:
22+
defnumber_lines(stream:Iterable[bytes])->Iterator[bytes]:
2323
fori,_inenumerate(stream):
2424
yieldf"{i+1:>6} ".encode()
2525

2626

27-
defnumber_nonblank_lines(stream:Iterable[bytes])->Generator[bytes]:
27+
defnumber_nonblank_lines(stream:Iterable[bytes])->Iterator[bytes]:
2828
i=1
2929
forlineinstream:
3030
iflen(line)>1:
@@ -36,7 +36,7 @@ def number_nonblank_lines(stream: Iterable[bytes]) -> Generator[bytes]:
3636

3737
defformat_chars(
3838
data:bytes,show_ends:bool,show_tabs:bool,show_nonprinting:bool
39-
)->Generator[bytes]:
39+
)->Iterator[bytes]:
4040
fornindata:
4141
ifn==ord(b"\n"):
4242
ifshow_ends:
@@ -62,7 +62,7 @@ def format_chars(
6262
yieldn.to_bytes()
6363

6464

65-
defformat_lines(stream:Iterable[bytes],*args)->Generator[bytes]:
65+
defformat_lines(stream:Iterable[bytes],*args)->Iterator[bytes]:
6666
forlineinstream:
6767
yieldb"".join(format_chars(line,*args))
6868

‎userland/utilities/factor.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
importmath
2-
fromtypingimportGenerator,Iterable,cast
2+
fromtypingimportIterable,Iterator,cast
33

44
from ..importcore
55

@@ -50,7 +50,7 @@ def pollards_rho(n: int, /, step: int) -> int | None:
5050

5151
deffactorize(
5252
n:int,/,*,cache:dict[int,int]= {p:pforpinSMALL_PRIMES}
53-
)->Generator[int]:
53+
)->Iterator[int]:
5454
"""
5555
Generates prime factors of the integer n.
5656

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp