hatchet-dev / hatchet

A distributed, fault-tolerant task queue
https://hatchet.run
MIT License
3.83k stars 126 forks source link

bug: Pyright complaining about `WorkflowMeta` argument type #689

Closed waydegg closed 2 weeks ago

waydegg commented 2 weeks ago

I'm going through the quickstart for Python, and Pyright (default VSCode Python linter) has an issue with class inheritance when registring a workflow:

# workflow.py

@hatchet.workflow(name="first-python-workflow", on_events=["user:create"])
class MyWorkflow:
    @hatchet.step()
    def step1(self, context):
        return {"result": "success"}

worker = hatchet.worker("first-worker")
worker.register_workflow(MyWorkflow())

Running pyright workflow.py results in the following error:

.../workflow.py
 .../workflow.py:16:26 - error: Argument of type "__class_WorkflowMeta" cannot be assigned to parameter "workflow" of type "WorkflowMeta" in function "register_workflow"
    "__class_WorkflowMeta" is incompatible with "WorkflowMeta" (reportArgumentType)
1 error, 0 warnings, 0 informations

Python Environment Info Hatchet SDK version: 0.27.1 Pyright version: .1.370 Python version: 3.11.9

System Info Model Name: MacBook Pro Model Identifier: Mac15,8 Total Number of Cores: 16 (12 performance and 4 efficiency) Memory: 64 GB System Version: macOS 14.5 (23F79) Secure Virtual Memory: Enabled

abelanger5 commented 1 week ago

Hey @waydegg, this should have been fixed in the latest python release, thanks for the report!