Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jonatlib opened this issue Aug 4, 2016 · 6 comments
Assignees

Comments

@jonatlib
Copy link

jonatlib commented Aug 4, 2016

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.

@gvanrossum
Copy link
Member

Is this Python 3.5.2 or older?

--Guido (mobile)

On Aug 4, 2016 1:47 AM, "Libor Jonát" notifications@github.com wrote:

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


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#259, or mute the thread
https://github.com/notifications/unsubscribe-auth/ACwrMu1jk8GEn9p2QxEzbQIfG7paOENPks5qcacGgaJpZM4JceSM
.

@vitawasalreadytaken
Copy link

It's 3.5.2. I can't replicate this in 3.5.1.

@gvanrossum gvanrossum added the bug label Aug 4, 2016
@gvanrossum gvanrossum self-assigned this Aug 4, 2016
@gvanrossum
Copy link
Member

OK, thanks! Should be easy to fix.

@ErikBjare
Copy link

Was this fixed? Getting it here: https://travis-ci.org/ActivityWatch/activitywatch/jobs/241466478

@ilevkivskyi
Copy link
Member

@ErikBjare I have no idea which version of Python/typing are you using, but I just tried this on Python 3.4 with typing master and it works as expected.

@ilevkivskyi
Copy link
Member

@ErikBjare OK, I see you are using 3.5.2 in CI, then you need to either upgrade to 3.5.3, or (if not possible) use quoted annotations 'Dict[str, Callable[..., storages.AbstractStorage]]' (it is not pretty, but will be recognized by most type checkers).

spmallette added a commit to apache/tinkerpop that referenced this issue Mar 10, 2020
There's a problem with python 3.5.2 and earlier when it comes to some dependencies on the master branch (3.5.0 at this point). Something related to python/typing#259 and of course xenial only pulls in 3.5.2. We stick to xenial because of 3.3.x/3.4.x...i guess we'd have to do equally oddball things to the docker image if we went to bionic so this change seems like the one of least effort. CTR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants