Closed cswartzvi closed 3 weeks ago
Thanks @cswartzvi for the find! Would you mind throwing up a PR? That way we could get a clean sense of how the tests run to determine if your suggestion would require further work. Otherwise I'll defer to @elijahbenizzy here to comment on your proposed code.
First off, I wanted to say "thanks", this project is a breath of fresh air and exactly what I was looking for. Please keep up the great work!
I was working along with Dynamic DAGs/Parallel Execution when I encountered a type checking error using
Parallelizable
as prescribed in the docs.Current behavior
Annotating a generator function with
Parallelizable
(see example below) results in the followingpyright
type error in either VS Code (using thebasic
type checking mode) and/or the command line:Full disclosure: I did not encounter any errors with
mypy
, even in strict mode.Screenshots
Note: The text of the error message is slightly different then the command line.
Steps to replicate behavior
pyright
(either via VS Code or on the command line) on the following code:def url() -> Parallelizable[str]: for url in ["web1", "web2", "web3"]: yield url
def url_loaded(url: str) -> str: return url
def counts(url_loaded: str) -> int: return len(url_loaded.split(" "))
def total_words(counts: Collect[int]) -> int: return sum(counts)
I added these changes to a fork and ran the executor tests successfully. Note that I was having issues with other tests before I made the change - maybe because I am on Windows - so I cannot comment on the rest of the test suite. If you think this is a worthwhile addition to Hamilton I would be honored to submit a PR - let me know. Thanks!