Skip to content

Commit b7d16de

Browse files
committed
Renamed Var to TypeVar
1 parent ada03b6 commit b7d16de

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

pep-NNNN.txt

+10-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Status: Draft
88
Type: Standards Track
99
Content-Type: text/x-rst
1010
Created: 29-Sep-2014
11-
Post-History:
11+
Post-History:
1212
Resolution:
1313

1414

@@ -85,25 +85,21 @@ elements. Example::
8585
def notify_by_email(employees: Set[Employee], overrides: Mapping[str, str]): ...
8686

8787
Generics can be parametrized by using a new factory available in
88-
``collections.abc`` called ``Var``. Example::
88+
``collections.abc`` called ``TypeVar``. Example::
8989

90-
T = Var('T') # Declare type variable
90+
T = TypeVar('T') # Declare type variable
9191

9292
def first(l: Sequence[T]) -> T: # Generic function
9393
return l[0]
9494

95-
.. FIXME: Maybe rename Var to TypeVar to avoid confusion with simple
96-
variables and a possible future syntax of the form
97-
var name: type = value
98-
9995
In this case the contract is that the returning value is consistent with
10096
the elements held by the collection.
10197

102-
``Var`` supports constraining parametric types to classes with any of
98+
``TypeVar`` supports constraining parametric types to classes with any of
10399
the specified bases. Example::
104100

105-
X = Var('X')
106-
Y = Var('Y', Iterable[X])
101+
X = TypeVar('X')
102+
Y = TypeVar('Y', Iterable[X])
107103

108104
def filter(rule: Callable[[X], bool], input: Y) -> Y:
109105
...
@@ -201,8 +197,8 @@ complex cases, a comment of the following format may be used::
201197

202198
x = [] # type: List[Employee]
203199

204-
If type hinting proves useful in general, a variable typing in syntax may
205-
be provided in a future Python version.
200+
If type hinting proves useful in general, a syntax for typing variables
201+
may be provided in a future Python version.
206202

207203

208204
Explicit raised exceptions
@@ -246,7 +242,7 @@ new members are defined:
246242

247243
* Union
248244

249-
* Var
245+
* TypeVar
250246

251247
All available abstract base classes are importable:
252248

@@ -295,7 +291,7 @@ All available abstract base classes are importable:
295291

296292
The following helper types are also provided by the ``typing`` module:
297293

298-
* AnyStr, equivalent to ``Var('AnyStr', str, bytes)``
294+
* AnyStr, equivalent to ``TypeVar('AnyStr', str, bytes)``
299295

300296
* Match and Pattern, types of ``re.match()`` and ``re.compile()`` results
301297

0 commit comments

Comments
 (0)