Auto-fix clippy::collapsible_if violations (#36428)

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-08-19 15:27:24 +02:00 committed by GitHub
parent 9e8ec72bd5
commit 8f567383e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
281 changed files with 6628 additions and 7089 deletions

View file

@ -633,11 +633,11 @@ pub fn into_anthropic(
Role::Assistant => anthropic::Role::Assistant,
Role::System => unreachable!("System role should never occur here"),
};
if let Some(last_message) = new_messages.last_mut() {
if last_message.role == anthropic_role {
last_message.content.extend(anthropic_message_content);
continue;
}
if let Some(last_message) = new_messages.last_mut()
&& last_message.role == anthropic_role
{
last_message.content.extend(anthropic_message_content);
continue;
}
// Mark the last segment of the message as cached

View file

@ -412,10 +412,10 @@ impl BedrockModel {
.region(Region::new(region))
.timeout_config(TimeoutConfig::disabled());
if let Some(endpoint_url) = endpoint {
if !endpoint_url.is_empty() {
config_builder = config_builder.endpoint_url(endpoint_url);
}
if let Some(endpoint_url) = endpoint
&& !endpoint_url.is_empty()
{
config_builder = config_builder.endpoint_url(endpoint_url);
}
match auth_method {
@ -728,11 +728,11 @@ pub fn into_bedrock(
Role::Assistant => bedrock::BedrockRole::Assistant,
Role::System => unreachable!("System role should never occur here"),
};
if let Some(last_message) = new_messages.last_mut() {
if last_message.role == bedrock_role {
last_message.content.extend(bedrock_message_content);
continue;
}
if let Some(last_message) = new_messages.last_mut()
&& last_message.role == bedrock_role
{
last_message.content.extend(bedrock_message_content);
continue;
}
new_messages.push(
BedrockMessage::builder()

View file

@ -597,15 +597,13 @@ impl CloudLanguageModel {
.headers()
.get(SUBSCRIPTION_LIMIT_RESOURCE_HEADER_NAME)
.and_then(|resource| resource.to_str().ok())
{
if let Some(plan) = response
&& let Some(plan) = response
.headers()
.get(CURRENT_PLAN_HEADER_NAME)
.and_then(|plan| plan.to_str().ok())
.and_then(|plan| cloud_llm_client::Plan::from_str(plan).ok())
{
return Err(anyhow!(ModelRequestLimitReachedError { plan }));
}
{
return Err(anyhow!(ModelRequestLimitReachedError { plan }));
}
} else if status == StatusCode::PAYMENT_REQUIRED {
return Err(anyhow!(PaymentRequiredError));
@ -662,29 +660,29 @@ where
impl From<ApiError> for LanguageModelCompletionError {
fn from(error: ApiError) -> Self {
if let Ok(cloud_error) = serde_json::from_str::<CloudApiError>(&error.body) {
if cloud_error.code.starts_with("upstream_http_") {
let status = if let Some(status) = cloud_error.upstream_status {
status
} else if cloud_error.code.ends_with("_error") {
error.status
} else {
// If there's a status code in the code string (e.g. "upstream_http_429")
// then use that; otherwise, see if the JSON contains a status code.
cloud_error
.code
.strip_prefix("upstream_http_")
.and_then(|code_str| code_str.parse::<u16>().ok())
.and_then(|code| StatusCode::from_u16(code).ok())
.unwrap_or(error.status)
};
if let Ok(cloud_error) = serde_json::from_str::<CloudApiError>(&error.body)
&& cloud_error.code.starts_with("upstream_http_")
{
let status = if let Some(status) = cloud_error.upstream_status {
status
} else if cloud_error.code.ends_with("_error") {
error.status
} else {
// If there's a status code in the code string (e.g. "upstream_http_429")
// then use that; otherwise, see if the JSON contains a status code.
cloud_error
.code
.strip_prefix("upstream_http_")
.and_then(|code_str| code_str.parse::<u16>().ok())
.and_then(|code| StatusCode::from_u16(code).ok())
.unwrap_or(error.status)
};
return LanguageModelCompletionError::UpstreamProviderError {
message: cloud_error.message,
status,
retry_after: cloud_error.retry_after.map(Duration::from_secs_f64),
};
}
return LanguageModelCompletionError::UpstreamProviderError {
message: cloud_error.message,
status,
retry_after: cloud_error.retry_after.map(Duration::from_secs_f64),
};
}
let retry_after = None;