Commit d47f0dd2 authored by M. Eric Irrgang's avatar M. Eric Irrgang Committed by Ivan Levkivskyi

bpo-32996: Documentation fix-up. (GH-16646)

PR #4906 changed the typing.Generic class hierarchy, leaving an
outdated comment in the library reference. User-defined Generic ABCs now
must get a abc.ABCMeta metaclass from something other than typing.Generic
inheritance.
parent a05fcd3c
...@@ -307,9 +307,10 @@ User defined generic type aliases are also supported. Examples:: ...@@ -307,9 +307,10 @@ User defined generic type aliases are also supported. Examples::
def inproduct(v: Vec[T]) -> T: # Same as Iterable[Tuple[T, T]] def inproduct(v: Vec[T]) -> T: # Same as Iterable[Tuple[T, T]]
return sum(x*y for x, y in v) return sum(x*y for x, y in v)
The metaclass used by :class:`Generic` is a subclass of :class:`abc.ABCMeta`. .. versionchanged:: 3.7
A generic class can be an ABC by including abstract methods or properties, :class:`Generic` no longer has a custom metaclass.
and generic classes can also have ABCs as base classes without a metaclass
A user-defined generic class can have ABCs as base classes without a metaclass
conflict. Generic metaclasses are not supported. The outcome of parameterizing conflict. Generic metaclasses are not supported. The outcome of parameterizing
generics is cached, and most types in the typing module are hashable and generics is cached, and most types in the typing module are hashable and
comparable for equality. comparable for equality.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment