# HG changeset patch # User Matt Harbison # Date 1720641893 14400 # Node ID a09435c0eb14bd98b9f1b303eab537f8ff5f92cc # Parent 32a1c9226dd9ee138848a00829ce1f870491bd9f typing: add a few type hints to `mercurial/utils/urlutil.py` Somewhere between hg 3dbc7b1ecaba and hg 8e3f6b5bf720, `_pathsuboptions` changed from `Dict[bytes, Tuple[bytes, Any]]` to `Dict[bytes, Tuple[str, Any]]`, and it caught my attention from diffing the local *.pyi files. The change is correct based on the assertion, so let's get pytype to check for this instead of relying on the assertion alone. diff -r 32a1c9226dd9 -r a09435c0eb14 mercurial/utils/urlutil.py --- a/mercurial/utils/urlutil.py Wed Jul 10 15:49:16 2024 -0400 +++ b/mercurial/utils/urlutil.py Wed Jul 10 16:04:53 2024 -0400 @@ -9,6 +9,9 @@ import socket from typing import ( + Callable, + Dict, + Tuple, Union, ) @@ -29,7 +32,7 @@ ) # keeps pyflakes happy -assert [Union] +assert [Callable, Dict, Tuple, Union] urlreq = urllibcompat.urlreq @@ -652,12 +655,12 @@ self[name] = new_paths -_pathsuboptions = {} +_pathsuboptions: "Dict[bytes, Tuple[str, Callable]]" = {} # a dictionnary of methods that can be used to format a sub-option value path_suboptions_display = {} -def pathsuboption(option, attr, display=pycompat.bytestr): +def pathsuboption(option: bytes, attr: str, display=pycompat.bytestr): """Decorator used to declare a path sub-option. Arguments are the sub-option name and the attribute it should set on