equal
deleted
inserted
replaced
18 pycompat, |
18 pycompat, |
19 ) |
19 ) |
20 |
20 |
21 from .pure import charencode as charencodepure |
21 from .pure import charencode as charencodepure |
22 |
22 |
23 _TYPE_CHECKING = False |
23 if pycompat.TYPE_CHECKING: |
24 |
|
25 if not globals(): # hide this from non-pytype users |
|
26 from typing import ( |
24 from typing import ( |
27 Any, |
25 Any, |
28 Callable, |
26 Callable, |
29 List, |
27 List, |
30 TYPE_CHECKING as _TYPE_CHECKING, |
|
31 Text, |
28 Text, |
32 Type, |
29 Type, |
33 TypeVar, |
30 TypeVar, |
34 Union, |
31 Union, |
35 ) |
32 ) |
122 def __new__(cls, u, l): |
119 def __new__(cls, u, l): |
123 s = bytes.__new__(cls, l) |
120 s = bytes.__new__(cls, l) |
124 s._utf8 = u |
121 s._utf8 = u |
125 return s |
122 return s |
126 |
123 |
127 if _TYPE_CHECKING: |
124 if pycompat.TYPE_CHECKING: |
128 # pseudo implementation to help pytype see localstr() constructor |
125 # pseudo implementation to help pytype see localstr() constructor |
129 def __init__(self, u, l): |
126 def __init__(self, u, l): |
130 # type: (bytes, bytes) -> None |
127 # type: (bytes, bytes) -> None |
131 super(localstr, self).__init__(l) |
128 super(localstr, self).__init__(l) |
132 self._utf8 = u |
129 self._utf8 = u |