Hello community,

here is the log from the commit of package python-typing_extensions for 
openSUSE:Factory checked in at 2020-04-07 10:26:16
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-typing_extensions (Old)
 and      /work/SRC/openSUSE:Factory/.python-typing_extensions.new.3248 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-typing_extensions"

Tue Apr  7 10:26:16 2020 rev:7 rq:791701 version:3.7.4.2

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-typing_extensions/python-typing_extensions.changes
        2020-03-27 00:21:12.548132550 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-typing_extensions.new.3248/python-typing_extensions.changes
      2020-04-07 10:26:23.326167196 +0200
@@ -1,0 +2,6 @@
+Mon Apr  6 08:53:23 UTC 2020 - Marketa Calabkova <[email protected]>
+
+- update to version 3.7.4.2
+  * official support for Python 3.8 and 3.9
+
+-------------------------------------------------------------------

Old:
----
  typing_extensions-3.7.4.1.tar.gz

New:
----
  typing_extensions-3.7.4.2.tar.gz

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

Other differences:
------------------
++++++ python-typing_extensions.spec ++++++
--- /var/tmp/diff_new_pack.D1rXPB/_old  2020-04-07 10:26:24.450168445 +0200
+++ /var/tmp/diff_new_pack.D1rXPB/_new  2020-04-07 10:26:24.454168449 +0200
@@ -20,7 +20,7 @@
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 %bcond_without python2
 Name:           python-typing_extensions
-Version:        3.7.4.1
+Version:        3.7.4.2
 Release:        0
 Summary:        Backported and Experimental Type Hints for Python 35+
 License:        Python-2.0

++++++ typing_extensions-3.7.4.1.tar.gz -> typing_extensions-3.7.4.2.tar.gz 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/typing_extensions-3.7.4.1/PKG-INFO 
new/typing_extensions-3.7.4.2/PKG-INFO
--- old/typing_extensions-3.7.4.1/PKG-INFO      2019-10-28 14:28:10.000000000 
+0100
+++ new/typing_extensions-3.7.4.2/PKG-INFO      2020-04-02 19:20:22.907262800 
+0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: typing_extensions
-Version: 3.7.4.1
+Version: 3.7.4.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
@@ -35,4 +35,6 @@
 Classifier: Programming Language :: Python :: 3.5
 Classifier: Programming Language :: Python :: 3.6
 Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
 Classifier: Topic :: Software Development
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/typing_extensions-3.7.4.1/setup.py 
new/typing_extensions-3.7.4.2/setup.py
--- old/typing_extensions-3.7.4.1/setup.py      2019-10-28 14:15:18.000000000 
+0100
+++ new/typing_extensions-3.7.4.2/setup.py      2020-04-02 19:19:42.000000000 
+0200
@@ -9,7 +9,7 @@
                      'to install the typing package.\n')
     exit(1)
 
-version = '3.7.4.1'
+version = '3.7.4.2'
 description = 'Backported and Experimental Type Hints for Python 3.5+'
 long_description = '''\
 Typing Extensions -- Backported and Experimental Type Hints for Python
@@ -41,6 +41,8 @@
     'Programming Language :: Python :: 3.5',
     'Programming Language :: Python :: 3.6',
     'Programming Language :: Python :: 3.7',
+    'Programming Language :: Python :: 3.8',
+    'Programming Language :: Python :: 3.9',
     'Topic :: Software Development',
 ]
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/typing_extensions-3.7.4.1/src_py3/test_typing_extensions.py 
new/typing_extensions-3.7.4.2/src_py3/test_typing_extensions.py
--- old/typing_extensions-3.7.4.1/src_py3/test_typing_extensions.py     
2019-08-10 20:55:22.000000000 +0200
+++ new/typing_extensions-3.7.4.2/src_py3/test_typing_extensions.py     
2020-02-12 01:51:39.000000000 +0100
@@ -6,7 +6,7 @@
 import pickle
 import subprocess
 import types
-from unittest import TestCase, main, skipUnless
+from unittest import TestCase, main, skipUnless, skipIf
 from typing import TypeVar, Optional
 from typing import T, KT, VT  # Not in __all__.
 from typing import Tuple, List, Dict, Iterator
@@ -328,7 +328,6 @@
 
 
 ASYNCIO_TESTS = """
-import asyncio
 from typing import Iterable
 from typing_extensions import Awaitable, AsyncIterator
 
@@ -351,9 +350,8 @@
     def __aiter__(self) -> AsyncIterator[T_a]:
         return self
 
-    @asyncio.coroutine
-    def __anext__(self) -> T_a:
-        data = yield from self.value
+    async def __anext__(self) -> T_a:
+        data = await self.value
         if data:
             return data
         else:
@@ -428,11 +426,24 @@
     x: int
     y: int
 
+class Point2Dor3D(Point2D, total=False):
+    z: int
+
 class LabelPoint2D(Point2D, Label): ...
 
 class Options(TypedDict, total=False):
     log_level: int
     log_path: str
+
+class BaseAnimal(TypedDict):
+    name: str
+
+class Animal(BaseAnimal, total=False):
+    voice: str
+    tail: bool
+
+class Cat(Animal):
+    fur_color: str
 """
 
 if PY36:
@@ -442,7 +453,8 @@
     ann_module = ann_module2 = ann_module3 = None
     A = B = CSub = G = CoolEmployee = CoolEmployeeWithDefault = object
     XMeth = XRepr = HasCallProtocol = NoneAndForward = Loop = object
-    Point2D = LabelPoint2D = Options = object
+    Point2D = Point2Dor3D = LabelPoint2D = Options = object
+    BaseAnimal = Animal = Cat = object
 
 gth = get_type_hints
 
@@ -1445,9 +1457,43 @@
         self.assertEqual(Emp.__annotations__, {'name': str, 'id': int})
         self.assertEqual(Emp.__total__, True)
 
+    def test_typeddict_special_keyword_names(self):
+        TD = TypedDict("TD", cls=type, self=object, typename=str, 
_typename=int,
+                       fields=list, _fields=dict)
+        self.assertEqual(TD.__name__, 'TD')
+        self.assertEqual(TD.__annotations__, {'cls': type, 'self': object, 
'typename': str,
+                                              '_typename': int, 'fields': 
list, '_fields': dict})
+        a = TD(cls=str, self=42, typename='foo', _typename=53,
+               fields=[('bar', tuple)], _fields={'baz', set})
+        self.assertEqual(a['cls'], str)
+        self.assertEqual(a['self'], 42)
+        self.assertEqual(a['typename'], 'foo')
+        self.assertEqual(a['_typename'], 53)
+        self.assertEqual(a['fields'], [('bar', tuple)])
+        self.assertEqual(a['_fields'], {'baz', set})
+
+    @skipIf(hasattr(typing, 'TypedDict'), "Should be tested by upstream")
+    def test_typeddict_create_errors(self):
+        with self.assertRaises(TypeError):
+            TypedDict.__new__()
+        with self.assertRaises(TypeError):
+            TypedDict()
+        with self.assertRaises(TypeError):
+            TypedDict('Emp', [('name', str)], None)
+
+        with self.assertWarns(DeprecationWarning):
+            Emp = TypedDict(_typename='Emp', name=str, id=int)
+        self.assertEqual(Emp.__name__, 'Emp')
+        self.assertEqual(Emp.__annotations__, {'name': str, 'id': int})
+
+        with self.assertWarns(DeprecationWarning):
+            Emp = TypedDict('Emp', _fields={'name': str, 'id': int})
+        self.assertEqual(Emp.__name__, 'Emp')
+        self.assertEqual(Emp.__annotations__, {'name': str, 'id': int})
+
     def test_typeddict_errors(self):
         Emp = TypedDict('Emp', {'name': str, 'id': int})
-        if hasattr(typing, 'TypedDict'):
+        if sys.version_info[:2] >= (3, 9):
             self.assertEqual(TypedDict.__module__, 'typing')
         else:
             self.assertEqual(TypedDict.__module__, 'typing_extensions')
@@ -1509,6 +1555,34 @@
             self.assertEqual(Options(log_level=2), {'log_level': 2})
             self.assertEqual(Options.__total__, False)
 
+    @skipUnless(PY36, 'Python 3.6 required')
+    def test_optional_keys(self):
+        assert Point2Dor3D.__required_keys__ == frozenset(['x', 'y'])
+        assert Point2Dor3D.__optional_keys__ == frozenset(['z'])
+
+    @skipUnless(PY36, 'Python 3.6 required')
+    def test_keys_inheritance(self):
+        assert BaseAnimal.__required_keys__ == frozenset(['name'])
+        assert BaseAnimal.__optional_keys__ == frozenset([])
+        assert BaseAnimal.__annotations__ == {'name': str}
+
+        assert Animal.__required_keys__ == frozenset(['name'])
+        assert Animal.__optional_keys__ == frozenset(['tail', 'voice'])
+        assert Animal.__annotations__ == {
+            'name': str,
+            'tail': bool,
+            'voice': str,
+        }
+
+        assert Cat.__required_keys__ == frozenset(['name', 'fur_color'])
+        assert Cat.__optional_keys__ == frozenset(['tail', 'voice'])
+        assert Cat.__annotations__ == {
+            'fur_color': str,
+            'name': str,
+            'tail': bool,
+            'voice': str,
+        }
+
 
 @skipUnless(TYPING_3_5_3, "Python >= 3.5.3 required")
 class AnnotatedTests(BaseTestCase):
@@ -1783,7 +1857,16 @@
             self.assertIn('runtime', a)
 
     def test_typing_extensions_defers_when_possible(self):
-        exclude = {'overload', 'Text', 'TYPE_CHECKING', 'Final', 
'get_type_hints'}
+        exclude = {
+            'overload',
+            'Text',
+            'TypedDict',
+            'TYPE_CHECKING',
+            'Final',
+            'get_type_hints'
+        }
+        if sys.version_info[:2] == (3, 8):
+            exclude |= {'get_args', 'get_origin'}
         for item in typing_extensions.__all__:
             if item not in exclude and hasattr(typing, item):
                 self.assertIs(
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/typing_extensions-3.7.4.1/src_py3/typing_extensions.egg-info/PKG-INFO 
new/typing_extensions-3.7.4.2/src_py3/typing_extensions.egg-info/PKG-INFO
--- old/typing_extensions-3.7.4.1/src_py3/typing_extensions.egg-info/PKG-INFO   
2019-10-28 14:28:10.000000000 +0100
+++ new/typing_extensions-3.7.4.2/src_py3/typing_extensions.egg-info/PKG-INFO   
2020-04-02 19:20:22.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: typing-extensions
-Version: 3.7.4.1
+Version: 3.7.4.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
@@ -35,4 +35,6 @@
 Classifier: Programming Language :: Python :: 3.5
 Classifier: Programming Language :: Python :: 3.6
 Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
 Classifier: Topic :: Software Development
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/typing_extensions-3.7.4.1/src_py3/typing_extensions.py 
new/typing_extensions-3.7.4.2/src_py3/typing_extensions.py
--- old/typing_extensions-3.7.4.1/src_py3/typing_extensions.py  2019-08-10 
20:55:22.000000000 +0200
+++ new/typing_extensions-3.7.4.2/src_py3/typing_extensions.py  2020-02-12 
01:51:39.000000000 +0100
@@ -151,7 +151,7 @@
 HAVE_ANNOTATED = PEP_560 or SUBS_TREE
 
 if PEP_560:
-    __all__.append("get_type_hints")
+    __all__.extend(["get_args", "get_origin", "get_type_hints"])
 
 if HAVE_ANNOTATED:
     __all__.append("Annotated")
@@ -1569,7 +1569,9 @@
     runtime = runtime_checkable
 
 
-if hasattr(typing, 'TypedDict'):
+if sys.version_info[:2] >= (3, 9):
+    # The standard library TypedDict in Python 3.8 does not store runtime 
information
+    # about which (if any) keys are optional.  See 
https://bugs.python.org/issue38834
     TypedDict = typing.TypedDict
 else:
     def _check_fails(cls, other):
@@ -1583,25 +1585,60 @@
             pass
         return False
 
-    def _dict_new(cls, *args, **kwargs):
+    def _dict_new(*args, **kwargs):
+        if not args:
+            raise TypeError('TypedDict.__new__(): not enough arguments')
+        _, args = args[0], args[1:]  # allow the "cls" keyword be passed
         return dict(*args, **kwargs)
 
-    def _typeddict_new(cls, _typename, _fields=None, **kwargs):
-        total = kwargs.pop('total', True)
-        if _fields is None:
-            _fields = kwargs
+    _dict_new.__text_signature__ = '($cls, _typename, _fields=None, /, 
**kwargs)'
+
+    def _typeddict_new(*args, total=True, **kwargs):
+        if not args:
+            raise TypeError('TypedDict.__new__(): not enough arguments')
+        _, args = args[0], args[1:]  # allow the "cls" keyword be passed
+        if args:
+            typename, args = args[0], args[1:]  # allow the "_typename" 
keyword be passed
+        elif '_typename' in kwargs:
+            typename = kwargs.pop('_typename')
+            import warnings
+            warnings.warn("Passing '_typename' as keyword argument is 
deprecated",
+                          DeprecationWarning, stacklevel=2)
+        else:
+            raise TypeError("TypedDict.__new__() missing 1 required positional 
"
+                            "argument: '_typename'")
+        if args:
+            try:
+                fields, = args  # allow the "_fields" keyword be passed
+            except ValueError:
+                raise TypeError('TypedDict.__new__() takes from 2 to 3 '
+                                'positional arguments but {} '
+                                'were given'.format(len(args) + 2))
+        elif '_fields' in kwargs and len(kwargs) == 1:
+            fields = kwargs.pop('_fields')
+            import warnings
+            warnings.warn("Passing '_fields' as keyword argument is 
deprecated",
+                          DeprecationWarning, stacklevel=2)
+        else:
+            fields = None
+
+        if fields is None:
+            fields = kwargs
         elif kwargs:
             raise TypeError("TypedDict takes either a dict or keyword 
arguments,"
                             " but not both")
 
-        ns = {'__annotations__': dict(_fields), '__total__': total}
+        ns = {'__annotations__': dict(fields), '__total__': total}
         try:
             # Setting correct module is necessary to make typed dict classes 
pickleable.
             ns['__module__'] = sys._getframe(1).f_globals.get('__name__', 
'__main__')
         except (AttributeError, ValueError):
             pass
 
-        return _TypedDictMeta(_typename, (), ns)
+        return _TypedDictMeta(typename, (), ns)
+
+    _typeddict_new.__text_signature__ = ('($cls, _typename, _fields=None,'
+                                         ' /, *, total=True, **kwargs)')
 
     class _TypedDictMeta(type):
         def __new__(cls, name, bases, ns, total=True):
@@ -1614,12 +1651,30 @@
             ns['__new__'] = _typeddict_new if name == 'TypedDict' else 
_dict_new
             tp_dict = super(_TypedDictMeta, cls).__new__(cls, name, (dict,), 
ns)
 
-            anns = ns.get('__annotations__', {})
+            annotations = {}
+            own_annotations = ns.get('__annotations__', {})
+            own_annotation_keys = set(own_annotations.keys())
             msg = "TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a 
type"
-            anns = {n: typing._type_check(tp, msg) for n, tp in anns.items()}
+            own_annotations = {
+                n: typing._type_check(tp, msg) for n, tp in 
own_annotations.items()
+            }
+            required_keys = set()
+            optional_keys = set()
+
             for base in bases:
-                anns.update(base.__dict__.get('__annotations__', {}))
-            tp_dict.__annotations__ = anns
+                annotations.update(base.__dict__.get('__annotations__', {}))
+                required_keys.update(base.__dict__.get('__required_keys__', 
()))
+                optional_keys.update(base.__dict__.get('__optional_keys__', 
()))
+
+            annotations.update(own_annotations)
+            if total:
+                required_keys.update(own_annotation_keys)
+            else:
+                optional_keys.update(own_annotation_keys)
+
+            tp_dict.__annotations__ = annotations
+            tp_dict.__required_keys__ = frozenset(required_keys)
+            tp_dict.__optional_keys__ = frozenset(optional_keys)
             if not hasattr(tp_dict, '__total__'):
                 tp_dict.__total__ = total
             return tp_dict
@@ -1647,8 +1702,9 @@
 
             assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, 
label='first')
 
-        The type info could be accessed via Point2D.__annotations__. TypedDict
-        supports two additional equivalent forms::
+        The type info can be accessed via the Point2D.__annotations__ dict, and
+        the Point2D.__required_keys__ and Point2D.__optional_keys__ frozensets.
+        TypedDict supports two additional equivalent forms::
 
             Point2D = TypedDict('Point2D', x=int, y=int, label=str)
             Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})
@@ -1658,7 +1714,14 @@
         """
 
 
-if PEP_560:
+# Python 3.9+ has PEP 593 (Annotated and modified get_type_hints)
+if hasattr(typing, 'Annotated'):
+    Annotated = typing.Annotated
+    get_type_hints = typing.get_type_hints
+    # Not exported and not a public API, but needed for get_origin() and 
get_args()
+    # to work.
+    _AnnotatedAlias = typing._AnnotatedAlias
+elif PEP_560:
     class _AnnotatedAlias(typing._GenericAlias, _root=True):
         """Runtime representation of an annotated type.
 
@@ -1943,3 +2006,53 @@
             OptimizedList = Annotated[List[T], runtime.Optimize()]
             OptimizedList[int] == Annotated[List[int], runtime.Optimize()]
         """
+
+# Python 3.8 has get_origin() and get_args() but those implementations aren't
+# Annotated-aware, so we can't use those, only Python 3.9 versions will do.
+if sys.version_info[:2] >= (3, 9):
+    get_origin = typing.get_origin
+    get_args = typing.get_args
+elif PEP_560:
+    from typing import _GenericAlias  # noqa
+
+    def get_origin(tp):
+        """Get the unsubscripted version of a type.
+
+        This supports generic types, Callable, Tuple, Union, Literal, Final, 
ClassVar
+        and Annotated. Return None for unsupported types. Examples::
+
+            get_origin(Literal[42]) is Literal
+            get_origin(int) is None
+            get_origin(ClassVar[int]) is ClassVar
+            get_origin(Generic) is Generic
+            get_origin(Generic[T]) is Generic
+            get_origin(Union[T, int]) is Union
+            get_origin(List[Tuple[T, T]][int]) == list
+        """
+        if isinstance(tp, _AnnotatedAlias):
+            return Annotated
+        if isinstance(tp, _GenericAlias):
+            return tp.__origin__
+        if tp is Generic:
+            return Generic
+        return None
+
+    def get_args(tp):
+        """Get type arguments with all substitutions performed.
+
+        For unions, basic simplifications used by Union constructor are 
performed.
+        Examples::
+            get_args(Dict[str, int]) == (str, int)
+            get_args(int) == ()
+            get_args(Union[int, Union[T, int], str][int]) == (int, str)
+            get_args(Union[int, Tuple[T, int]][str]) == (int, Tuple[str, int])
+            get_args(Callable[[], T][int]) == ([], int)
+        """
+        if isinstance(tp, _AnnotatedAlias):
+            return (tp.__origin__,) + tp.__metadata__
+        if isinstance(tp, _GenericAlias):
+            res = tp.__args__
+            if get_origin(tp) is collections.abc.Callable and res[0] is not 
Ellipsis:
+                res = (list(res[:-1]), res[-1])
+            return res
+        return ()


Reply via email to