This is an archive of the discontinued Mercurial Phabricator instance.

encoding: define per-use identity functions only in typechecking mode
AbandonedPublic

Authored by durin42 on Nov 13 2019, 10:51 PM.

Details

Reviewers
None
Group Reviewers
hg-reviewers
Summary

This avoids some unfortunate overhead from my previous iteration.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

durin42 created this revision.Nov 13 2019, 10:51 PM

Let's not land this for now: it's breaking a fair amount of typechecking. :(

durin42 abandoned this revision.Nov 13 2019, 11:03 PM
dlax added a subscriber: dlax.Nov 14 2019, 5:50 AM

Have you tried using variables annotations? Like:

strtolocal = pycompat.identity  # type: (str) -> bytes
strfromlocal = pycompat.identity  # type: (bytes) -> str
yuja added a subscriber: yuja.Nov 14 2019, 9:31 AM
strtolocal = pycompat.identity  # type: (str) -> bytes
strfromlocal = pycompat.identity  # type: (bytes) -> str

# type: Callable[[str], bytes] might work. pytype complained
# type: ... -> ... is an invalid type comment.