Message303839
| Author | levkivskyi |
|---|---|
| Recipients | levkivskyi, srittau |
| Date | 2017-10-06.17:06:28 |
| SpamBayes Score | -1.0 |
| Marked as misclassified | Yes |
| Message-id | <1507309588.53.0.213398074469.issue31700@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
You can use Iterator type, for example this works in mypy (didn't test in other type checkers):
def f() -> Iterator[int]:
yield 42
In case you want annotate something specifically as Generator[int, None, None] (for example to use its .close() method), then you can create a generic alias:
T = TypeVar('T')
Gen = Generator[T, None, None]
def f() -> Gen[int]:
...
this is supported by mypy as well. |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2017-10-06 17:06:28 | levkivskyi | set | recipients: + levkivskyi, srittau |
| 2017-10-06 17:06:28 | levkivskyi | set | messageid: <1507309588.53.0.213398074469.issue31700@psf.upfronthosting.co.za> |
| 2017-10-06 17:06:28 | levkivskyi | link | issue31700 messages |
| 2017-10-06 17:06:28 | levkivskyi | create | |