@@ -26,21 +26,21 @@ Work in progress notes
26
26
precedent in ``abc ``, namely ``Callable ``, and ``Hashable ``.
27
27
However, attempts at implementing reasonable runtime behavior
28
28
suggests that it may be better to leave ``collections.abc `` alone.
29
- **Proposed resolution: leave ``collections.abc`` alone. **
29
+ **Proposed resolution: ** Leave ``collections.abc `` alone.
30
30
31
31
* ``Var('T') `` is put in ``collections.abc `` as a helper with generics
32
32
and covariance/contravariance in ABCs. May be renamed to ``TypeVar ``.
33
33
The co-/contravariance behavior requires more thinking.
34
- **Proposed resolution: Use ``TypeVar``, with mypy's semantics mapped:
35
- ``typevar('T', values=(str, bytes)`` becomes ``TypeVar('T', str, bytes)``. **
34
+ **Proposed resolution: ** Use ``TypeVar ``, with mypy's semantics mapped:
35
+ ``typevar('T', values=(str, bytes) `` becomes ``TypeVar('T', str, bytes) ``.
36
36
37
37
* ``AnyStr `` (and consequently ``IO ``) smells like basestring in
38
38
disguise, what is the use case for Python 3? Answer: There are
39
39
lots of things in the stdlib that are essentially overloaded as
40
40
str-in-str-out and bytes-in-bytes-out; ``AnyStr `` has exactly the
41
41
right behavior for this (unlike ``Union[str, bytes] ``).
42
- **Proposed resolution: keep ``AnyStr``, ``IO`` and its subclasses,
43
- in typing.py. **
42
+ **Proposed resolution: ** Keep ``AnyStr ``, ``IO `` and its subclasses,
43
+ in typing.py.
44
44
45
45
* ``Undefined `` smells like JavaScript, I (Łukasz) left it out for now.
46
46
However, mypy needs it. See https://github.com/ambv/typehinting/issues/20
@@ -50,13 +50,13 @@ Work in progress notes
50
50
rather be fixed in ``re `` directly, with the types just imported in
51
51
``typing ``. If so, are there any other potentially useful types we'd
52
52
like? See https://github.com/ambv/typehinting/issues/23
53
- **Proposed resolution: keep these two in typing.py for convenience. **
53
+ **Proposed resolution: ** Keep these two in typing.py for convenience.
54
54
55
55
* I (Łukasz) left out ``overload `` because I don't understand its purpose. If we
56
56
need generic dispatch, we should add it to ``functools ``.
57
57
Perhaps ``overload `` should only be allowed in stub modules?
58
58
See https://github.com/ambv/typehinting/issues/14
59
- **Proposed resolution: support the syntax but only in stub files. **
59
+ **Proposed resolution: ** support the syntax but only in stub files.
60
60
61
61
* I (Łukasz) left out specifying protocols as they are an ABC implementation
62
62
detail from the perspective of this PEP. However, they should be
@@ -69,8 +69,8 @@ Work in progress notes
69
69
* Having the last thing in mind, ``IO ``, ``BinaryIO `` and ``TextIO ``
70
70
would simply be new abstract base classes, usable with or without type
71
71
hinting.
72
- **Proposed resolution: ``IO`` is generic over ``AnyStr``, the other two
73
- are concrete (subclassing ``IO[bytes]`` and ``IO[str]`` respectively). **
72
+ **Proposed resolution: ** ``IO `` is generic over ``AnyStr ``, the other two
73
+ are concrete (subclassing ``IO[bytes] `` and ``IO[str] `` respectively).
74
74
75
75
* The current implementation of ``*IO `` is quite un-ducktyped (specifies
76
76
both reading and writing as one protocol)
@@ -83,10 +83,10 @@ Work in progress notes
83
83
well_typed_list = bad_typed_list # type: List[int]
84
84
85
85
See https://github.com/ambv/typehinting/issues/15
86
- **Proposed resolution: add ``cast(type, value)`` back in.**
86
+ **Proposed resolution:** Add ``cast(type, value)`` back in.
87
87
88
88
* I (Łukasz) removed ``mypy `` from the listed "existing approaches" since we
89
- basically describe what mypy is. **Proposed resolution: fine. **
89
+ basically describe what mypy is. **Proposed resolution: ** Fine.
90
90
91
91
* I (Łukasz) thought if introducing optional contravariance/invariance to ``Var ``
92
92
has merit but I'm undecided; definitely complicates the type checker.
@@ -104,12 +104,12 @@ Changes to MyPy coming from this proposal
104
104
https://github.com/JukkaL/mypy/issues/539 and
105
105
https://github.com/ambv/typehinting/issues/1 and
106
106
https://github.com/ambv/typehinting/issues/2 and maybe others.
107
- **Proposed resolution: ``TypeVar`` (see above). **
107
+ **Proposed resolution: ** ``TypeVar `` (see above).
108
108
109
109
* ``Union `` behaves differently, it holds the defined types in order
110
110
to be able to actually respond to issubclass.
111
- **Proposed resolution: This doesn't affect mypy; I do want this for
112
- typing.py (also for generic types). **
111
+ **Proposed resolution: ** This doesn't affect mypy; I do want this for
112
+ typing.py (also for generic types).
113
113
114
114
* ``typing.Function `` becomes ``typing.Callable ``, which is equivalent
115
115
to ``collections.abc.Callable ``. (Has now been implemented in mypy.)
@@ -130,23 +130,23 @@ Open issues
130
130
longer to type than dict?
131
131
132
132
* Is multiple dispatch using type hints in scope for this PEP?
133
- **Proposed resolution: let's wait, allow @overload only in stubs. **
133
+ **Proposed resolution: ** let's wait, allow @overload only in stubs.
134
134
135
135
* Should we mention platform- or version-specific typing? Guido mentioned
136
136
Windows vs. POSIX during the Skype meeting.
137
- **Proposed resolution: let typing.py export a few specific constants;
138
- PY3, PY2, PY3_x (for x in 2, 3, 4, 5). **
137
+ **Proposed resolution: ** Let typing.py export a few specific constants;
138
+ PY3, PY2, PY3_x (for x in 2, 3, 4, 5).
139
139
140
140
* It would be useful to have a ``Subclass[] `` factory that would be
141
141
equivalent to "any class that has the all the following classes in its
142
142
MRO". Maybe we'd want to rename union to ``Any[] `` and this new
143
143
proposed type to ``All[] ``? See https://github.com/ambv/typehinting/issues/18
144
- **Proposed resolution: let 's just have ``Union[T1, T2, ...]`` and ``Any``. **
144
+ **Proposed resolution: ** Let 's just have ``Union[T1, T2, ...] `` and ``Any ``.
145
145
146
146
* Callable signature definition should be explained and support all
147
147
valid function signatures.
148
- **Proposed resolution: ``Callable[[T1, T2, ...], Tr]``. **
148
+ **Proposed resolution: ** ``Callable[[T1, T2, ...], Tr] ``.
149
149
150
150
* What about all other collections available in the ``collections ``
151
151
module?
152
- **Proposed resolution: make Generic types retain their argument type(s). **
152
+ **Proposed resolution: ** Make Generic types retain their argument type(s).
0 commit comments