Skip to content

Commit 51b2d7d

Browse files
committed
Merge pull request #455 from spkersten/privstub452
Made local type vars in stubs private
2 parents 9005b3d + b6a4307 commit 51b2d7d

14 files changed

+211
-211
lines changed

stubs/2.7/typing.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def __getitem__(self, typeargs):
3939

4040
# Abstract base classes.
4141

42-
T = typevar('T')
43-
KT = typevar('KT')
44-
VT = typevar('VT')
42+
_T = typevar('_T')
43+
_KT = typevar('_KT')
44+
_VT = typevar('_VT')
4545

4646
# TODO Container etc.
4747

@@ -53,113 +53,113 @@ class SupportsFloat(metaclass=ABCMeta):
5353
@abstractmethod
5454
def __float__(self) -> float: pass
5555

56-
class SupportsAbs(AbstractGeneric[T]):
56+
class SupportsAbs(AbstractGeneric[_T]):
5757
@abstractmethod
58-
def __abs__(self) -> T: pass
58+
def __abs__(self) -> _T: pass
5959

6060
@disjointclass(int)
6161
@disjointclass(float)
62-
class SupportsRound(AbstractGeneric[T]):
62+
class SupportsRound(AbstractGeneric[_T]):
6363
@abstractmethod
64-
def __round__(self, ndigits: int = 0) -> T: pass
64+
def __round__(self, ndigits: int = 0) -> _T: pass
6565

66-
class Reversible(AbstractGeneric[T]):
66+
class Reversible(AbstractGeneric[_T]):
6767
@abstractmethod
68-
def __reversed__(self) -> Iterator[T]: pass
68+
def __reversed__(self) -> Iterator[_T]: pass
6969

7070
class Sized(metaclass=ABCMeta):
7171
@abstractmethod
7272
def __len__(self) -> int: pass
7373

74-
class Iterable(AbstractGeneric[T]):
74+
class Iterable(AbstractGeneric[_T]):
7575
@abstractmethod
76-
def __iter__(self) -> Iterator[T]: pass
76+
def __iter__(self) -> Iterator[_T]: pass
7777

78-
class Iterator(Iterable[T], AbstractGeneric[T]):
78+
class Iterator(Iterable[_T], AbstractGeneric[_T]):
7979
@abstractmethod
80-
def next(self) -> T: pass
80+
def next(self) -> _T: pass
8181

82-
class Sequence(Sized, Iterable[T], AbstractGeneric[T]):
82+
class Sequence(Sized, Iterable[_T], AbstractGeneric[_T]):
8383
@abstractmethod
8484
def __contains__(self, x: object) -> bool: pass
8585
@overload
8686
@abstractmethod
87-
def __getitem__(self, i: int) -> T: pass
87+
def __getitem__(self, i: int) -> _T: pass
8888
@overload
8989
@abstractmethod
90-
def __getitem__(self, s: slice) -> Sequence[T]: pass
90+
def __getitem__(self, s: slice) -> Sequence[_T]: pass
9191

92-
class AbstractSet(Sized, Iterable[T], AbstractGeneric[T]):
92+
class AbstractSet(Sized, Iterable[_T], AbstractGeneric[_T]):
9393
@abstractmethod
9494
def __contains__(self, x: object) -> bool: pass
9595
# TODO __le__, __lt__, __gt__, __ge__
9696
@abstractmethod
97-
def __and__(self, s: AbstractSet[T]) -> AbstractSet[T]: pass
97+
def __and__(self, s: AbstractSet[_T]) -> AbstractSet[_T]: pass
9898
@abstractmethod
99-
def __or__(self, s: AbstractSet[T]) -> AbstractSet[T]: pass
99+
def __or__(self, s: AbstractSet[_T]) -> AbstractSet[_T]: pass
100100
@abstractmethod
101-
def __sub__(self, s: AbstractSet[T]) -> AbstractSet[T]: pass
101+
def __sub__(self, s: AbstractSet[_T]) -> AbstractSet[_T]: pass
102102
@abstractmethod
103-
def __xor__(self, s: AbstractSet[T]) -> AbstractSet[T]: pass
103+
def __xor__(self, s: AbstractSet[_T]) -> AbstractSet[_T]: pass
104104
# TODO argument can be any container?
105105
@abstractmethod
106-
def isdisjoint(self, s: AbstractSet[T]) -> bool: pass
106+
def isdisjoint(self, s: AbstractSet[_T]) -> bool: pass
107107

108-
class Mapping(Sized, Iterable[KT], AbstractGeneric[KT, VT]):
108+
class Mapping(Sized, Iterable[_KT], AbstractGeneric[_KT, _VT]):
109109
@abstractmethod
110-
def __getitem__(self, k: KT) -> VT: pass
110+
def __getitem__(self, k: _KT) -> _VT: pass
111111
@abstractmethod
112-
def __setitem__(self, k: KT, v: VT) -> None: pass
112+
def __setitem__(self, k: _KT, v: _VT) -> None: pass
113113
@abstractmethod
114-
def __delitem__(self, v: KT) -> None: pass
114+
def __delitem__(self, v: _KT) -> None: pass
115115
@abstractmethod
116116
def __contains__(self, o: object) -> bool: pass
117117

118118
@abstractmethod
119119
def clear(self) -> None: pass
120120
@abstractmethod
121-
def copy(self) -> Mapping[KT, VT]: pass
121+
def copy(self) -> Mapping[_KT, _VT]: pass
122122
@overload
123123
@abstractmethod
124-
def get(self, k: KT) -> VT: pass
124+
def get(self, k: _KT) -> _VT: pass
125125
@overload
126126
@abstractmethod
127-
def get(self, k: KT, default: VT) -> VT: pass
127+
def get(self, k: _KT, default: _VT) -> _VT: pass
128128
@overload
129129
@abstractmethod
130-
def pop(self, k: KT) -> VT: pass
130+
def pop(self, k: _KT) -> _VT: pass
131131
@overload
132132
@abstractmethod
133-
def pop(self, k: KT, default: VT) -> VT: pass
133+
def pop(self, k: _KT, default: _VT) -> _VT: pass
134134
@abstractmethod
135-
def popitem(self) -> Tuple[KT, VT]: pass
135+
def popitem(self) -> Tuple[_KT, _VT]: pass
136136
@overload
137137
@abstractmethod
138-
def setdefault(self, k: KT) -> VT: pass
138+
def setdefault(self, k: _KT) -> _VT: pass
139139
@overload
140140
@abstractmethod
141-
def setdefault(self, k: KT, default: VT) -> VT: pass
141+
def setdefault(self, k: _KT, default: _VT) -> _VT: pass
142142

143143
# TODO keyword arguments
144144
@overload
145145
@abstractmethod
146-
def update(self, m: Mapping[KT, VT]) -> None: pass
146+
def update(self, m: Mapping[_KT, _VT]) -> None: pass
147147
@overload
148148
@abstractmethod
149-
def update(self, m: Iterable[Tuple[KT, VT]]) -> None: pass
149+
def update(self, m: Iterable[Tuple[_KT, _VT]]) -> None: pass
150150

151151
@abstractmethod
152-
def keys(self) -> list[KT]: pass
152+
def keys(self) -> list[_KT]: pass
153153
@abstractmethod
154-
def values(self) -> list[VT]: pass
154+
def values(self) -> list[_VT]: pass
155155
@abstractmethod
156-
def items(self) -> list[Tuple[KT, VT]]: pass
156+
def items(self) -> list[Tuple[_KT, _VT]]: pass
157157
@abstractmethod
158-
def iterkeys(self) -> Iterator[KT]: pass
158+
def iterkeys(self) -> Iterator[_KT]: pass
159159
@abstractmethod
160-
def itervalues(self) -> Iterator[VT]: pass
160+
def itervalues(self) -> Iterator[_VT]: pass
161161
@abstractmethod
162-
def iteritems(self) -> Iterator[Tuple[KT, VT]]: pass
162+
def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: pass
163163

164164
class IO(Iterable[AnyStr], AbstractGeneric[AnyStr]):
165165
# TODO detach

stubs/3.2/atexit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import typevar, Any
22

3-
FT = typevar('FT')
3+
_FT = typevar('_FT')
44

5-
def register(func: FT, *args: Any, **kargs: Any) -> FT: pass
5+
def register(func: _FT, *args: Any, **kargs: Any) -> _FT: pass

stubs/3.2/collections.py

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,87 +13,87 @@
1313
Mapping, List, Tuple, Undefined, Function, Set, Sequence, Sized
1414
)
1515

16-
T = typevar('T')
17-
KT = typevar('KT')
18-
VT = typevar('VT')
16+
_T = typevar('_T')
17+
_KT = typevar('_KT')
18+
_VT = typevar('_VT')
1919

2020

21-
class deque(Sized, Iterable[T], AbstractGeneric[T]):
21+
class deque(Sized, Iterable[_T], AbstractGeneric[_T]):
2222
# TODO int with None default
2323
maxlen = 0 # TODO readonly
24-
def __init__(self, iterable: Iterable[T] = None,
24+
def __init__(self, iterable: Iterable[_T] = None,
2525
maxlen: int = None) -> None: pass
26-
def append(self, x: T) -> None: pass
27-
def appendleft(self, x: T) -> None: pass
26+
def append(self, x: _T) -> None: pass
27+
def appendleft(self, x: _T) -> None: pass
2828
def clear(self) -> None: pass
29-
def count(self, x: T) -> int: pass
30-
def extend(self, iterable: Iterable[T]) -> None: pass
31-
def extendleft(self, iterable: Iterable[T]) -> None: pass
32-
def pop(self) -> T: pass
33-
def popleft(self) -> T: pass
34-
def remove(self, value: T) -> None: pass
29+
def count(self, x: _T) -> int: pass
30+
def extend(self, iterable: Iterable[_T]) -> None: pass
31+
def extendleft(self, iterable: Iterable[_T]) -> None: pass
32+
def pop(self) -> _T: pass
33+
def popleft(self) -> _T: pass
34+
def remove(self, value: _T) -> None: pass
3535
def reverse(self) -> None: pass
3636
def rotate(self, n: int) -> None: pass
3737

3838
def __len__(self) -> int: pass
39-
def __iter__(self) -> Iterator[T]: pass
39+
def __iter__(self) -> Iterator[_T]: pass
4040
def __str__(self) -> str: pass
4141
def __hash__(self) -> int: pass
4242

43-
def __getitem__(self, i: int) -> T: pass
44-
def __setitem__(self, i: int, x: T) -> None: pass
45-
def __contains__(self, o: T) -> bool: pass
43+
def __getitem__(self, i: int) -> _T: pass
44+
def __setitem__(self, i: int, x: _T) -> None: pass
45+
def __contains__(self, o: _T) -> bool: pass
4646

4747
# TODO __reversed__
4848

4949

50-
class Counter(Dict[T, int], Generic[T]):
50+
class Counter(Dict[_T, int], Generic[_T]):
5151
@overload
5252
def __init__(self) -> None: pass
5353
@overload
54-
def __init__(self, Mapping: Mapping[T, int]) -> None: pass
54+
def __init__(self, Mapping: Mapping[_T, int]) -> None: pass
5555
@overload
56-
def __init__(self, iterable: Iterable[T]) -> None: pass
56+
def __init__(self, iterable: Iterable[_T]) -> None: pass
5757
# TODO keyword arguments
5858

59-
def elements(self) -> Iterator[T]: pass
59+
def elements(self) -> Iterator[_T]: pass
6060

6161
@overload
62-
def most_common(self) -> List[T]: pass
62+
def most_common(self) -> List[_T]: pass
6363
@overload
64-
def most_common(self, n: int) -> List[T]: pass
64+
def most_common(self, n: int) -> List[_T]: pass
6565

6666
@overload
67-
def subtract(self, Mapping: Mapping[T, int]) -> None: pass
67+
def subtract(self, Mapping: Mapping[_T, int]) -> None: pass
6868
@overload
69-
def subtract(self, iterable: Iterable[T]) -> None: pass
69+
def subtract(self, iterable: Iterable[_T]) -> None: pass
7070

7171
# TODO update
7272

7373

74-
class OrderedDict(Dict[KT, VT], Generic[KT, VT]):
75-
def popitem(self, last: bool = True) -> Tuple[KT, VT]: pass
76-
def move_to_end(self, key: KT, last: bool = True) -> None: pass
74+
class OrderedDict(Dict[_KT, _VT], Generic[_KT, _VT]):
75+
def popitem(self, last: bool = True) -> Tuple[_KT, _VT]: pass
76+
def move_to_end(self, key: _KT, last: bool = True) -> None: pass
7777

7878

79-
class defaultdict(Dict[KT, VT], Generic[KT, VT]):
80-
default_factory = Undefined(Function[[], VT])
79+
class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
80+
default_factory = Undefined(Function[[], _VT])
8181

8282
@overload
8383
def __init__(self) -> None: pass
8484
@overload
85-
def __init__(self, map: Mapping[KT, VT]) -> None: pass
85+
def __init__(self, map: Mapping[_KT, _VT]) -> None: pass
8686
@overload
87-
def __init__(self, iterable: Iterable[Tuple[KT, VT]]) -> None: pass
87+
def __init__(self, iterable: Iterable[Tuple[_KT, _VT]]) -> None: pass
8888
@overload
89-
def __init__(self, default_factory: Function[[], VT]) -> None: pass
89+
def __init__(self, default_factory: Function[[], _VT]) -> None: pass
9090
@overload
91-
def __init__(self, default_factory: Function[[], VT],
92-
map: Mapping[KT, VT]) -> None: pass
91+
def __init__(self, default_factory: Function[[], _VT],
92+
map: Mapping[_KT, _VT]) -> None: pass
9393
@overload
94-
def __init__(self, default_factory: Function[[], VT],
95-
iterable: Iterable[Tuple[KT, VT]]) -> None: pass
94+
def __init__(self, default_factory: Function[[], _VT],
95+
iterable: Iterable[Tuple[_KT, _VT]]) -> None: pass
9696
# TODO __init__ keyword args
9797

98-
def __missing__(self, key: KT) -> VT: pass
98+
def __missing__(self, key: _KT) -> _VT: pass
9999
# TODO __reversed__

stubs/3.2/copy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
from typing import typevar
66

7-
T = typevar('T')
7+
_T = typevar('_T')
88

9-
def deepcopy(x: T) -> T: pass
9+
def deepcopy(x: _T) -> _T: pass

stubs/3.2/heapq.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
from typing import typevar, List, Iterable, Any, Function
66

7-
T = typevar('T')
7+
_T = typevar('_T')
88

9-
def heappush(heap: List[T], item: T) -> None: pass
10-
def heappop(heap: List[T]) -> T: pass
11-
def heappushpop(heap: List[T], item: T) -> T: pass
12-
def heapify(x: List[T]) -> None: pass
13-
def heapreplace(heap: List[T], item: T) -> T: pass
14-
def merge(*iterables: Iterable[T]) -> Iterable[T]: pass
15-
def nlargest(n: int, iterable: Iterable[T],
16-
key: Function[[T], Any] = None) -> List[T]: pass
17-
def nsmallest(n: int, iterable: Iterable[T],
18-
key: Function[[T], Any] = None) -> List[T]: pass
9+
def heappush(heap: List[_T], item: _T) -> None: pass
10+
def heappop(heap: List[_T]) -> _T: pass
11+
def heappushpop(heap: List[_T], item: _T) -> _T: pass
12+
def heapify(x: List[_T]) -> None: pass
13+
def heapreplace(heap: List[_T], item: _T) -> _T: pass
14+
def merge(*iterables: Iterable[_T]) -> Iterable[_T]: pass
15+
def nlargest(n: int, iterable: Iterable[_T],
16+
key: Function[[_T], Any] = None) -> List[_T]: pass
17+
def nsmallest(n: int, iterable: Iterable[_T],
18+
key: Function[[_T], Any] = None) -> List[_T]: pass

stubs/3.2/imp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from typing import typevar
66

7-
T = typevar('T')
7+
_T = typevar('_T')
88

99
def cache_from_source(path: str, debug_override: bool = None) -> str: pass
10-
def reload(module: T) -> T: pass # TODO imprecise signature
10+
def reload(module: _T) -> _T: pass # TODO imprecise signature

0 commit comments

Comments
 (0)