def _should_skip_switch(args: Namespace) -> bool:
    """Check if we should skip the config switch operation.

    :param args: arguments received from the command-line of
        ``patroni_barman config-switch`` command.

    :returns: if the operation should be skipped.
    """
    if args.switch_when == "promoted":
        return args.role not in {"primary", "promoted"}
    if args.switch_when == "demoted":
        return args.role not in {"replica", "demoted"}
    return False
Check if we should skip the config switch operation.

    :param args: arguments received from the command-line of
        ``patroni_barman config-switch`` command.

    :returns: if the operation should be skipped.
    
patroni/scripts/barman/config_switch.py