-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Cleanup code by removing if __name__ == '__main__'
pattern
#1922
Conversation
@Tarrasch , Are you saying that |
I believe that to be the case yes. I think there's a few advantages:
Come to think about it. I made a similar statement when I deprecated Does all this make sense to you? :) |
I don't mind the `if name == 'main`` personally. I generally hate overly prescriptive frameworks that impose rules on how to execute stuff. But I guess this is only internal cleanup so LGTM |
Shoot, I'm just behind on the times then. Perhaps due to my comfort with Python, I've always used if __name__ == "__main__":
luigi.run(['NameOfMyTopLevelTask', '--some-option', 'the_value']) Since I don't print or see my non-errors, I was unaware of I'll switch over to |
This patch started out as fixing the red in the current travis flake8 step. As most occurrences was about simply removing the over-(mis)-used `if __name__ == "__main__"` pattern that was way to prevalent in the luigi code base. This is kind of analogous to the other time flake8 suddenly got more sensitive. See spotify#1786
Reviewers: Seems like the actual flake8 issues were fixed in a540006 already, thanks @mrunesson. :) @dlstadther, I'm still not sure if |
if __name__ == '__main__'
pattern
@dlstadther in that case there's no need to involve command line parsing. iirc you can just do |
This is exactly like spotify#1922, only that I forgot to search for '__main__' with single qoutes. This patch completes that PR.
This is exactly like #1922, only that I forgot to search for '__main__' with single qoutes. This patch completes that PR.
This is exactly like spotify#1922, only that I forgot to search for '__main__' with single qoutes. This patch completes that PR.
This patch started out as fixing the red in the current travis flake8
step. As most occurrences was about simply removing the over-(mis)-used
if __name__ == "__main__"
pattern that was way to prevalent in the luigicode base.
This is kind of analogous to the other time flake8 suddenly got more
sensitive. See #1786