D7267: encoding: define local identify functions with explicit type comments

Yuya Nishihara yuya at tcha.org
Fri Nov 8 09:09:36 EST 2019


> --- a/mercurial/encoding.py
> +++ b/mercurial/encoding.py
> @@ -241,8 +241,15 @@
>      strfromlocal = unifromlocal
>      strmethod = unimethod
>  else:
> -    strtolocal = pycompat.identity
> -    strfromlocal = pycompat.identity
> +
> +    def strtolocal(s):
> +        # type: (str) -> bytes
> +        return s
> +
> +    def strfromlocal(s):
> +        # type: (bytes) -> str
> +        return s

It disables the fast path `f is identity` in `pycompat.rapply`. I don't
think that matters, but I just noted.


More information about the Mercurial-devel mailing list