Skip to content

Commit 8c4ac6c

Browse files
author
Guido van Rossum
committed
Various updates and references to issues.
1 parent def7be0 commit 8c4ac6c

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

README.rst

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,40 @@ Work in progress notes
2222

2323
* Putting new things in ``collections.abc`` seems fine as long as those
2424
new elements are actual abstract base classes that are collections.
25-
I lessened this latter requirement since there's non-collection
25+
I (Łukasz) lessened this latter requirement since there's non-collection
2626
precedent in ``abc``, namely ``Callable``, and ``Hashable``.
27+
However, attempts at implementing reasonable runtime behavior
28+
suggests that it may be better to leave ``collections.abc`` alone.
2729

2830
* ``Var('T')`` is put in ``collections.abc`` as a helper with generics
29-
and covariance/contravariance in ABCs
31+
and covariance/contravariance in ABCs. May be renamed to ``TypeVar``.
32+
The co-/contravariance behavior requires more thinking.
3033

3134
* ``AnyStr`` (and consequently ``IO``) smells like basestring in
32-
disguise, what is the use case for Python 3?
35+
disguise, what is the use case for Python 3? Answer: There are
36+
lots of things in the stdlib that are essentially overloaded as
37+
str-in-str-out and bytes-in-bytes-out; ``AnyStr`` has exactly the
38+
right behavior for this (unlike ``Union[str, bytes]``).
3339

34-
* ``Undefined`` smells like JavaScript, I left it out for now
40+
* ``Undefined`` smells like JavaScript, I left it out for now.
41+
However, mypy needs it. See https://github.com/ambv/typehinting/issues/20
3542

3643
* The addition of ``Match`` and ``Pattern`` seems arbitrary and should
3744
rather be fixed in ``re`` directly, with the types just imported in
3845
``typing``. If so, are there any other potentially useful types we'd
39-
like?
46+
like? See https://github.com/ambv/typehinting/issues/23
4047

4148
* I left out ``overload`` because I don't understand its purpose. If we
42-
need generic dispatch, we should add it to ``functools``
49+
need generic dispatch, we should add it to ``functools``.
50+
Perhaps ``overload`` should only be allowed in stub modules?
51+
See https://github.com/ambv/typehinting/issues/14
4352

4453
* I left out specifying protocols as they are an ABC implementation
4554
detail from the perspective of this PEP. However, they should be
4655
defined in a separate PEP because making ``__subclasshook__`` less
4756
dynamic when possible (which is often) would make ABCs much better
48-
behaved in static analysis contexts
57+
behaved in static analysis contexts.
58+
See https://github.com/ambv/typehinting/issues/11
4959

5060
* Having the last thing in mind, ``IO``, ``BinaryIO`` and ``TextIO``
5161
would simply be new abstract base classes, usable with or without type
@@ -60,11 +70,14 @@ Work in progress notes
6070
...
6171
well_typed_list = bad_typed_list # type: List[int]
6272

73+
See https://github.com/ambv/typehinting/issues/15
74+
6375
* I removed ``mypy`` from the listed "existing approaches" since we
64-
basically describe what MyPy is
76+
basically describe what mypy is
6577

6678
* I thought if introducing optional contravariance/invariance to ``Var``
67-
has merit but I'm undecided; definitely complicates the type checker
79+
has merit but I'm undecided; definitely complicates the type checker.
80+
See https://github.com/ambv/typehinting/issues/2
6881

6982

7083
Changes to MyPy coming from this proposal
@@ -73,21 +86,23 @@ Changes to MyPy coming from this proposal
7386
* ``typevar`` becomes ``Var('T')`` and its semantics support specifying
7487
base type constraints. If we decide to add optional invariance or
7588
contravariance, this will be the place, too.
89+
Or perhaps ``TypeVar('T')``. See
90+
https://github.com/JukkaL/mypy/issues/539 and
91+
https://github.com/ambv/typehinting/issues/1 and
92+
https://github.com/ambv/typehinting/issues/2 and maybe others.
93+
7694

77-
* ``collections.abc.Union`` behaves differently, it holds the defined
78-
types to be able to actually respond to issubclass. Consequently,
79-
``typing.AnyStr`` becomes an ``Union`` instead of ``typevar('AnyStr',
80-
values=(str, bytes))`` (which is consciously impossible to express in
81-
the ``Var`` notation, unless you're using a Union as ``base=``)
95+
* ``Union`` behaves differently, it holds the defined types in order
96+
to be able to actually respond to issubclass.
8297

8398
* ``typing.Function`` becomes ``typing.Callable``, which is equivalent
84-
to ``collections.abc.Callable``
99+
to ``collections.abc.Callable``. (Has now been implemented in mypy.)
85100

86101

87102
Open issues
88103
-----------
89104

90-
* How to make the union type land in __annotations__ for the ``x:str
105+
* How to make the union type land in __annotations__ for the ``x: str
91106
= None`` case?
92107

93108
* State of the art: should we list decorator-based approaches
@@ -100,13 +115,13 @@ Open issues
100115

101116
* is multiple dispatch using type hints in scope for this PEP?
102117

103-
* should we mention platform- or Python-specific typing? Guido mentioned
118+
* should we mention platform- or version-specific typing? Guido mentioned
104119
Windows vs. POSIX during the Skype meeting.
105120

106121
* it would be useful to have a ``Subclass[]`` factory that would be
107122
equivalent to "any class that has the all the following classes in its
108123
MRO". Maybe we'd want to rename union to ``Any[]`` and this new
109-
proposed type to ``All[]``?
124+
proposed type to ``All[]``? See https://github.com/ambv/typehinting/issues/18
110125

111126
* Callable signature definition should be explained and support all
112127
valid function signatures

0 commit comments

Comments
 (0)