##// END OF EJS Templates
typing: add pseudo localstr.__init__() to help pytype...
Yuya Nishihara -
r44080:da925257 default
parent child Browse files
Show More
@@ -20,11 +20,14 b' from . import ('
20 20
21 21 from .pure import charencode as charencodepure
22 22
23 _TYPE_CHECKING = False
24
23 25 if not globals(): # hide this from non-pytype users
24 26 from typing import (
25 27 Any,
26 28 Callable,
27 29 List,
30 TYPE_CHECKING as _TYPE_CHECKING,
28 31 Text,
29 32 Type,
30 33 TypeVar,
@@ -117,11 +120,17 b' class localstr(bytes):'
117 120 round-tripped to the local encoding and back'''
118 121
119 122 def __new__(cls, u, l):
120 # type: (Type[_Tlocalstr], bytes, bytes) -> _Tlocalstr
121 123 s = bytes.__new__(cls, l)
122 124 s._utf8 = u
123 125 return s
124 126
127 if _TYPE_CHECKING:
128 # pseudo implementation to help pytype see localstr() constructor
129 def __init__(self, u, l):
130 # type: (bytes, bytes) -> None
131 super(localstr, self).__init__(l)
132 self._utf8 = u
133
125 134 def __hash__(self):
126 135 return hash(self._utf8) # avoid collisions in local string space
127 136
General Comments 0
You need to be logged in to leave comments. Login now