Skip to content

Commit

Permalink
Addressed clippy warnings and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jpalvarezl committed Sep 30, 2024
1 parent 687858a commit 611f716
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 20 deletions.
8 changes: 4 additions & 4 deletions sdk/openai/inference/src/credentials/azure_key_credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Header for AzureKeyCredential {
}

fn value(&self) -> HeaderValue {
HeaderValue::from_cow(format!("{}", self.0.secret()))
HeaderValue::from_cow(self.0.secret().to_string())
}
}

Expand All @@ -57,8 +57,8 @@ impl Policy for AzureKeyCredential {
}
}

impl Into<Arc<dyn Policy>> for AzureKeyCredential {
fn into(self) -> Arc<dyn Policy> {
Arc::new(self)
impl From<AzureKeyCredential> for Arc<dyn Policy> {
fn from(credential: AzureKeyCredential) -> Arc<dyn Policy> {
Arc::new(credential)
}
}
3 changes: 1 addition & 2 deletions sdk/openai/inference/src/credentials/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ mod openai_key_credential;
pub(crate) use azure_key_credential::*;
pub(crate) use openai_key_credential::*;

pub(crate) const DEFAULT_SCOPE: [&'static str; 1] =
["https://cognitiveservices.azure.com/.default"];
pub(crate) const DEFAULT_SCOPE: [&str; 1] = ["https://cognitiveservices.azure.com/.default"];
6 changes: 3 additions & 3 deletions sdk/openai/inference/src/credentials/openai_key_credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ impl Policy for OpenAIKeyCredential {
}
}

impl Into<Arc<dyn Policy>> for OpenAIKeyCredential {
fn into(self) -> Arc<dyn Policy> {
Arc::new(self)
impl From<OpenAIKeyCredential> for Arc<dyn Policy> {
fn from(credential: OpenAIKeyCredential) -> Arc<dyn Policy> {
Arc::new(credential)
}
}
2 changes: 1 addition & 1 deletion sdk/openai/inference/src/helpers/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub(crate) fn string_chunks<'a>(
None
};
}
if chunk_buffer.len() > 0 {
if !chunk_buffer.is_empty() {
return Some((
Err(Error::with_message(
azure_core::error::ErrorKind::DataConversion,
Expand Down
4 changes: 2 additions & 2 deletions sdk/openai/inference/src/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ mod azure_openai_client_options;
mod openai_client_options;
mod service_version;

pub use azure_openai_client_options::*;
pub use openai_client_options::*;
pub use azure_openai_client_options::{builders::*, AzureOpenAIClientOptions};
pub use openai_client_options::{builders::*, OpenAIClientOptions};
pub use service_version::AzureServiceVersion;
16 changes: 8 additions & 8 deletions sdk/openai/inference/src/options/service_version.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
use async_trait::async_trait;
use std::sync::Arc;
use std::{fmt::Display, sync::Arc};

use azure_core::{Context, Policy, PolicyResult, Request};

Expand Down Expand Up @@ -36,13 +36,13 @@ impl From<AzureServiceVersion> for String {
AzureServiceVersion::V2023_12_01Preview => "2023-12-01-preview",
AzureServiceVersion::V2024_07_01Preview => "2024-07-01-preview",
};
return String::from(as_str);
String::from(as_str)
}
}

impl ToString for AzureServiceVersion {
fn to_string(&self) -> String {
String::from(self.clone())
impl Display for AzureServiceVersion {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&String::from(self.clone()))
}
}

Expand All @@ -64,8 +64,8 @@ impl Policy for AzureServiceVersion {
}
}

impl Into<Arc<dyn Policy>> for AzureServiceVersion {
fn into(self) -> Arc<dyn Policy> {
Arc::new(self)
impl From<AzureServiceVersion> for Arc<dyn Policy> {
fn from(version: AzureServiceVersion) -> Arc<dyn Policy> {
Arc::new(version)
}
}

0 comments on commit 611f716

Please sign in to comment.