# HG changeset patch # User Matt Harbison # Date 1720650887 14400 # Node ID 0e16efe30866da9b8903ecd1c79416ae459e3392 # Parent df6ce326936f15141ffab1ae6384d1db4fdedabd typing: add a few trivial type hints to `mercurial/templater.py` Since hg 3dbc7b1ecaba, pytype started inferring that the second value in the tuple is `BinaryIO`, but still hasn't been able to figure out the rest of `open_template()`. We can be more precise. diff -r df6ce326936f -r 0e16efe30866 mercurial/templater.py --- a/mercurial/templater.py Wed Jul 10 18:19:32 2024 -0400 +++ b/mercurial/templater.py Wed Jul 10 18:34:47 2024 -0400 @@ -69,6 +69,12 @@ import abc import os +from typing import ( + BinaryIO, + Optional, + Tuple, +) + from .i18n import _ from .pycompat import ( FileNotFoundError, @@ -1121,7 +1127,9 @@ return path if os.path.isdir(path) else None -def open_template(name, templatepath=None): +def open_template( + name: bytes, templatepath: Optional[bytes] = None +) -> Tuple[bytes, BinaryIO]: """returns a file-like object for the given template, and its full path If the name is a relative path and we're in a frozen binary, the template @@ -1156,7 +1164,9 @@ ) -def try_open_template(name, templatepath=None): +def try_open_template( + name: bytes, templatepath: Optional[bytes] = None +) -> Tuple[Optional[bytes], Optional[BinaryIO]]: try: return open_template(name, templatepath) except (EnvironmentError, ImportError):