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

Support for typing.Iterator and better support for typing.Iterable. #94

Open
xbanke opened this issue May 26, 2020 · 1 comment
Open
Assignees
Labels
enhancement New feature or request
Projects

Comments

@xbanke
Copy link

xbanke commented May 26, 2020

  • typical version: 2.0.17
  • Python version: 3.7.4
  • Operating System:

Description

Iterable can be infinitely.

from typing import Iterable
import typic

def infinite_numbers():
    i = 0
    while 1:
        yield i
        i += 1

@typic.al
def foo(iterable: Iterable[int]):
    print(iterable)

foo(range(5))  # [0, 1, 2, 3, 4]
foo(infinite_numbers())  # never stop

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
@seandstewart seandstewart added the enhancement New feature or request label May 26, 2020
@seandstewart seandstewart self-assigned this May 26, 2020
@seandstewart
Copy link
Owner

Hey @xbanke -

Thanks for the submission. This is a tricky problem, because an Iterable may be an either an Iterator - which can iterate infinitely, or any iterable object/container.

As of right now, there's no existing support for iterators, so this would need to be added.

I don't think I want to change the default behavior of Iterable, but perhaps some intelligence can be added once iterator support is added to try and detect which path to use based upon the input.

@seandstewart seandstewart changed the title typing.Iterable should not be consumed when validate Support for typing.Iterator and smarter support for typing.Iterable. May 26, 2020
@seandstewart seandstewart changed the title Support for typing.Iterator and smarter support for typing.Iterable. Support for typing.Iterator and better support for typing.Iterable. May 26, 2020
@seandstewart seandstewart added this to To do in v2.1 via automation Jun 8, 2020
@seandstewart seandstewart added this to the Typic 2.1 milestone Jun 8, 2020
@seandstewart seandstewart removed this from the Typic 2.1 milestone Jan 5, 2021
@seandstewart seandstewart removed this from To do in v2.1 Jan 5, 2021
@seandstewart seandstewart added this to To do in v2.6 via automation Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
v2.6
To do
Development

No branches or pull requests

2 participants