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

shifting operators are being interpreted as pointless statements #2584

Closed
feluelle opened this issue Nov 7, 2018 · 6 comments
Closed

shifting operators are being interpreted as pointless statements #2584

feluelle opened this issue Nov 7, 2018 · 6 comments
Labels
Invalid Not a bug, already exists or already fixed

Comments

@feluelle
Copy link

feluelle commented Nov 7, 2018

Question

Hey,

I was wondering why the >> operator is interpreted as pointless statement.

For example when I do something like a >> b, the __rshift__ function from a will be called and if this function does change some kind of external state it is not a pointless statement.
Is it a bad practice to change an external state in __rshift__ or why is it being interpreted as W0104: Statement seems to have no effect (pointless-statement) ?

I am asking this because I am currently using apache-airflow and in Airflow it is recommended to use the >> operator to declare graph dependencies.
I do not want to put # pylint: disable=pointless-statement before each of those kind of statements.

It would be nice if I could somehow tell my pylintrc to only disable pointless statement for the bitshifting operator. Is this possible? Or what would you recommend me to do?

@PCManticore PCManticore added the Invalid Not a bug, already exists or already fixed label Nov 23, 2018
@PCManticore
Copy link
Contributor

@feluelle Thanks for creating a question. RIght, that is definitely suggesting to me a code smell, special properties such as __rshift__ should either return a new object or a mutated object, but they shouldn't mutate a global state. pylint tries to figure out if any statement has its value used or not, and given that in your example you mutate a global state, pylint cannot figure (and definitely shouldn't) figure that out.
I think a solution for your use case would definitely be to disable the error locally, given that it's not possible to disable pointless-statement for one operator or another.

@feluelle
Copy link
Author

Thank you for your opinion on this. :)

@martimlobao
Copy link

Resurfacing an old issue, but what's the recommended approach here? We're also trying to use pylint in our airflow deployment, but it's very cumbersome to put # pylint: disable=pointless-statement in every DAG. Is there a better way of doing this?

@feluelle what did you end up doing here? Is there pylint extension that we can use?

@PCManticore Or perhaps a way to disable this specific warning in a specific directory, or only for Airflow task objects or something?

@DanielNoord
Copy link
Collaborator

I don't think there is much more you can do then disable this for projects that use airflow.

@martimlobao
Copy link

Unfortunate, since we use a monorepo which means this is an all-or-nothing situation, and the pointless-statement warning is generally valuable. 😞

I think the #618 Add different configuration for different sub directories ticket might provide the best solution.

@feluelle
Copy link
Author

Hey @martimlobao, sorry but I also don't have a better idea. We moved away from using pylint at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Invalid Not a bug, already exists or already fixed
Projects
None yet
Development

No branches or pull requests

4 participants