Skip to content

Sentinel available in context during option callbacksΒ #3136

Closed

Description

@Rowlando13

Sentinel is an implementation detail that is not intentionally exposed. However, it is in the context params during a callback: sentinel_in_callback.py

import click

def _validate(ctx, param, value):

    you_sentinel = ctx.params.get("you")
    you_too_sentinel = ctx.params.get("you_too")
    print(f"you: {you_sentinel}")
    print(f"you_too: {you_too_sentinel}")
    print(f"param: {param}")
    print(f"value: {value}")
    return value

@click.group()
def basic():
    pass

@basic.command()
@click.argument('you', required=False)
@click.option('--you-too', )
@click.option('--yall', callback=_validate)
@click.pass_context
def hello(ctx, you, you_too, yall):
    click.echo('Hello World!')

if __name__ == '__main__':
    basic()
    # python -m sentinel_in_callback hello
> python -m sentinel_in_callback hello
you: Sentinel.UNSET
you_too: Sentinel.UNSET
param: <Option yall>
value: None
Hello World!

Activity

  1. Rowlando13 commented on Nov 10, 2025

    @Rowlando13
    MemberAuthor

    Minimal reproduction of pallets/flask#5836.

  2. Rowlando13 commented on Nov 11, 2025

    @Rowlando13
    MemberAuthor

    @kdeldycke Can you take a look at this when you get a chance. It is holding up 8.3.1.

  3. added this to the 8.3.1 milestone on Nov 11, 2025
  4. kdeldycke commented on Nov 11, 2025

    @kdeldycke
    Collaborator

    @kdeldycke Can you take a look at this when you get a chance. It is holding up 8.3.1.

    Oh sorry I did not realized that. Was lost in a couple of rabbit holes. I could also benefits from a 8.3.1 release! πŸ˜… Ok let me look into this...

  5. kdeldycke commented on Nov 11, 2025

    @kdeldycke
    Collaborator

    Oh f***. You're not gonna like this. This is a side-effect of:

    Looking for a way to reconcile the two.

  6. kdeldycke commented on Nov 11, 2025

    @kdeldycke
    Collaborator

    I have a fix available at #3137 that is ready for review.

  7. locked as resolved and limited conversation to collaborators on Nov 30, 2025
  8. added
    parsingParsing, parameters, commands, chaining, context
    on Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    parsingParsing, parameters, commands, chaining, context

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions