-
Notifications
You must be signed in to change notification settings - Fork 63
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
SKIP doesn't behave as expected #107
Comments
Hi Maciej! I've struggled a bit with SKIP in tuples myself, in fact. SKIP's meant to be used for optional processing steps in the tuple. For aborting the processing, you'd want to use |
@mahmoud: glom({'data': {'class': 'foo', 'val': 42}},
('data', lambda x: x if x.get('class') == 'bar' else STOP))
>>> {'class': 'foo', 'val': 42} |
Ah, so the desired behavior is that the target would get dropped if a SKIP (or maybe a STOP) is returned from the tuple? Actually, if you wouldn't mind including the desired output for the example(s) above that'd be great! |
@mathrick just a gentle ping on the example; I'm still thinkin about this one! |
Ah, sorry, I got busy with another part of my project and I forgot to reply here. The output is a bit of a tricky area, since in the example above, you really want "nothing" (ie. no values at all, not even display_name = glom(user,
(Check(has_completed_profile, default=STOP),
Coalesce(
(Check(has_new_profile, default=SKIP), 'profile.display_name'),
(Check(has_legacy_profile, default=SKIP), 'user_profile.name')),
format_for_display))
if display_name == SKIP:
raise redirect(url_for(complete_user_profile)) Here If |
@mahmoud: just a quick ping, is this clear enough, or do you need more info? |
Hmm, yeah I think more info would be helpful. The code blocks above detail some of the data and some prospective specs, so really the only thing remaining would be the expected output. Would love to see that. By the by, we're working on a |
Trivial example:
SKIP
, in a tuple, essentially results in whatever spec produced it not being there, rather than the entire compound spec (ie. the surrounding tuple) coming to a halt. That is not super important in the example above, but I constantly run into it in my glom-based parser / pattern matcher, where I have a potential match that needs further processing:I'd expect
SKIP
to essentially abort the entire "branch" of a computation (which is what a tuple of spec is, really), but instead it happily lets through whatever was the target before, leading to a lot unexpected results.The text was updated successfully, but these errors were encountered: