You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is legitimate to explicitly pass None as key, so is this expected behaviour?
You can do a similar @overload for myfunc to overcome the error.
If you use if key is not None: the problem becomes you can't effectively describe the type of iterator, e.g.:
iterator: Iterator[Tuple[S, Iterator[T]]]
if key is not None:
iterator = itertools.groupby(iterable, key) # Ok
else:
iterator = itertools.groupby(iterable) # Fail
You get the error:
error: Incompatible types in assignment (expression has type "Iterator[Tuple[T, Iterator[T]]]", variable has type "Iterator[Tuple[S, Iterator[T]]]")
And you can't declare the types in each branch because you will get a redeclaration error Name 'iterator' already defined on line ...
Activity
srittau commentedon Feb 11, 2019
It seems that the seconds overload to
groupby()is missing anOptionalannotation. Patches welcome!