bpo-32226: PEP 560: improve typing module (#4906)

This PR re-designs the internal typing API using the new PEP 560 features.
However, there are only few minor changes in the public API.
This commit is contained in:
Ivan Levkivskyi 2018-01-20 11:23:59 +00:00 committed by GitHub
parent d57f26c753
commit d911e40e78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 771 additions and 1640 deletions

View file

@ -389,7 +389,8 @@ def _get_field(cls, a_name, a_type):
if typing is not None:
# This test uses a typing internal class, but it's the best
# way to test if this is a ClassVar.
if type(a_type) is typing._ClassVar:
if (type(a_type) is typing._GenericAlias and
a_type.__origin__ is typing.ClassVar):
# This field is a ClassVar, so it's not a field.
f._field_type = _FIELD_CLASSVAR