Hello community,

here is the log from the commit of package python-typing_extensions for 
openSUSE:Factory checked in at 2019-03-01 16:47:57
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-typing_extensions (Old)
 and      /work/SRC/openSUSE:Factory/.python-typing_extensions.new.28833 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-typing_extensions"

Fri Mar  1 16:47:57 2019 rev:2 rq:680053 version:3.7.2

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-typing_extensions/python-typing_extensions.changes
        2018-12-07 14:34:37.643128672 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-typing_extensions.new.28833/python-typing_extensions.changes
     2019-03-01 16:47:59.813786087 +0100
@@ -1,0 +2,24 @@
+Thu Feb 28 09:01:37 UTC 2019 - Tomáš Chvátal <[email protected]>
+
+- Drop the old tarball
+
+-------------------------------------------------------------------
+Thu Feb 28 04:57:58 UTC 2019 - John Vandenberg <[email protected]>
+
+- Replace test_modules.tar.gz with python-testsuite
+- Remove fix_tests.patch which is half fixing test_modules.tar.gz,
+  and the other half is replaced with a less brittle sed.
+- Remove unnecessary build dependencies
+- Update to 3.7.2
+  * Pass *args and **kwargs to superclass in Generic.__new__
+  * Fix for issue #524
+  * Fix typing_extensions to support PEP 560
+  * Add annotations to NamedTuple children __new__ constructors
+  * Add missing 'NoReturn' to __all__ in typing.py
+  * Backport Generic.__new__ fix
+  * Fix IO.closed to be property
+  * Add Final to typing_extensions
+  * Fix instance/subclass checks of functions against runtime protocols
+  * Add Literal[...] types to typing_extensions
+
+-------------------------------------------------------------------

Old:
----
  fix_tests.patch
  test_modules.tar.gz
  typing_extensions-3.6.6.tar.gz

New:
----
  typing_extensions-3.7.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-typing_extensions.spec ++++++
--- /var/tmp/diff_new_pack.4YH6BA/_old  2019-03-01 16:48:02.285785156 +0100
+++ /var/tmp/diff_new_pack.4YH6BA/_new  2019-03-01 16:48:02.285785156 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package python-typing_extensions
 #
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -20,22 +20,17 @@
 %define modname typing_extensions
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-typing_extensions
-Version:        3.6.6
+Version:        3.7.2
 Release:        0
 Summary:        Backported and Experimental Type Hints for Python 35+
 License:        Python-2.0
 Group:          Development/Languages/Python
 URL:            https://github.com/python/typing/
 Source0:        
https://files.pythonhosted.org/packages/source/t/typing_extensions/%{modname}-%{version}.tar.gz
-Source1:        test_modules.tar.gz
-Patch0:         fix_tests.patch
-BuildRequires:  %{python_module flake8-bugbear}
-BuildRequires:  %{python_module flake8-pyi}
-BuildRequires:  %{python_module flake8}
 BuildRequires:  %{python_module pytest >= 3.0}
-BuildRequires:  %{python_module pytest-cov >= 2.4.0}
 BuildRequires:  %{python_module pytest-xdist >= 1.18}
 BuildRequires:  %{python_module setuptools}
+BuildRequires:  %{python_module testsuite}
 BuildRequires:  fdupes
 BuildRequires:  python-rpm-macros
 BuildArch:      noarch
@@ -60,7 +55,8 @@
 
 %prep
 %setup -q -n %{modname}-%{version}
-%autopatch -p1
+# Workaround https://github.com/python/typing/pull/615
+sed -i 's/python -OO/python3 -OO/' src_py3/test_typing_extensions.py
 
 %build
 %python_build
@@ -71,7 +67,6 @@
 
 %check
 cd src_py3
-tar xvf %{SOURCE1}
 %__python3 test_typing_extensions.py
 
 %files %{python_files}

++++++ typing_extensions-3.6.6.tar.gz -> typing_extensions-3.7.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/typing_extensions-3.6.6/PKG-INFO 
new/typing_extensions-3.7.2/PKG-INFO
--- old/typing_extensions-3.6.6/PKG-INFO        2018-10-07 00:02:43.000000000 
+0200
+++ new/typing_extensions-3.7.2/PKG-INFO        2019-01-12 19:10:12.000000000 
+0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: typing_extensions
-Version: 3.6.6
+Version: 3.7.2
 Summary: Backported and Experimental Type Hints for Python 3.5+
 Home-page: 
https://github.com/python/typing/blob/master/typing_extensions/README.rst
 Author: Guido van Rossum, Jukka Lehtosalo, Lukasz Langa, Michael Lee
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/typing_extensions-3.6.6/setup.py 
new/typing_extensions-3.7.2/setup.py
--- old/typing_extensions-3.6.6/setup.py        2018-10-06 23:53:46.000000000 
+0200
+++ new/typing_extensions-3.7.2/setup.py        2019-01-12 16:59:40.000000000 
+0100
@@ -9,7 +9,7 @@
                      'to install the typing package.\n')
     exit(1)
 
-version = '3.6.6'
+version = '3.7.2'
 description = 'Backported and Experimental Type Hints for Python 3.5+'
 long_description = '''\
 Typing Extensions -- Backported and Experimental Type Hints for Python
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/typing_extensions-3.6.6/src_py2/test_typing_extensions.py 
new/typing_extensions-3.7.2/src_py2/test_typing_extensions.py
--- old/typing_extensions-3.6.6/src_py2/test_typing_extensions.py       
2018-10-06 23:53:24.000000000 +0200
+++ new/typing_extensions-3.7.2/src_py2/test_typing_extensions.py       
2019-01-12 16:58:29.000000000 +0100
@@ -5,9 +5,10 @@
 import collections
 import pickle
 import subprocess
+import types
 from unittest import TestCase, main, skipUnless
 
-from typing_extensions import NoReturn, ClassVar, Final
+from typing_extensions import NoReturn, ClassVar, Final, Literal
 from typing_extensions import ContextManager, Counter, Deque, DefaultDict
 from typing_extensions import NewType, overload, Protocol, runtime
 import typing
@@ -157,6 +158,65 @@
             issubclass(int, Final)
 
 
+class LiteralTests(BaseTestCase):
+    def test_basics(self):
+        Literal[1]
+        Literal[1, 2, 3]
+        Literal["x", "y", "z"]
+        Literal[None]
+
+    def test_illegal_parameters_do_not_raise_runtime_errors(self):
+        # Type checkers should reject these types, but we do not
+        # raise errors at runtime to maintain maximium flexibility
+        Literal[int]
+        Literal[Literal[1, 2], Literal[4, 5]]
+        Literal[3j + 2, ..., ()]
+        Literal[b"foo", u"bar"]
+        Literal[{"foo": 3, "bar": 4}]
+        Literal[T]
+
+    def test_literals_inside_other_types(self):
+        typing.List[Literal[1, 2, 3]]
+        typing.List[Literal[("foo", "bar", "baz")]]
+
+    def test_repr(self):
+        self.assertEqual(repr(Literal[1]), "typing_extensions.Literal[1]")
+        self.assertEqual(repr(Literal[1, True, "foo"]), 
"typing_extensions.Literal[1, True, 'foo']")
+        self.assertEqual(repr(Literal[int]), "typing_extensions.Literal[int]")
+        self.assertEqual(repr(Literal), "typing_extensions.Literal")
+        self.assertEqual(repr(Literal[None]), 
"typing_extensions.Literal[None]")
+
+    def test_cannot_init(self):
+        with self.assertRaises(TypeError):
+            Literal()
+        with self.assertRaises(TypeError):
+            Literal[1]()
+        with self.assertRaises(TypeError):
+            type(Literal)()
+        with self.assertRaises(TypeError):
+            type(Literal[1])()
+
+    def test_no_isinstance_or_issubclass(self):
+        with self.assertRaises(TypeError):
+            isinstance(1, Literal[1])
+        with self.assertRaises(TypeError):
+            isinstance(int, Literal[1])
+        with self.assertRaises(TypeError):
+            issubclass(1, Literal[1])
+        with self.assertRaises(TypeError):
+            issubclass(int, Literal[1])
+
+    def test_no_subclassing(self):
+        with self.assertRaises(TypeError):
+            class Foo(Literal[1]): pass
+        with self.assertRaises(TypeError):
+            class Bar(Literal): pass
+
+    def test_no_multiple_subscripts(self):
+        with self.assertRaises(TypeError):
+            Literal[1][1]
+
+
 class CollectionsAbcTests(BaseTestCase):
 
     def test_isinstance_collections(self):
@@ -274,20 +334,35 @@
         class D(object):
             def meth(self):
                 pass
+        def f():
+            pass
         self.assertIsSubclass(D, P)
         self.assertIsInstance(D(), P)
         self.assertNotIsSubclass(C, P)
         self.assertNotIsInstance(C(), P)
+        self.assertNotIsSubclass(types.FunctionType, P)
+        self.assertNotIsInstance(f, P)
 
     def test_everything_implements_empty_protocol(self):
         @runtime
         class Empty(Protocol): pass
         class C(object): pass
-        for thing in (object, type, tuple, C):
+        def f():
+            pass
+        for thing in (object, type, tuple, C, types.FunctionType):
             self.assertIsSubclass(thing, Empty)
-        for thing in (object(), 1, (), typing):
+        for thing in (object(), 1, (), typing, f):
             self.assertIsInstance(thing, Empty)
 
+    def test_function_implements_protocol(self):
+        @runtime
+        class Function(Protocol):
+            def __call__(self, *args, **kwargs):
+                pass
+        def f():
+            pass
+        self.assertIsInstance(f, Function)
+
     def test_no_inheritance_from_nominal(self):
         class C(object): pass
         class BP(Protocol): pass
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/typing_extensions-3.6.6/src_py2/typing_extensions.py 
new/typing_extensions-3.7.2/src_py2/typing_extensions.py
--- old/typing_extensions-3.6.6/src_py2/typing_extensions.py    2018-10-06 
23:53:24.000000000 +0200
+++ new/typing_extensions-3.7.2/src_py2/typing_extensions.py    2019-01-12 
16:58:30.000000000 +0100
@@ -27,6 +27,7 @@
 
     # One-off things.
     'final',
+    'Literal',
     'NewType',
     'overload',
     'runtime',
@@ -39,12 +40,12 @@
     NoReturn = typing.NoReturn
 else:
     # TODO: Remove once typing.py has been updated
-    class NoReturnMeta(typing.TypingMeta):
+    class _NoReturnMeta(typing.TypingMeta):
         """Metaclass for NoReturn."""
 
         def __new__(cls, name, bases, namespace):
             cls.assert_no_subclassing(bases)
-            self = super(NoReturnMeta, cls).__new__(cls, name, bases, 
namespace)
+            self = super(_NoReturnMeta, cls).__new__(cls, name, bases, 
namespace)
             return self
 
     class _NoReturn(typing._FinalTypingBase):
@@ -56,7 +57,7 @@
         This type is invalid in other positions, e.g., ``List[NoReturn]``
         will fail in static type checkers.
         """
-        __metaclass__ = NoReturnMeta
+        __metaclass__ = _NoReturnMeta
         __slots__ = ()
 
         def __instancecheck__(self, obj):
@@ -108,12 +109,12 @@
     return cls
 
 
-class FinalMeta(TypingMeta):
+class _FinalMeta(TypingMeta):
     """Metaclass for _Final"""
 
     def __new__(cls, name, bases, namespace):
         cls.assert_no_subclassing(bases)
-        self = super(FinalMeta, cls).__new__(cls, name, bases, namespace)
+        self = super(_FinalMeta, cls).__new__(cls, name, bases, namespace)
         return self
 
 
@@ -133,7 +134,7 @@
     There is no runtime checking of these properties.
     """
 
-    __metaclass__ = FinalMeta
+    __metaclass__ = _FinalMeta
     __slots__ = ('__type__',)
 
     def __init__(self, tp=None, **kwds):
@@ -196,6 +197,67 @@
     return f
 
 
+class _LiteralMeta(TypingMeta):
+    """Metaclass for _Literal"""
+
+    def __new__(cls, name, bases, namespace):
+        cls.assert_no_subclassing(bases)
+        self = super(_LiteralMeta, cls).__new__(cls, name, bases, namespace)
+        return self
+
+
+class _Literal(typing._FinalTypingBase):
+    """A type that can be used to indicate to type checkers that the
+    corresponding value has a value literally equivalent to the
+    provided parameter. For example:
+
+        var: Literal[4] = 4
+    
+    The type checker understands that 'var' is literally equal to the
+    value 4 and no other value.
+
+    Literal[...] cannot be subclassed. There is no runtime checking
+    verifying that the parameter is actually a value instead of a type.
+    """
+
+    __metaclass__ = _LiteralMeta
+    __slots__ = ('__values__',)
+
+    def __init__(self, values=None, **kwds):
+        self.__values__ = values
+
+    def __getitem__(self, item):
+        cls = type(self)
+        if self.__values__ is None:
+            if not isinstance(item, tuple):
+                item = (item,)
+            return cls(values=item,
+                       _root=True)
+        raise TypeError('{} cannot be further subscripted'
+                        .format(cls.__name__[1:]))
+
+    def _eval_type(self, globalns, localns):
+        return self
+
+    def __repr__(self):
+        r = super(_Literal, self).__repr__()
+        if self.__values__ is not None:
+            r += '[{}]'.format(', '.join(map(typing._type_repr, 
self.__values__)))
+        return r
+
+    def __hash__(self):
+        return hash((type(self).__name__, self.__values__))
+
+    def __eq__(self, other):
+        if not isinstance(other, _Literal):
+            return NotImplemented
+        if self.__values__ is not None:
+            return self.__values__ == other.__values__
+        return self is other
+
+Literal = _Literal(_root=True)
+
+
 class _ProtocolMeta(GenericMeta):
     """Internal metaclass for Protocol.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/typing_extensions-3.6.6/src_py3/test_typing_extensions.py 
new/typing_extensions-3.7.2/src_py3/test_typing_extensions.py
--- old/typing_extensions-3.6.6/src_py3/test_typing_extensions.py       
2018-10-06 23:53:24.000000000 +0200
+++ new/typing_extensions-3.7.2/src_py3/test_typing_extensions.py       
2019-01-12 16:58:30.000000000 +0100
@@ -5,6 +5,7 @@
 import collections
 import pickle
 import subprocess
+import types
 from unittest import TestCase, main, skipUnless
 from typing import TypeVar, Optional
 from typing import T, KT, VT  # Not in __all__.
@@ -12,7 +13,7 @@
 from typing import Generic
 from typing import get_type_hints
 from typing import no_type_check
-from typing_extensions import NoReturn, ClassVar, Final, Type, NewType
+from typing_extensions import NoReturn, ClassVar, Final, Literal, Type, NewType
 try:
     from typing_extensions import Protocol, runtime
 except ImportError:
@@ -211,6 +212,64 @@
         with self.assertRaises(TypeError):
             issubclass(int, Final)
 
+class LiteralTests(BaseTestCase):
+    def test_basics(self):
+        Literal[1]
+        Literal[1, 2, 3]
+        Literal["x", "y", "z"]
+        Literal[None]
+
+    def test_illegal_parameters_do_not_raise_runtime_errors(self):
+        # Type checkers should reject these types, but we do not
+        # raise errors at runtime to maintain maximium flexibility
+        Literal[int]
+        Literal[Literal[1, 2], Literal[4, 5]]
+        Literal[3j + 2, ..., ()]
+        Literal[b"foo", u"bar"]
+        Literal[{"foo": 3, "bar": 4}]
+        Literal[T]
+
+    def test_literals_inside_other_types(self):
+        List[Literal[1, 2, 3]]
+        List[Literal[("foo", "bar", "baz")]]
+
+    def test_repr(self):
+        self.assertEqual(repr(Literal[1]), "typing_extensions.Literal[1]")
+        self.assertEqual(repr(Literal[1, True, "foo"]), 
"typing_extensions.Literal[1, True, 'foo']")
+        self.assertEqual(repr(Literal[int]), "typing_extensions.Literal[int]")
+        self.assertEqual(repr(Literal), "typing_extensions.Literal")
+        self.assertEqual(repr(Literal[None]), 
"typing_extensions.Literal[None]")
+
+    def test_cannot_init(self):
+        with self.assertRaises(TypeError):
+            Literal()
+        with self.assertRaises(TypeError):
+            Literal[1]()
+        with self.assertRaises(TypeError):
+            type(Literal)()
+        with self.assertRaises(TypeError):
+            type(Literal[1])()
+
+    def test_no_isinstance_or_issubclass(self):
+        with self.assertRaises(TypeError):
+            isinstance(1, Literal[1])
+        with self.assertRaises(TypeError):
+            isinstance(int, Literal[1])
+        with self.assertRaises(TypeError):
+            issubclass(1, Literal[1])
+        with self.assertRaises(TypeError):
+            issubclass(int, Literal[1])
+
+    def test_no_subclassing(self):
+        with self.assertRaises(TypeError):
+            class Foo(Literal[1]): pass
+        with self.assertRaises(TypeError):
+            class Bar(Literal): pass
+
+    def test_no_multiple_subscripts(self):
+        with self.assertRaises(TypeError):
+            Literal[1][1]
+
 
 class OverloadTests(BaseTestCase):
 
@@ -318,6 +377,11 @@
     def __add__(self, other):
         return 0
 
+@runtime
+class HasCallProtocol(Protocol):
+    __call__: typing.Callable
+
+
 async def g_with(am: AsyncContextManager[int]):
     x: int
     async with am as x:
@@ -335,7 +399,7 @@
     # fake names for the sake of static analysis
     ann_module = ann_module2 = ann_module3 = None
     A = B = CSub = G = CoolEmployee = CoolEmployeeWithDefault = object
-    XMeth = XRepr = NoneAndForward = Loop = object
+    XMeth = XRepr = HasCallProtocol = NoneAndForward = Loop = object
 
 gth = get_type_hints
 
@@ -739,20 +803,32 @@
             class D:
                 def meth(self):
                     pass
+            def f():
+                pass
             self.assertIsSubclass(D, P)
             self.assertIsInstance(D(), P)
             self.assertNotIsSubclass(C, P)
             self.assertNotIsInstance(C(), P)
+            self.assertNotIsSubclass(types.FunctionType, P)
+            self.assertNotIsInstance(f, P)
 
         def test_everything_implements_empty_protocol(self):
             @runtime
             class Empty(Protocol): pass
             class C: pass
-            for thing in (object, type, tuple, C):
+            def f():
+                pass
+            for thing in (object, type, tuple, C, types.FunctionType):
                 self.assertIsSubclass(thing, Empty)
-            for thing in (object(), 1, (), typing):
+            for thing in (object(), 1, (), typing, f):
                 self.assertIsInstance(thing, Empty)
 
+        @skipUnless(PY36, 'Python 3.6 required')
+        def test_function_implements_protocol(self):
+            def f():
+                pass
+            self.assertIsInstance(f, HasCallProtocol)
+
         def test_no_inheritance_from_nominal(self):
             class C: pass
             class BP(Protocol): pass
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/typing_extensions-3.6.6/src_py3/typing_extensions.egg-info/PKG-INFO 
new/typing_extensions-3.7.2/src_py3/typing_extensions.egg-info/PKG-INFO
--- old/typing_extensions-3.6.6/src_py3/typing_extensions.egg-info/PKG-INFO     
2018-10-07 00:02:43.000000000 +0200
+++ new/typing_extensions-3.7.2/src_py3/typing_extensions.egg-info/PKG-INFO     
2019-01-12 19:10:12.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: typing-extensions
-Version: 3.6.6
+Version: 3.7.2
 Summary: Backported and Experimental Type Hints for Python 3.5+
 Home-page: 
https://github.com/python/typing/blob/master/typing_extensions/README.rst
 Author: Guido van Rossum, Jukka Lehtosalo, Lukasz Langa, Michael Lee
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/typing_extensions-3.6.6/src_py3/typing_extensions.py 
new/typing_extensions-3.7.2/src_py3/typing_extensions.py
--- old/typing_extensions-3.6.6/src_py3/typing_extensions.py    2018-10-06 
23:53:24.000000000 +0200
+++ new/typing_extensions-3.7.2/src_py3/typing_extensions.py    2019-01-12 
16:58:30.000000000 +0100
@@ -126,6 +126,7 @@
 
     # One-off things.
     'final',
+    'Literal',
     'NewType',
     'overload',
     'Text',
@@ -164,7 +165,7 @@
 
     NoReturn = _NoReturn(_root=True)
 else:
-    class NoReturnMeta(typing.TypingMeta):
+    class _NoReturnMeta(typing.TypingMeta):
         """Metaclass for NoReturn"""
         def __new__(cls, name, bases, namespace, _root=False):
             return super().__new__(cls, name, bases, namespace, _root=_root)
@@ -175,7 +176,7 @@
         def __subclasscheck__(self, cls):
             raise TypeError("NoReturn cannot be used with issubclass().")
 
-    class NoReturn(typing.Final, metaclass=NoReturnMeta, _root=True):
+    class NoReturn(typing.Final, metaclass=_NoReturnMeta, _root=True):
         """Special type indicating functions that never return.
         Example::
 
@@ -259,7 +260,7 @@
 
     ClassVar = _ClassVar(_root=True)
 else:
-    class ClassVarMeta(typing.TypingMeta):
+    class _ClassVarMeta(typing.TypingMeta):
         """Metaclass for ClassVar"""
 
         def __new__(cls, name, bases, namespace, tp=None, _root=False):
@@ -310,7 +311,7 @@
                 return self.__type__ == other.__type__
             return self is other
 
-    class ClassVar(typing.Final, metaclass=ClassVarMeta, _root=True):
+    class ClassVar(typing.Final, metaclass=_ClassVarMeta, _root=True):
         """Special type construct to mark class variables.
 
         An annotation wrapped in ClassVar indicates that a given
@@ -410,7 +411,7 @@
 
     Final = _Final(_root=True)
 else:
-    class FinalMeta(typing.TypingMeta):
+    class _FinalMeta(typing.TypingMeta):
         """Metaclass for Final"""
 
         def __new__(cls, name, bases, namespace, tp=None, _root=False):
@@ -461,7 +462,7 @@
                 return self.__type__ == other.__type__
             return self is other
 
-    class Final(typing.Final, metaclass=FinalMeta, _root=True):
+    class Final(typing.Final, metaclass=_FinalMeta, _root=True):
         """A special typing construct to indicate that a name
         cannot be re-assigned or overridden in a subclass.
         For example:
@@ -503,6 +504,142 @@
     return f
 
 
+if hasattr(typing, 'Literal'):
+    Literal = typing.Literal 
+elif sys.version_info[:2] >= (3, 7):
+    class _LiteralForm(typing._SpecialForm, _root=True):
+
+        def __repr__(self):
+            return 'typing_extensions.' + self._name
+
+        def __getitem__(self, parameters):
+            return _GenericAlias(self, parameters)
+
+    Literal = _LiteralForm('Literal', doc=
+        """A type that can be used to indicate to type checkers that the
+        corresponding value has a value literally equivalent to the
+        provided parameter. For example:
+
+            var: Literal[4] = 4
+        
+        The type checker understands that 'var' is literally equal to the
+        value 4 and no other value.
+
+        Literal[...] cannot be subclassed. There is no runtime checking
+        verifying that the parameter is actually a value instead of a type.
+        """)
+elif hasattr(typing, '_FinalTypingBase'):
+    class _Literal(typing._FinalTypingBase, _root=True):
+        """A type that can be used to indicate to type checkers that the
+        corresponding value has a value literally equivalent to the
+        provided parameter. For example:
+
+            var: Literal[4] = 4
+        
+        The type checker understands that 'var' is literally equal to the
+        value 4 and no other value.
+
+        Literal[...] cannot be subclassed. There is no runtime checking
+        verifying that the parameter is actually a value instead of a type.
+        """
+
+        __slots__ = ('__values__',)
+
+        def __init__(self, values=None, **kwds):
+            self.__values__ = values
+
+        def __getitem__(self, values):
+            cls = type(self)
+            if self.__values__ is None:
+                if not isinstance(values, tuple):
+                    values = (values,)
+                return cls(values, _root=True)
+            raise TypeError('{} cannot be further subscripted'
+                            .format(cls.__name__[1:]))
+
+        def _eval_type(self, globalns, localns):
+            return self
+
+        def __repr__(self):
+            r = super().__repr__()
+            if self.__values__ is not None:
+                r += '[{}]'.format(', '.join(map(typing._type_repr, 
self.__values__)))
+            return r
+
+        def __hash__(self):
+            return hash((type(self).__name__, self.__values__))
+
+        def __eq__(self, other):
+            if not isinstance(other, _Literal):
+                return NotImplemented
+            if self.__values__ is not None:
+                return self.__values__ == other.__values__
+            return self is other
+
+    Literal = _Literal(_root=True)
+else:
+    class _LiteralMeta(typing.TypingMeta):
+        """Metaclass for Literal"""
+
+        def __new__(cls, name, bases, namespace, values=None, _root=False):
+            self = super().__new__(cls, name, bases, namespace, _root=_root)
+            if values is not None:
+                self.__values__ = values
+            return self
+
+        def __instancecheck__(self, obj):
+            raise TypeError("Literal cannot be used with isinstance().")
+
+        def __subclasscheck__(self, cls):
+            raise TypeError("Literal cannot be used with issubclass().")
+
+        def __getitem__(self, item):
+            cls = type(self)
+            if self.__values__ is not None:
+                raise TypeError('{} cannot be further subscripted'
+                                .format(cls.__name__[1:]))
+
+            if not isinstance(item, tuple):
+                item = (item,)
+            return cls(self.__name__, self.__bases__,
+                       dict(self.__dict__), values=item, _root=True)
+
+        def _eval_type(self, globalns, localns):
+            return self
+
+        def __repr__(self):
+            r = super().__repr__()
+            if self.__values__ is not None:
+                r += '[{}]'.format(', '.join(map(typing._type_repr, 
self.__values__)))
+            return r
+
+        def __hash__(self):
+            return hash((type(self).__name__, self.__values__))
+
+        def __eq__(self, other):
+            if not isinstance(other, Literal):
+                return NotImplemented
+            if self.__values__ is not None:
+                return self.__values__ == other.__values__
+            return self is other
+
+    class Literal(typing.Final, metaclass=_LiteralMeta, _root=True):
+        """A type that can be used to indicate to type checkers that the
+        corresponding value has a value literally equivalent to the
+        provided parameter. For example:
+
+            var: Literal[4] = 4
+        
+        The type checker understands that 'var' is literally equal to the
+        value 4 and no other value.
+
+        Literal[...] cannot be subclassed. There is no runtime checking
+        verifying that the parameter is actually a value instead of a type.
+        """
+
+        __values__ = None
+
+
 def _overload_dummy(*args, **kwds):
     """Helper for @overload to raise when called."""
     raise NotImplementedError(
@@ -771,14 +908,14 @@
     assert _geqv_defined
     _TInt = typing.TypeVar('_TInt')
 
-    class CounterMeta(typing.GenericMeta):
+    class _CounterMeta(typing.GenericMeta):
         """Metaclass for Counter"""
         def __getitem__(self, item):
             return super().__getitem__((item, int))
 
     class Counter(collections.Counter,
                   typing.Dict[T, int],
-                  metaclass=CounterMeta,
+                  metaclass=_CounterMeta,
                   extra=collections.Counter):
 
         __slots__ = ()
@@ -1043,7 +1180,8 @@
                             if base.__dict__[attr] is None:
                                 return NotImplemented
                             break
-                        if (attr in getattr(base, '__annotations__', {}) and
+                        annotations = getattr(base, '__annotations__', {})
+                        if (isinstance(annotations, typing.Mapping) and attr 
in annotations and
                                 isinstance(other, _ProtocolMeta) and 
other._is_protocol):
                             break
                     else:
@@ -1328,7 +1466,8 @@
                             if base.__dict__[attr] is None:
                                 return NotImplemented
                             break
-                        if (attr in getattr(base, '__annotations__', {}) and
+                        annotations = getattr(base, '__annotations__', {})
+                        if (isinstance(annotations, typing.Mapping) and attr 
in annotations and
                                 isinstance(other, _ProtocolMeta) and 
other._is_protocol):
                             break
                     else:


Reply via email to