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

Mypy issue with task_runner argument of flow #16938

Open
david-gang opened this issue Feb 3, 2025 · 1 comment
Open

Mypy issue with task_runner argument of flow #16938

david-gang opened this issue Feb 3, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@david-gang
Copy link

Bug summary

Mypy does not pass on an example from the prefect website

from prefect import flow, task
from prefect.futures import wait
from prefect.task_runners import ThreadPoolTaskRunner
import time


@task
def stop_at_floor(floor):
    print(f"elevator moving to floor {floor}")
    time.sleep(floor)
    print(f"elevator stops on floor {floor}")


@flow(task_runner=ThreadPoolTaskRunner(max_workers=3))
def elevator():
    floors = []

    for floor in range(10, 0, -1):
        floors.append(stop_at_floor.submit(floor))

    wait(floors)

This is the pyproject.toml

[project]
name = "prefect-playground"
version = "0.1.0"
description = ""
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
    "prefect (>=3.1.15,<4.0.0)"
]


[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.group.dev.dependencies]
mypy = "^1.14.1"

poetry run mypy .
example.py:14: error: Argument "task_runner" to "call" of "FlowDecorator" has incompatible type "ThreadPoolTaskRunner[Never]"; >expected "TaskRunner[PrefectFuture[Never]] | None" [arg-type]
Found 1 error in 1 file (checked 1 source file)

This is python 3.12

Version info

poetry run prefect version
Version:             3.1.15
API version:         0.8.4
Python version:      3.12.8
Git commit:          3ac3d548
Built:               Thu, Jan 30, 2025 11:31 AM
OS/Arch:             darwin/arm64
Profile:             ephemeral
Server type:         ephemeral
Pydantic version:    2.11.0a1
Server:
  Database:          sqlite
  SQLite version:    3.43.2

Additional context

No response

@david-gang david-gang added the bug Something isn't working label Feb 3, 2025
@david-gang
Copy link
Author

Looks connected to: #16876

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant