Hey are there any better way of dealing with pylin...
# ask-community
t
Hey are there any better way of dealing with pylint error or should I just disable these lints: When using DynamicOut:
Copy code
some_op().map(another_op)
E1101: Generator 'generator' has no 'map' member (no-member)
And using context in ops:
No value for argument 'context' in function call (no-value-for-parameter)
🤖 1
s
Hi Tadas, just letting you know I'm looking into this.
t
@sean thanks!
s
hi @sean were you able to find an answer? I googled around and found these older related threads. https://github.com/dagster-io/dagster/issues/1720 https://github.com/PyCQA/pylint/pull/2926 It seems like it is currently implemented as
signature_mutator
instead of
function_mutator
. But also, what I took away from this thread is that if the decorator is properly annotated, this wouldn't be an issue https://github.com/microsoft/pyright/issues/660
t
@sean did you had an opportunity to check this?
s
Hi Tadas and Stanely, my aploogies for the long wait on this. I just looked into this and here are my conclusions/recommendations: • Pylint’s typechecking functionality is pretty basic and struggles with the kind of logic we use for op composition. • The only pylint-based workaround is the
--signature-mutators
option for the
typecheck
checker. In theory this just makes functions decorated by the target opaque to pylint, so pylint won’t typecheck e.g. the return value. So adding
dagster.op
to pylint’s
signature-mutators
should fix the problem in OP. • That said, I was unable to get it to work-- I included this in a
pyproject.toml
but continued to see the original problem:
Copy code
[tool.pylint.typecheck]
signature-mutators = ['dagster.op']
• In any case, it doesn’t really matter because unfortunately, there is no way for us as library developers to make sure
signature-mutators
is set on the user end for functions in our library-- basically
signature-mutators
is part of
pylint
configuration, and we can’t control user
pylint
configuration. The only way we as developers have to communicate with the user’s
pylint
is by appropriately annotating our decorators, but in this case I believe we’ve done that but
pylint
does not account for it. Given this, there are two possible solutions: • *RECOMMENDED: Disable the pylint
typecheck
checker. * This checker is redundant with mypy and/or pyright anyway, both of which understand Dagster’s annotations and do not raise an error for OP. • *ALTERNATIVE: Configure pylint
signature-mutators
on the user end to exclude
op
. * @Stanley Yang the thread you linked is for pyright, and it’s correct that Pyright won’t raise errors for properly annotated functions, but that doesn’t seem to be true of pylint. Please let me know if I’ve missed something here or you have more information!
s
thanks @sean! that makes sense and we will try it out
t
@sean thanks!
Copy code
[tool.pylint.typecheck]
signature-mutators = ['op']
I added this snippet to my pyproject.toml and it worked 🙂 But it only solves part of the problem. I’m still getting:
E1101: Generator 'generator' has no 'map' member (no-member)
for code using DynamicOut:
Copy code
some_op().map(another_op)
s
Tadas yeah that’s the behavior I tested, which adding signature mutators did not fix. I guess I had pylint configured correctly. It appears that in this case, signature-mutators just doesn’t work. I can only recommend you follow either (1) take it up with
pylint
, this might be a bug-- it seems like
signature-mutators
should disable
no-member
checks; or (b) disable the pylint
typecheck
checker and use
mypy
or
pyright
instead. Sorry I don’t have a better solution.
t
I’ve modified my config like this:
Copy code
[tool.pylint.typecheck]
generated-members = ["map"]
signature-mutators = ["op"]
Lets say map is a generated-member 🙂
blob thumbs up 1