##// 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 from .pure import charencode as charencodepure
21 from .pure import charencode as charencodepure
22
22
23 _TYPE_CHECKING = False
24
23 if not globals(): # hide this from non-pytype users
25 if not globals(): # hide this from non-pytype users
24 from typing import (
26 from typing import (
25 Any,
27 Any,
26 Callable,
28 Callable,
27 List,
29 List,
30 TYPE_CHECKING as _TYPE_CHECKING,
28 Text,
31 Text,
29 Type,
32 Type,
30 TypeVar,
33 TypeVar,
@@ -117,11 +120,17 b' class localstr(bytes):'
117 round-tripped to the local encoding and back'''
120 round-tripped to the local encoding and back'''
118
121
119 def __new__(cls, u, l):
122 def __new__(cls, u, l):
120 # type: (Type[_Tlocalstr], bytes, bytes) -> _Tlocalstr
121 s = bytes.__new__(cls, l)
123 s = bytes.__new__(cls, l)
122 s._utf8 = u
124 s._utf8 = u
123 return s
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 def __hash__(self):
134 def __hash__(self):
126 return hash(self._utf8) # avoid collisions in local string space
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