I am very new to type hinting in Python 3, and have tried reading and understanding the PEP, and I'm struggling with this.
I have a function that returns the iterator from re.finditer()
def get_collected_issues(book: Book) -> Iterator:
"""Parse the 'collecting' part of the book description, for series names and issue details.
"""
collecting = get_collecting(book)
return re.finditer(FULL_REGEX, collecting, re.IGNORECASE)
When inspecting at runtime, each iteration of finditer() is a _sre.SRE_Match
object, but that's not importable, so I'm not sure how I can make the return type hint any more specific.
The typing.re.Match
was added for exactly this reason.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.