https://dagster.io/ logo
#ask-community
Title
# ask-community
c

Chris Histe

12/12/2022, 6:10 PM
Hello support, do you have recommendation to make linters happy with Dagster? One specific problem is
context
missing from function calls since it’s injected by Dagster.
🤖 1
j

jamie

12/13/2022, 5:34 PM
cc @sean
s

sean

12/13/2022, 5:37 PM
Hi Chris, Can you post a code snippet, the linter you’re using, and the linter error you’re seeing? Always working to improve this, unfortunately stuff slips through since the lint errors that appear when developing dagster and when using dagster as a 3rd party lib are often different.
c

Chris Histe

12/15/2022, 1:51 PM
Hi Sean, I’m seeing an
undefined-variable
error when I have context as the first argument on an
@op
, and when I call that op I’m getting a
no-value-for-parameter
because I’m not passing the context. I’m pretty sure it can be fixed by explicitly disabling those rules with
context
but I assume there might be some other Dagster specific rules so I was wondering if you had a lint config you could share with the community (or even better a plugin).
☝🏻😀 @sean
s

sean

12/19/2022, 9:45 PM
hi chris, what linter is this and what dagster version? Going to repro now
In my testing, neither
mypy
nor
pyright
flag this:
Copy code
from dagster import OpExecutionContext, op

@op
def foo(context: OpExecutionContext):
    return 1

foo()
OK I replicated it on pylint. I think this problem is in pylint’s court. Our code is properly type-annotated, which is why neither mypy nor pyright has a problem with the snippet I posted. Pylint’s typechecking functionality is comparatively primitive. I recommend turning off the
pylint
typecheck
checker and using mypy or pyright for typechecking instead. However, if you don’t want to do that, I believe you can configure pylint’s
--signature-mutators
option to tell it that
dagster.op
etc change function signatures, and that should stop it from raising errors for functions decorated with the specified decorators: https://pylint.pycqa.org/en/latest/user_guide/configuration/all-options.html#signature-mutators
c

Chris Histe

12/20/2022, 3:30 PM
Thanks. We’re using
pylint
and
mypy
. We don’t want to turn off
pylint
. Thanks for sharing that link it looks like what we need indeed. I was hoping you would have a recommended pylint config since it’s probably the most used linter. I’ll check out
pyright
maybe I can remove the problem without spending time on config 🙂
s

sean

12/20/2022, 4:07 PM
We don’t want to turn off pylint
Just want to make sure you’re aware that you don’t have to turn off
pylint
entirely to turn off its
typecheck
checker (the part that overlaps mypy).
In fact the dagster repo currently uses pylint and mypy with pylint
typecheck
disabled: https://github.com/dagster-io/dagster/blame/master/pyproject.toml#L137
c

Chris Histe

12/20/2022, 6:25 PM
Oh nice, thanks for sharing
36 Views