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

ChoiceParameter should raise an error when passed invalid choice #2454

Merged
merged 1 commit into from
Jul 10, 2018

Conversation

jotinha
Copy link
Contributor

@jotinha jotinha commented Jul 10, 2018

Description

Validates ChoiceParameter when initializing a task by moving the logic from .parse to .normalize. Currently this validation only runs when calling from the command line, when the method .parse is called. Moving it to .normalize ensure it always runs

Motivation and Context

I was having an issue where I was requiring a task with an invalid ChoiceParameter but no ValueError was raising at task init time.

class Foo(luigi.Task):
     args = luigi.ChoiceParameter(var_type=str, choices=["1", "2", "3"])

Foo(args="bar") #should raise an Error

Have you tested this? If so, how?

Added tests

@Tarrasch
Copy link
Contributor

Nice fix. Thanks!

@Tarrasch Tarrasch merged commit bdfcb6c into spotify:master Jul 10, 2018
thisiscab pushed a commit to glossier/luigi that referenced this pull request Aug 3, 2018
thisiscab pushed a commit to glossier/luigi that referenced this pull request Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants