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

login
register
mail settings
Submitter phabricator
Date Nov. 7, 2019, 8:31 a.m.
Message ID <aba1fe4b0b45f53debae98874a48c7d7@localhost.localdomain>
Download mbox | patch
Permalink /patch/42866/
State Not Applicable
Headers show

Comments

phabricator - Nov. 7, 2019, 8:31 a.m.
Closed by commit rHG5f2a8dabb0d8: encoding: define local identify functions with explicit type comments (authored by durin42).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7267?vs=17637&id=17684

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7267/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7267

AFFECTED FILES
  mercurial/encoding.py

CHANGE DETAILS




To: durin42, #hg-reviewers, indygreg
Cc: mercurial-devel
Yuya Nishihara - Nov. 8, 2019, 2:09 p.m.
> --- 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.
phabricator - Nov. 8, 2019, 2:11 p.m.
yuja added a comment.


  > - 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.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7267/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7267

To: durin42, #hg-reviewers, indygreg
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/encoding.py b/mercurial/encoding.py
--- 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
+
     strmethod = pycompat.identity
 
 if not _nativeenviron: