mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
[BE] Improve gitutils
Inherit `PeekableIterator` from `collections.abc.Iterator` Pull Request resolved: https://github.com/pytorch/pytorch/pull/71515
This commit is contained in:
committed by
PyTorch MergeBot
parent
a9f44b22c0
commit
42f7afc4cd
5
.github/scripts/gitutils.py
vendored
5
.github/scripts/gitutils.py
vendored
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from collections import defaultdict
|
||||
from collections.abc import Iterator
|
||||
from datetime import datetime
|
||||
from typing import cast, Any, Dict, List, Optional, Tuple, Union
|
||||
import os
|
||||
@ -211,7 +212,7 @@ class GitRepo:
|
||||
self._run_git("commit", "--amend", "-m", msg)
|
||||
|
||||
|
||||
class PeekableIterator:
|
||||
class PeekableIterator(Iterator[str]):
|
||||
def __init__(self, val: str) -> None:
|
||||
self._val = val
|
||||
self._idx = -1
|
||||
@ -221,7 +222,7 @@ class PeekableIterator:
|
||||
return None
|
||||
return self._val[self._idx + 1]
|
||||
|
||||
def __iter__(self) -> Any:
|
||||
def __iter__(self) -> "PeekableIterator":
|
||||
return self
|
||||
|
||||
def __next__(self) -> str:
|
||||
|
Reference in New Issue
Block a user