Hey! First note: Dagster is awesome! :planet-dagg...
# ask-community
v
Hey! First note: Dagster is awesome! 🪐 I am using pyright as my typechecking tool. However, it is complaining about the context object not being passed when on OP is called.
Copy code
@op(
    ins={"start": In(Nothing)},
    out={"test_configuration": Out(TestConfiguration)},
    required_resource_keys={"test_system"},
)
def setup_benchmark(context: OpExecutionContext) -> TestConfiguration:
    ....

@graph()
def run_experiment():
    test_configuration = setup_benchmark()
It gives the following error:
Copy code
error: Argument missing for parameter "context" (reportGeneralTypeIssues)
Any idea how i should fix this? 🙂
j
@sean you were recently looking at pyright right? any ideas on this?
s
Hi Vince, getting our typing situation squared away is a very active area of focus right now so thanks for bringing this to our attention. I’ve taken your snippet and I’m trying to replicate this error, but I’m not seeing it even with pyright strict mode on. When I introspect the type of
setup_benchmark
inside
run_experiment
, I’m seeing
OpDefinition
, which is what I’d expect. This has a
__call__
method with signature:
Copy code
python
def __call__(self, *args, **kwargs) -> Any
So it makes sense that I’m not seeing the error (there’s no enforcement of
context
here). Are you sure you’ve shown the right line triggering the error? Also, are you using recent versions of dagster and pyright? And just curious, how are you getting pyright to read
dagster
? Did you turn
useLibraryCodeForTypes
on, or did you add
dagster
to pyright’s
extraPaths
?
v
Hi Sean, I will try to setup an empty project to try to replicate it for you.
I am using poetry as a package manager, in it's pyproject.toml i have defined the following:
Copy code
[tool.pyright]
reportMissingImports = false
reportMissingTypeStubs = false
reportUnknownMemberType = false
reportUnusedImport = false
useLibraryCodeForTypes
is not turned on, and i have not added
dagster
to pyrights
extraPaths
. Is that something I should do?
You should be able to install packages with
poetry install
inside the folder
And able to run pyright with
poetry run pyright .
If there is anything else i can provider, please let me know 🙂
Copy code
from dagster import In, Nothing, OpExecutionContext, graph, job, op

@op(
    ins={"start": In(Nothing)},
)
def start_test(context: OpExecutionContext) -> None:
    pass

@job
def run_job_test():
    start_test()


@graph
def run_graph_test():
    start_test()

if __name__ == "__main__":
    run_graph_test.to_job().execute_in_process()
    run_job_test.execute_in_process()
Copy code
/Users/vincevannoort/Projects/dagster-typing-test/dagster_typing_test/repo.py:11:5 - error: Argument missing for parameter "context" (reportGeneralTypeIssues)
  /Users/vincevannoort/Projects/dagster-typing-test/dagster_typing_test/repo.py:16:5 - error: Argument missing for parameter "context" (reportGeneralTypeIssues)
This is the code (also inside the zip) and errors
The project runs fine, so that is not the issue
@sean do you have any idea? (thanks in advance 🙂)