Skip to content

Type error in typing._get_type_vars() for Dict[typing.Callable[..., str], str] #259

Closed
@jonatlib

Description

@jonatlib

When using typing for Dict where key or value can be Callable which has Ellipsis in argument it leads to TypeError: 'ellipsis' object is not iterable.

Example:

Input:

import typing
typing.Dict[typing.Callable[..., str], str]

Output:

----> 1 typing.Dict[typing.Callable[..., str], str]

/usr/lib/python3.5/typing.py in __getitem__(self, params)
   1023                     "Too %s parameters for %s; actual %s, expected %s" %
   1024                     ("many" if alen > elen else "few", repr(self), alen, elen))
-> 1025             tvars = _type_vars(params)
   1026             args = params
   1027         return self.__class__(self.__name__,

/usr/lib/python3.5/typing.py in _type_vars(types)
    282 def _type_vars(types):
    283     tvars = []
--> 284     _get_type_vars(types, tvars)
    285     return tuple(tvars)
    286 

/usr/lib/python3.5/typing.py in _get_type_vars(types, tvars)
    277     for t in types:
    278         if isinstance(t, TypingMeta):
--> 279             t._get_type_vars(tvars)
    280 
    281 

/usr/lib/python3.5/typing.py in _get_type_vars(self, tvars)
    784     def _get_type_vars(self, tvars):
    785         if self.__args__:
--> 786             _get_type_vars(self.__args__, tvars)
    787 
    788     def _eval_type(self, globalns, localns):

/usr/lib/python3.5/typing.py in _get_type_vars(types, tvars)
    275 
    276 def _get_type_vars(types, tvars):
--> 277     for t in types:
    278         if isinstance(t, TypingMeta):
    279             t._get_type_vars(tvars)

TypeError: 'ellipsis' object is not iterable

This happens even on master. First saw in python 3.5.2.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions